diff --git a/sdk/monitor/azure-mgmt-monitor/_meta.json b/sdk/monitor/azure-mgmt-monitor/_meta.json index f0638d534bd2..a2420a50ed7e 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": "3142a53ae6aa3da406c001215ba3ee023c46c518", "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 --python3-only --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 3805e3b3d057..7a92a65b34c6 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 3dcd1e009c20..137c91121118 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 ef0b2052527f..d1088d0ae2a5 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 41a59c75017f..d864d21a5b37 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 d82479510092..ec9090a57df0 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 224f0bceaf6e..e1f58c99be3f 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 @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class MonitorManagementClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(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 +64,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/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 c77504598874..3399fadde882 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 030cec917f7b..de9d3cc08044 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,98 +6,94 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import 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 - -class MonitorManagementClient(object): +class MonitorManagementClient: """Monitor Management Client. :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] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + 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: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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 000000000000..74e48ecd07cf --- /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 000000000000..138f663c53a4 --- /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 cac9f5d10f8b..e5754a47ce68 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 96ce9b45c05b..4eba911f1c6e 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 a1b513c610d4..34bea0f7b202 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 0e8dd89e73a9..1859b81d454f 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 000000000000..74e48ecd07cf --- /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 41231e863452..6ebd670f23bf 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 fe527b21b961..0090b24ecd12 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 d6e489c04fa1..19844d7ade46 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 288c4bc49327..16baeea9aeca 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 53313b5ec127..2a7b6d9a147a 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 53fd30b722a5..e9a9c1f5aab2 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/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/__init__.py index 7e432fc032b0..8c2ce56ff580 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/__init__.py @@ -6,90 +6,48 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import AlertRuleResource - from ._models_py3 import AlertRuleResourceCollection - from ._models_py3 import AlertRuleResourcePatch - from ._models_py3 import AutoscaleNotification - from ._models_py3 import AutoscaleProfile - from ._models_py3 import AutoscaleSettingResource - from ._models_py3 import AutoscaleSettingResourceCollection - from ._models_py3 import AutoscaleSettingResourcePatch - from ._models_py3 import EmailNotification - from ._models_py3 import ErrorResponse - from ._models_py3 import EventCategoryCollection - from ._models_py3 import EventData - from ._models_py3 import EventDataCollection - from ._models_py3 import HttpRequestInfo - from ._models_py3 import LocalizableString - from ._models_py3 import LocationThresholdRuleCondition - from ._models_py3 import ManagementEventAggregationCondition - from ._models_py3 import ManagementEventRuleCondition - from ._models_py3 import MetricTrigger - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationListResult - from ._models_py3 import Recurrence - from ._models_py3 import RecurrentSchedule - from ._models_py3 import Resource - from ._models_py3 import RuleAction - from ._models_py3 import RuleCondition - from ._models_py3 import RuleDataSource - from ._models_py3 import RuleEmailAction - from ._models_py3 import RuleManagementEventClaimsDataSource - from ._models_py3 import RuleManagementEventDataSource - from ._models_py3 import RuleMetricDataSource - from ._models_py3 import RuleWebhookAction - from ._models_py3 import ScaleAction - from ._models_py3 import ScaleCapacity - from ._models_py3 import ScaleRule - from ._models_py3 import ScaleRuleMetricDimension - from ._models_py3 import SenderAuthorization - from ._models_py3 import ThresholdRuleCondition - from ._models_py3 import TimeWindow - from ._models_py3 import WebhookNotification -except (SyntaxError, ImportError): - from ._models import AlertRuleResource # type: ignore - from ._models import AlertRuleResourceCollection # type: ignore - from ._models import AlertRuleResourcePatch # type: ignore - from ._models import AutoscaleNotification # type: ignore - from ._models import AutoscaleProfile # type: ignore - from ._models import AutoscaleSettingResource # type: ignore - from ._models import AutoscaleSettingResourceCollection # type: ignore - from ._models import AutoscaleSettingResourcePatch # type: ignore - from ._models import EmailNotification # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import EventCategoryCollection # type: ignore - from ._models import EventData # type: ignore - from ._models import EventDataCollection # type: ignore - from ._models import HttpRequestInfo # type: ignore - from ._models import LocalizableString # type: ignore - from ._models import LocationThresholdRuleCondition # type: ignore - from ._models import ManagementEventAggregationCondition # type: ignore - from ._models import ManagementEventRuleCondition # type: ignore - from ._models import MetricTrigger # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationListResult # type: ignore - from ._models import Recurrence # type: ignore - from ._models import RecurrentSchedule # type: ignore - from ._models import Resource # type: ignore - from ._models import RuleAction # type: ignore - from ._models import RuleCondition # type: ignore - from ._models import RuleDataSource # type: ignore - from ._models import RuleEmailAction # type: ignore - from ._models import RuleManagementEventClaimsDataSource # type: ignore - from ._models import RuleManagementEventDataSource # type: ignore - from ._models import RuleMetricDataSource # type: ignore - from ._models import RuleWebhookAction # type: ignore - from ._models import ScaleAction # type: ignore - from ._models import ScaleCapacity # type: ignore - from ._models import ScaleRule # type: ignore - from ._models import ScaleRuleMetricDimension # type: ignore - from ._models import SenderAuthorization # type: ignore - from ._models import ThresholdRuleCondition # type: ignore - from ._models import TimeWindow # type: ignore - from ._models import WebhookNotification # type: ignore +from ._models_py3 import AlertRuleResource +from ._models_py3 import AlertRuleResourceCollection +from ._models_py3 import AlertRuleResourcePatch +from ._models_py3 import AutoscaleNotification +from ._models_py3 import AutoscaleProfile +from ._models_py3 import AutoscaleSettingResource +from ._models_py3 import AutoscaleSettingResourceCollection +from ._models_py3 import AutoscaleSettingResourcePatch +from ._models_py3 import EmailNotification +from ._models_py3 import ErrorResponse +from ._models_py3 import EventCategoryCollection +from ._models_py3 import EventData +from ._models_py3 import EventDataCollection +from ._models_py3 import HttpRequestInfo +from ._models_py3 import LocalizableString +from ._models_py3 import LocationThresholdRuleCondition +from ._models_py3 import ManagementEventAggregationCondition +from ._models_py3 import ManagementEventRuleCondition +from ._models_py3 import MetricTrigger +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationListResult +from ._models_py3 import Recurrence +from ._models_py3 import RecurrentSchedule +from ._models_py3 import Resource +from ._models_py3 import RuleAction +from ._models_py3 import RuleCondition +from ._models_py3 import RuleDataSource +from ._models_py3 import RuleEmailAction +from ._models_py3 import RuleManagementEventClaimsDataSource +from ._models_py3 import RuleManagementEventDataSource +from ._models_py3 import RuleMetricDataSource +from ._models_py3 import RuleWebhookAction +from ._models_py3 import ScaleAction +from ._models_py3 import ScaleCapacity +from ._models_py3 import ScaleRule +from ._models_py3 import ScaleRuleMetricDimension +from ._models_py3 import SenderAuthorization +from ._models_py3 import ThresholdRuleCondition +from ._models_py3 import TimeWindow +from ._models_py3 import WebhookNotification + from ._monitor_management_client_enums import ( ComparisonOperationType, 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 deleted file mode 100644 index 8996b10f93c8..000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/_models.py +++ /dev/null @@ -1,1806 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class Resource(msrest.serialization.Model): - """An azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :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] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - - -class AlertRuleResource(Resource): - """The alert rule resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :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 - 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 - when an alert condition is resolved. - :type 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 - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'name_properties_name': {'required': True}, - 'is_enabled': {'required': True}, - 'condition': {'required': True}, - 'last_updated_time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'name_properties_name': {'key': 'properties.name', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'is_enabled': {'key': 'properties.isEnabled', 'type': 'bool'}, - 'condition': {'key': 'properties.condition', 'type': 'RuleCondition'}, - 'action': {'key': 'properties.action', 'type': 'RuleAction'}, - 'actions': {'key': 'properties.actions', 'type': '[RuleAction]'}, - 'last_updated_time': {'key': 'properties.lastUpdatedTime', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(AlertRuleResource, self).__init__(**kwargs) - self.name_properties_name = kwargs['name_properties_name'] - self.description = kwargs.get('description', None) - self.provisioning_state = kwargs.get('provisioning_state', None) - self.is_enabled = kwargs['is_enabled'] - self.condition = kwargs['condition'] - self.action = kwargs.get('action', None) - self.actions = kwargs.get('actions', None) - self.last_updated_time = None - - -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] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[AlertRuleResource]'}, - } - - def __init__( - self, - **kwargs - ): - super(AlertRuleResourceCollection, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class AlertRuleResourcePatch(msrest.serialization.Model): - """The alert rule object for patch operations. - - 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 - 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 - when an alert condition is resolved. - :type 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 - """ - - _validation = { - 'last_updated_time': {'readonly': True}, - } - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'name': {'key': 'properties.name', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'is_enabled': {'key': 'properties.isEnabled', 'type': 'bool'}, - 'condition': {'key': 'properties.condition', 'type': 'RuleCondition'}, - 'action': {'key': 'properties.action', 'type': 'RuleAction'}, - 'actions': {'key': 'properties.actions', 'type': '[RuleAction]'}, - 'last_updated_time': {'key': 'properties.lastUpdatedTime', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(AlertRuleResourcePatch, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.name = kwargs.get('name', None) - self.description = kwargs.get('description', None) - self.provisioning_state = kwargs.get('provisioning_state', None) - self.is_enabled = kwargs.get('is_enabled', None) - self.condition = kwargs.get('condition', None) - self.action = kwargs.get('action', None) - self.actions = kwargs.get('actions', None) - self.last_updated_time = None - - -class AutoscaleNotification(msrest.serialization.Model): - """Autoscale notification. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar 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] - """ - - _validation = { - 'operation': {'required': True, 'constant': True}, - } - - _attribute_map = { - 'operation': {'key': 'operation', 'type': 'str'}, - 'email': {'key': 'email', 'type': 'EmailNotification'}, - 'webhooks': {'key': 'webhooks', 'type': '[WebhookNotification]'}, - } - - operation = "Scale" - - def __init__( - self, - **kwargs - ): - super(AutoscaleNotification, self).__init__(**kwargs) - self.email = kwargs.get('email', None) - self.webhooks = kwargs.get('webhooks', None) - - -class AutoscaleProfile(msrest.serialization.Model): - """Autoscale profile. - - 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 - 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 - """ - - _validation = { - 'name': {'required': True}, - 'capacity': {'required': True}, - 'rules': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'ScaleCapacity'}, - 'rules': {'key': 'rules', 'type': '[ScaleRule]'}, - 'fixed_date': {'key': 'fixedDate', 'type': 'TimeWindow'}, - 'recurrence': {'key': 'recurrence', 'type': 'Recurrence'}, - } - - def __init__( - self, - **kwargs - ): - super(AutoscaleProfile, self).__init__(**kwargs) - self.name = kwargs['name'] - self.capacity = kwargs['capacity'] - self.rules = kwargs['rules'] - self.fixed_date = kwargs.get('fixed_date', None) - self.recurrence = kwargs.get('recurrence', None) - - -class AutoscaleSettingResource(Resource): - """The autoscale setting resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :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 - 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 - 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 - should be added to. - :type target_resource_uri: str - :param target_resource_location: the location of the resource that the autoscale setting should - be added to. - :type target_resource_location: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'profiles': {'required': True, 'max_items': 20, 'min_items': 0}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'profiles': {'key': 'properties.profiles', 'type': '[AutoscaleProfile]'}, - 'notifications': {'key': 'properties.notifications', 'type': '[AutoscaleNotification]'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - 'name_properties_name': {'key': 'properties.name', 'type': 'str'}, - 'target_resource_uri': {'key': 'properties.targetResourceUri', 'type': 'str'}, - 'target_resource_location': {'key': 'properties.targetResourceLocation', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AutoscaleSettingResource, self).__init__(**kwargs) - self.profiles = kwargs['profiles'] - self.notifications = kwargs.get('notifications', None) - self.enabled = kwargs.get('enabled', True) - self.name_properties_name = kwargs.get('name_properties_name', None) - self.target_resource_uri = kwargs.get('target_resource_uri', None) - self.target_resource_location = kwargs.get('target_resource_location', None) - - -class AutoscaleSettingResourceCollection(msrest.serialization.Model): - """Represents a collection of autoscale setting resources. - - 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 - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[AutoscaleSettingResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AutoscaleSettingResourceCollection, self).__init__(**kwargs) - self.value = kwargs['value'] - self.next_link = kwargs.get('next_link', None) - - -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 - 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 - 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 - should be added to. - :type target_resource_uri: str - :param target_resource_location: the location of the resource that the autoscale setting should - be added to. - :type target_resource_location: str - """ - - _validation = { - 'profiles': {'max_items': 20, 'min_items': 0}, - } - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'profiles': {'key': 'properties.profiles', 'type': '[AutoscaleProfile]'}, - 'notifications': {'key': 'properties.notifications', 'type': '[AutoscaleNotification]'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - 'name': {'key': 'properties.name', 'type': 'str'}, - 'target_resource_uri': {'key': 'properties.targetResourceUri', 'type': 'str'}, - 'target_resource_location': {'key': 'properties.targetResourceLocation', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AutoscaleSettingResourcePatch, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.profiles = kwargs.get('profiles', None) - self.notifications = kwargs.get('notifications', None) - self.enabled = kwargs.get('enabled', True) - self.name = kwargs.get('name', None) - self.target_resource_uri = kwargs.get('target_resource_uri', None) - self.target_resource_location = kwargs.get('target_resource_location', None) - - -class EmailNotification(msrest.serialization.Model): - """Email notification of an autoscale event. - - :param 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 - 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 - this attribute will be ignored. - :type custom_emails: list[str] - """ - - _attribute_map = { - 'send_to_subscription_administrator': {'key': 'sendToSubscriptionAdministrator', 'type': 'bool'}, - 'send_to_subscription_co_administrators': {'key': 'sendToSubscriptionCoAdministrators', 'type': 'bool'}, - 'custom_emails': {'key': 'customEmails', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - 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) - self.custom_emails = kwargs.get('custom_emails', None) - - -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 - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - - -class EventCategoryCollection(msrest.serialization.Model): - """A collection of event categories. Currently possible values are: Administrative, Security, ServiceHealth, Alert, Recommendation, Policy. - - 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] - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[LocalizableString]'}, - } - - def __init__( - self, - **kwargs - ): - super(EventCategoryCollection, self).__init__(**kwargs) - self.value = kwargs['value'] - - -class EventData(msrest.serialization.Model): - """The Azure event log entries are of type EventData. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar authorization: The sender authorization information. - :vartype authorization: ~$(python-base-namespace).v2015_04_01.models.SenderAuthorization - :ivar claims: key value pairs to identify ARM permissions. - :vartype claims: dict[str, str] - :ivar caller: the email address of the user who has performed the operation, the UPN claim or - SPN claim based on availability. - :vartype caller: str - :ivar description: the description of the event. - :vartype description: str - :ivar id: the Id of this event as required by ARM for RBAC. It contains the EventDataID and a - timestamp information. - :vartype id: str - :ivar event_data_id: the event data Id. This is a unique identifier for an event. - :vartype event_data_id: str - :ivar correlation_id: the correlation Id, usually a GUID in the string format. The correlation - Id is shared among the events that belong to the same uber operation. - :vartype correlation_id: str - :ivar event_name: the event name. This value should not be confused with OperationName. For - practical purposes, OperationName might be more appealing to end users. - :vartype event_name: ~$(python-base-namespace).v2015_04_01.models.LocalizableString - :ivar category: the event category. - :vartype category: ~$(python-base-namespace).v2015_04_01.models.LocalizableString - :ivar http_request: the HTTP request info. Usually includes the 'clientRequestId', - 'clientIpAddress' (IP address of the user who initiated the event) and 'method' (HTTP method - e.g. PUT). - :vartype http_request: ~$(python-base-namespace).v2015_04_01.models.HttpRequestInfo - :ivar level: the event level. Possible values include: "Critical", "Error", "Warning", - "Informational", "Verbose". - :vartype level: str or ~$(python-base-namespace).v2015_04_01.models.EventLevel - :ivar resource_group_name: the resource group name of the impacted resource. - :vartype resource_group_name: str - :ivar resource_provider_name: the resource provider name of the impacted resource. - :vartype resource_provider_name: ~$(python-base-namespace).v2015_04_01.models.LocalizableString - :ivar resource_id: the resource uri that uniquely identifies the resource that caused this - event. - :vartype resource_id: str - :ivar resource_type: the resource type. - :vartype resource_type: ~$(python-base-namespace).v2015_04_01.models.LocalizableString - :ivar operation_id: It is usually a GUID shared among the events corresponding to single - operation. This value should not be confused with EventName. - :vartype operation_id: str - :ivar operation_name: the operation name. - :vartype operation_name: ~$(python-base-namespace).v2015_04_01.models.LocalizableString - :ivar properties: the set of pairs (usually a Dictionary) that - includes details about the event. - :vartype properties: dict[str, str] - :ivar status: a string describing the status of the operation. Some typical values are: - Started, In progress, Succeeded, Failed, Resolved. - :vartype status: ~$(python-base-namespace).v2015_04_01.models.LocalizableString - :ivar sub_status: the event sub status. Most of the time, when included, this captures the HTTP - status code of the REST call. Common values are: OK (HTTP Status Code: 200), Created (HTTP - Status Code: 201), Accepted (HTTP Status Code: 202), No Content (HTTP Status Code: 204), Bad - Request(HTTP Status Code: 400), Not Found (HTTP Status Code: 404), Conflict (HTTP Status Code: - 409), Internal Server Error (HTTP Status Code: 500), Service Unavailable (HTTP Status - Code:503), Gateway Timeout (HTTP Status Code: 504). - :vartype sub_status: ~$(python-base-namespace).v2015_04_01.models.LocalizableString - :ivar event_timestamp: the timestamp of when the event was generated by the Azure service - processing the request corresponding the event. It in ISO 8601 format. - :vartype event_timestamp: ~datetime.datetime - :ivar submission_timestamp: the timestamp of when the event became available for querying via - this API. It is in ISO 8601 format. This value should not be confused eventTimestamp. As there - might be a delay between the occurrence time of the event, and the time that the event is - submitted to the Azure logging infrastructure. - :vartype submission_timestamp: ~datetime.datetime - :ivar subscription_id: the Azure subscription Id usually a GUID. - :vartype subscription_id: str - :ivar tenant_id: the Azure tenant Id. - :vartype tenant_id: str - """ - - _validation = { - 'authorization': {'readonly': True}, - 'claims': {'readonly': True}, - 'caller': {'readonly': True}, - 'description': {'readonly': True}, - 'id': {'readonly': True}, - 'event_data_id': {'readonly': True}, - 'correlation_id': {'readonly': True}, - 'event_name': {'readonly': True}, - 'category': {'readonly': True}, - 'http_request': {'readonly': True}, - 'level': {'readonly': True}, - 'resource_group_name': {'readonly': True}, - 'resource_provider_name': {'readonly': True}, - 'resource_id': {'readonly': True}, - 'resource_type': {'readonly': True}, - 'operation_id': {'readonly': True}, - 'operation_name': {'readonly': True}, - 'properties': {'readonly': True}, - 'status': {'readonly': True}, - 'sub_status': {'readonly': True}, - 'event_timestamp': {'readonly': True}, - 'submission_timestamp': {'readonly': True}, - 'subscription_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - } - - _attribute_map = { - 'authorization': {'key': 'authorization', 'type': 'SenderAuthorization'}, - 'claims': {'key': 'claims', 'type': '{str}'}, - 'caller': {'key': 'caller', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'event_data_id': {'key': 'eventDataId', 'type': 'str'}, - 'correlation_id': {'key': 'correlationId', 'type': 'str'}, - 'event_name': {'key': 'eventName', 'type': 'LocalizableString'}, - 'category': {'key': 'category', 'type': 'LocalizableString'}, - 'http_request': {'key': 'httpRequest', 'type': 'HttpRequestInfo'}, - 'level': {'key': 'level', 'type': 'str'}, - 'resource_group_name': {'key': 'resourceGroupName', 'type': 'str'}, - 'resource_provider_name': {'key': 'resourceProviderName', 'type': 'LocalizableString'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'LocalizableString'}, - 'operation_id': {'key': 'operationId', 'type': 'str'}, - 'operation_name': {'key': 'operationName', 'type': 'LocalizableString'}, - 'properties': {'key': 'properties', 'type': '{str}'}, - 'status': {'key': 'status', 'type': 'LocalizableString'}, - 'sub_status': {'key': 'subStatus', 'type': 'LocalizableString'}, - 'event_timestamp': {'key': 'eventTimestamp', 'type': 'iso-8601'}, - 'submission_timestamp': {'key': 'submissionTimestamp', 'type': 'iso-8601'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EventData, self).__init__(**kwargs) - self.authorization = None - self.claims = None - self.caller = None - self.description = None - self.id = None - self.event_data_id = None - self.correlation_id = None - self.event_name = None - self.category = None - self.http_request = None - self.level = None - self.resource_group_name = None - self.resource_provider_name = None - self.resource_id = None - self.resource_type = None - self.operation_id = None - self.operation_name = None - self.properties = None - self.status = None - self.sub_status = None - self.event_timestamp = None - self.submission_timestamp = None - self.subscription_id = None - self.tenant_id = None - - -class EventDataCollection(msrest.serialization.Model): - """Represents collection of events. - - 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 - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[EventData]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EventDataCollection, self).__init__(**kwargs) - self.value = kwargs['value'] - self.next_link = kwargs.get('next_link', None) - - -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 - """ - - _attribute_map = { - 'client_request_id': {'key': 'clientRequestId', 'type': 'str'}, - 'client_ip_address': {'key': 'clientIpAddress', 'type': 'str'}, - 'method': {'key': 'method', 'type': 'str'}, - 'uri': {'key': 'uri', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - 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) - self.method = kwargs.get('method', None) - self.uri = kwargs.get('uri', None) - - -class LocalizableString(msrest.serialization.Model): - """The localizable string class. - - 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 - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LocalizableString, self).__init__(**kwargs) - self.value = kwargs['value'] - self.localized_value = kwargs.get('localized_value', None) - - -class RuleCondition(msrest.serialization.Model): - """The condition that results in the alert rule being activated. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: LocationThresholdRuleCondition, ManagementEventRuleCondition, ThresholdRuleCondition. - - 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: - 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 - """ - - _validation = { - 'odata_type': {'required': True}, - } - - _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'data_source': {'key': 'dataSource', 'type': 'RuleDataSource'}, - } - - _subtype_map = { - 'odata_type': {'Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition': 'LocationThresholdRuleCondition', 'Microsoft.Azure.Management.Insights.Models.ManagementEventRuleCondition': 'ManagementEventRuleCondition', 'Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition': 'ThresholdRuleCondition'} - } - - def __init__( - self, - **kwargs - ): - super(RuleCondition, self).__init__(**kwargs) - self.odata_type = None # type: Optional[str] - self.data_source = kwargs.get('data_source', None) - - -class LocationThresholdRuleCondition(RuleCondition): - """A rule condition based on a certain number of locations failing. - - 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: - 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 - 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 - alert. - :type failed_location_count: int - """ - - _validation = { - 'odata_type': {'required': True}, - 'failed_location_count': {'required': True, 'minimum': 0}, - } - - _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'data_source': {'key': 'dataSource', 'type': 'RuleDataSource'}, - 'window_size': {'key': 'windowSize', 'type': 'duration'}, - 'failed_location_count': {'key': 'failedLocationCount', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(LocationThresholdRuleCondition, self).__init__(**kwargs) - self.odata_type = 'Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition' # type: str - self.window_size = kwargs.get('window_size', None) - self.failed_location_count = kwargs['failed_location_count'] - - -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", - "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 - alert activity based on the threshold. If specified then it must be between 5 minutes and 1 - day. - :type window_size: ~datetime.timedelta - """ - - _attribute_map = { - 'operator': {'key': 'operator', 'type': 'str'}, - 'threshold': {'key': 'threshold', 'type': 'float'}, - 'window_size': {'key': 'windowSize', 'type': 'duration'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagementEventAggregationCondition, self).__init__(**kwargs) - self.operator = kwargs.get('operator', None) - self.threshold = kwargs.get('threshold', None) - self.window_size = kwargs.get('window_size', None) - - -class ManagementEventRuleCondition(RuleCondition): - """A management event rule condition. - - 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: - 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 - 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: - ~$(python-base-namespace).v2015_04_01.models.ManagementEventAggregationCondition - """ - - _validation = { - 'odata_type': {'required': True}, - } - - _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'data_source': {'key': 'dataSource', 'type': 'RuleDataSource'}, - 'aggregation': {'key': 'aggregation', 'type': 'ManagementEventAggregationCondition'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagementEventRuleCondition, self).__init__(**kwargs) - self.odata_type = 'Microsoft.Azure.Management.Insights.Models.ManagementEventRuleCondition' # type: str - self.aggregation = kwargs.get('aggregation', None) - - -class MetricTrigger(msrest.serialization.Model): - """The trigger that results in a scaling action. - - 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 - 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 - 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 - 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 - 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 - 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: - [{"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 - """ - - _validation = { - 'metric_name': {'required': True}, - 'metric_resource_uri': {'required': True}, - 'time_grain': {'required': True}, - 'statistic': {'required': True}, - 'time_window': {'required': True}, - 'time_aggregation': {'required': True}, - 'operator': {'required': True}, - 'threshold': {'required': True}, - } - - _attribute_map = { - 'metric_name': {'key': 'metricName', 'type': 'str'}, - 'metric_namespace': {'key': 'metricNamespace', 'type': 'str'}, - 'metric_resource_uri': {'key': 'metricResourceUri', 'type': 'str'}, - 'metric_resource_location': {'key': 'metricResourceLocation', 'type': 'str'}, - 'time_grain': {'key': 'timeGrain', 'type': 'duration'}, - 'statistic': {'key': 'statistic', 'type': 'str'}, - 'time_window': {'key': 'timeWindow', 'type': 'duration'}, - 'time_aggregation': {'key': 'timeAggregation', 'type': 'str'}, - 'operator': {'key': 'operator', 'type': 'str'}, - 'threshold': {'key': 'threshold', 'type': 'float'}, - 'dimensions': {'key': 'dimensions', 'type': '[ScaleRuleMetricDimension]'}, - 'divide_per_instance': {'key': 'dividePerInstance', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricTrigger, self).__init__(**kwargs) - self.metric_name = kwargs['metric_name'] - self.metric_namespace = kwargs.get('metric_namespace', None) - self.metric_resource_uri = kwargs['metric_resource_uri'] - self.metric_resource_location = kwargs.get('metric_resource_location', None) - self.time_grain = kwargs['time_grain'] - self.statistic = kwargs['statistic'] - self.time_window = kwargs['time_window'] - self.time_aggregation = kwargs['time_aggregation'] - self.operator = kwargs['operator'] - self.threshold = kwargs['threshold'] - self.dimensions = kwargs.get('dimensions', None) - self.divide_per_instance = kwargs.get('divide_per_instance', None) - - -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 - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display = kwargs.get('display', None) - - -class OperationDisplay(msrest.serialization.Model): - """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 - """ - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = kwargs.get('provider', None) - self.resource = kwargs.get('resource', None) - self.operation = kwargs.get('operation', None) - - -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 - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class Recurrence(msrest.serialization.Model): - """The repeating times at which this profile begins. This element is not used if the FixedDate element is used. - - 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 - 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 - """ - - _validation = { - 'frequency': {'required': True}, - 'schedule': {'required': True}, - } - - _attribute_map = { - 'frequency': {'key': 'frequency', 'type': 'str'}, - 'schedule': {'key': 'schedule', 'type': 'RecurrentSchedule'}, - } - - def __init__( - self, - **kwargs - ): - super(Recurrence, self).__init__(**kwargs) - self.frequency = kwargs['frequency'] - self.schedule = kwargs['schedule'] - - -class RecurrentSchedule(msrest.serialization.Model): - """The scheduling constraints for when the profile begins. - - 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 - 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. - :type time_zone: str - :param 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] - """ - - _validation = { - 'time_zone': {'required': True}, - 'days': {'required': True}, - 'hours': {'required': True}, - 'minutes': {'required': True}, - } - - _attribute_map = { - 'time_zone': {'key': 'timeZone', 'type': 'str'}, - 'days': {'key': 'days', 'type': '[str]'}, - 'hours': {'key': 'hours', 'type': '[int]'}, - 'minutes': {'key': 'minutes', 'type': '[int]'}, - } - - def __init__( - self, - **kwargs - ): - super(RecurrentSchedule, self).__init__(**kwargs) - self.time_zone = kwargs['time_zone'] - self.days = kwargs['days'] - self.hours = kwargs['hours'] - self.minutes = kwargs['minutes'] - - -class RuleAction(msrest.serialization.Model): - """The action that is performed when the alert rule becomes active, and when an alert condition is resolved. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: RuleEmailAction, RuleWebhookAction. - - 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: - RuleEmailAction and RuleWebhookAction.Constant filled by server. - :type odata_type: str - """ - - _validation = { - 'odata_type': {'required': True}, - } - - _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - } - - _subtype_map = { - 'odata_type': {'Microsoft.Azure.Management.Insights.Models.RuleEmailAction': 'RuleEmailAction', 'Microsoft.Azure.Management.Insights.Models.RuleWebhookAction': 'RuleWebhookAction'} - } - - def __init__( - self, - **kwargs - ): - super(RuleAction, self).__init__(**kwargs) - self.odata_type = None # type: Optional[str] - - -class RuleDataSource(msrest.serialization.Model): - """The resource from which the rule collects its data. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: RuleManagementEventDataSource, RuleMetricDataSource. - - 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. - **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 - """ - - _validation = { - 'odata_type': {'required': True}, - } - - _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'resource_uri': {'key': 'resourceUri', 'type': 'str'}, - 'legacy_resource_id': {'key': 'legacyResourceId', 'type': 'str'}, - 'resource_location': {'key': 'resourceLocation', 'type': 'str'}, - 'metric_namespace': {'key': 'metricNamespace', 'type': 'str'}, - } - - _subtype_map = { - 'odata_type': {'Microsoft.Azure.Management.Insights.Models.RuleManagementEventDataSource': 'RuleManagementEventDataSource', 'Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource': 'RuleMetricDataSource'} - } - - def __init__( - self, - **kwargs - ): - super(RuleDataSource, self).__init__(**kwargs) - self.odata_type = None # type: Optional[str] - self.resource_uri = kwargs.get('resource_uri', None) - self.legacy_resource_id = kwargs.get('legacy_resource_id', None) - self.resource_location = kwargs.get('resource_location', None) - self.metric_namespace = kwargs.get('metric_namespace', None) - - -class RuleEmailAction(RuleAction): - """Specifies the action to send email when the rule condition is evaluated. The discriminator is always RuleEmailAction in this case. - - 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: - 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 - activation of the alert. - :type custom_emails: list[str] - """ - - _validation = { - 'odata_type': {'required': True}, - } - - _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'send_to_service_owners': {'key': 'sendToServiceOwners', 'type': 'bool'}, - 'custom_emails': {'key': 'customEmails', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - 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) - self.custom_emails = kwargs.get('custom_emails', None) - - -class RuleManagementEventClaimsDataSource(msrest.serialization.Model): - """The claims for a rule management event data source. - - :param email_address: the email address. - :type email_address: str - """ - - _attribute_map = { - 'email_address': {'key': 'emailAddress', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RuleManagementEventClaimsDataSource, self).__init__(**kwargs) - self.email_address = kwargs.get('email_address', None) - - -class RuleManagementEventDataSource(RuleDataSource): - """A rule management event data source. The discriminator fields is always RuleManagementEventDataSource in this case. - - 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. - **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 - 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 - """ - - _validation = { - 'odata_type': {'required': True}, - } - - _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'resource_uri': {'key': 'resourceUri', 'type': 'str'}, - 'legacy_resource_id': {'key': 'legacyResourceId', 'type': 'str'}, - 'resource_location': {'key': 'resourceLocation', 'type': 'str'}, - 'metric_namespace': {'key': 'metricNamespace', 'type': 'str'}, - 'event_name': {'key': 'eventName', 'type': 'str'}, - 'event_source': {'key': 'eventSource', 'type': 'str'}, - 'level': {'key': 'level', 'type': 'str'}, - 'operation_name': {'key': 'operationName', 'type': 'str'}, - 'resource_group_name': {'key': 'resourceGroupName', 'type': 'str'}, - 'resource_provider_name': {'key': 'resourceProviderName', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'sub_status': {'key': 'subStatus', 'type': 'str'}, - 'claims': {'key': 'claims', 'type': 'RuleManagementEventClaimsDataSource'}, - } - - def __init__( - self, - **kwargs - ): - super(RuleManagementEventDataSource, self).__init__(**kwargs) - self.odata_type = 'Microsoft.Azure.Management.Insights.Models.RuleManagementEventDataSource' # type: str - self.event_name = kwargs.get('event_name', None) - self.event_source = kwargs.get('event_source', None) - self.level = kwargs.get('level', None) - self.operation_name = kwargs.get('operation_name', None) - self.resource_group_name = kwargs.get('resource_group_name', None) - self.resource_provider_name = kwargs.get('resource_provider_name', None) - self.status = kwargs.get('status', None) - self.sub_status = kwargs.get('sub_status', None) - self.claims = kwargs.get('claims', None) - - -class RuleMetricDataSource(RuleDataSource): - """A rule metric data source. The discriminator value is always RuleMetricDataSource in this case. - - 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. - **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 - """ - - _validation = { - 'odata_type': {'required': True}, - } - - _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'resource_uri': {'key': 'resourceUri', 'type': 'str'}, - 'legacy_resource_id': {'key': 'legacyResourceId', 'type': 'str'}, - 'resource_location': {'key': 'resourceLocation', 'type': 'str'}, - 'metric_namespace': {'key': 'metricNamespace', 'type': 'str'}, - 'metric_name': {'key': 'metricName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RuleMetricDataSource, self).__init__(**kwargs) - self.odata_type = 'Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource' # type: str - self.metric_name = kwargs.get('metric_name', None) - - -class RuleWebhookAction(RuleAction): - """Specifies the action to post to service when the rule condition is evaluated. The discriminator is always RuleWebhookAction in this case. - - 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: - 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 - 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] - """ - - _validation = { - 'odata_type': {'required': True}, - } - - _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'service_uri': {'key': 'serviceUri', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(RuleWebhookAction, self).__init__(**kwargs) - self.odata_type = 'Microsoft.Azure.Management.Insights.Models.RuleWebhookAction' # type: str - self.service_uri = kwargs.get('service_uri', None) - self.properties = kwargs.get('properties', None) - - -class ScaleAction(msrest.serialization.Model): - """The parameters for the scaling action. - - All required parameters must be populated in order to send to Azure. - - :param 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 - 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 - 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 - action occurs. It must be between 1 week and 1 minute in ISO 8601 format. - :type cooldown: ~datetime.timedelta - """ - - _validation = { - 'direction': {'required': True}, - 'type': {'required': True}, - 'cooldown': {'required': True}, - } - - _attribute_map = { - 'direction': {'key': 'direction', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'cooldown': {'key': 'cooldown', 'type': 'duration'}, - } - - def __init__( - self, - **kwargs - ): - super(ScaleAction, self).__init__(**kwargs) - self.direction = kwargs['direction'] - self.type = kwargs['type'] - self.value = kwargs.get('value', "1") - self.cooldown = kwargs['cooldown'] - - -class ScaleCapacity(msrest.serialization.Model): - """The number of instances that can be used during this profile. - - 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 - 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 - for evaluation. The default is only used if the current instance count is lower than the - default. - :type default: str - """ - - _validation = { - 'minimum': {'required': True}, - 'maximum': {'required': True}, - 'default': {'required': True}, - } - - _attribute_map = { - 'minimum': {'key': 'minimum', 'type': 'str'}, - 'maximum': {'key': 'maximum', 'type': 'str'}, - 'default': {'key': 'default', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ScaleCapacity, self).__init__(**kwargs) - self.minimum = kwargs['minimum'] - self.maximum = kwargs['maximum'] - self.default = kwargs['default'] - - -class ScaleRule(msrest.serialization.Model): - """A rule that provide the triggers and parameters for the scaling action. - - 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 - """ - - _validation = { - 'metric_trigger': {'required': True}, - 'scale_action': {'required': True}, - } - - _attribute_map = { - 'metric_trigger': {'key': 'metricTrigger', 'type': 'MetricTrigger'}, - 'scale_action': {'key': 'scaleAction', 'type': 'ScaleAction'}, - } - - def __init__( - self, - **kwargs - ): - super(ScaleRule, self).__init__(**kwargs) - self.metric_trigger = kwargs['metric_trigger'] - self.scale_action = kwargs['scale_action'] - - -class ScaleRuleMetricDimension(msrest.serialization.Model): - """Specifies an auto scale rule metric dimension. - - 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. - '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 - ~$(python-base-namespace).v2015_04_01.models.ScaleRuleMetricDimensionOperationType - :param values: Required. list of dimension values. For example: ["App1","App2"]. - :type values: list[str] - """ - - _validation = { - 'dimension_name': {'required': True}, - 'operator': {'required': True}, - 'values': {'required': True}, - } - - _attribute_map = { - 'dimension_name': {'key': 'DimensionName', 'type': 'str'}, - 'operator': {'key': 'Operator', 'type': 'str'}, - 'values': {'key': 'Values', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(ScaleRuleMetricDimension, self).__init__(**kwargs) - self.dimension_name = kwargs['dimension_name'] - self.operator = kwargs['operator'] - self.values = kwargs['values'] - - -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 - """ - - _attribute_map = { - 'action': {'key': 'action', 'type': 'str'}, - 'role': {'key': 'role', 'type': 'str'}, - 'scope': {'key': 'scope', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SenderAuthorization, self).__init__(**kwargs) - self.action = kwargs.get('action', None) - self.role = kwargs.get('role', None) - self.scope = kwargs.get('scope', None) - - -class ThresholdRuleCondition(RuleCondition): - """A rule condition based on a metric crossing a threshold. - - 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: - 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 - 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 - 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 - 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 - ~$(python-base-namespace).v2015_04_01.models.TimeAggregationOperator - """ - - _validation = { - 'odata_type': {'required': True}, - 'operator': {'required': True}, - 'threshold': {'required': True}, - } - - _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'data_source': {'key': 'dataSource', 'type': 'RuleDataSource'}, - 'operator': {'key': 'operator', 'type': 'str'}, - 'threshold': {'key': 'threshold', 'type': 'float'}, - 'window_size': {'key': 'windowSize', 'type': 'duration'}, - 'time_aggregation': {'key': 'timeAggregation', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ThresholdRuleCondition, self).__init__(**kwargs) - self.odata_type = 'Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition' # type: str - self.operator = kwargs['operator'] - self.threshold = kwargs['threshold'] - self.window_size = kwargs.get('window_size', None) - self.time_aggregation = kwargs.get('time_aggregation', None) - - -class TimeWindow(msrest.serialization.Model): - """A specific date-time for the profile. - - 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 - 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. - :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 - """ - - _validation = { - 'start': {'required': True}, - 'end': {'required': True}, - } - - _attribute_map = { - 'time_zone': {'key': 'timeZone', 'type': 'str'}, - 'start': {'key': 'start', 'type': 'iso-8601'}, - 'end': {'key': 'end', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(TimeWindow, self).__init__(**kwargs) - self.time_zone = kwargs.get('time_zone', None) - self.start = kwargs['start'] - self.end = kwargs['end'] - - -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] - """ - - _attribute_map = { - 'service_uri': {'key': 'serviceUri', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - 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 621d5431777a..56559fa4174d 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 37b2db1f18f4..9b8ef5463b88 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 e83da6d5d60a..d84be1161790 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,23 +5,62 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + *, + filter: str, + select: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + 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 + ) class ActivityLogsOperations(object): """ActivityLogsOperations operations. @@ -45,13 +84,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - filter, # type: str - select=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.EventDataCollection"] + filter: str, + select: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.EventDataCollection"]: """Provides the list of records from the activity logs. :param filter: Reduces the set of data collected.:code:`
`This argument is required and it @@ -79,7 +118,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 +127,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 +166,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 b9931cb2c2b9..1a2dc61a2fa4 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,23 +5,248 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_or_update_request( + resource_group_name: str, + rule_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + rule_name: str, + subscription_id: str, + **kwargs: Any +) -> 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: str, + rule_name: str, + subscription_id: str, + **kwargs: Any +) -> 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: str, + resource_group_name: str, + rule_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> 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: str, + **kwargs: Any +) -> 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 + ) class AlertRulesOperations(object): """AlertRulesOperations operations. @@ -45,17 +270,17 @@ 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 - rule_name, # type: str - parameters, # type: "_models.AlertRuleResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.AlertRuleResource" + resource_group_name: str, + rule_name: str, + parameters: "_models.AlertRuleResource", + **kwargs: Any + ) -> "_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 +296,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] + + _json = self._serialize.body(parameters, 'AlertRuleResource') - # 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, + 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,18 +330,20 @@ 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 - rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + rule_name: str, + **kwargs: Any + ) -> 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 +357,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,16 +381,17 @@ 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 - rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AlertRuleResource" + resource_group_name: str, + rule_name: str, + **kwargs: Any + ) -> "_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 +405,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,20 +430,22 @@ 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 - rule_name, # type: str - alert_rules_resource, # type: "_models.AlertRuleResourcePatch" - **kwargs # type: Any - ): - # type: (...) -> "_models.AlertRuleResource" + resource_group_name: str, + rule_name: str, + alert_rules_resource: "_models.AlertRuleResourcePatch", + **kwargs: Any + ) -> "_models.AlertRuleResource": """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 +461,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,21 +495,25 @@ 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 - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AlertRuleResourceCollection"] + resource_group_name: str, + **kwargs: Any + ) -> 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 +521,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,27 +558,30 @@ 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 - ): - # type: (...) -> Iterable["_models.AlertRuleResourceCollection"] + **kwargs: Any + ) -> Iterable["_models.AlertRuleResourceCollection"]: """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 +589,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 +624,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 ffd1174490a1..eefbcb61faac 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,23 +5,248 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> 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: str, + autoscale_setting_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + autoscale_setting_name: str, + subscription_id: str, + **kwargs: Any +) -> 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: str, + autoscale_setting_name: str, + subscription_id: str, + **kwargs: Any +) -> 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: str, + resource_group_name: str, + autoscale_setting_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> 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 + ) class AutoscaleSettingsOperations(object): """AutoscaleSettingsOperations operations. @@ -45,19 +270,21 @@ 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 - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AutoscaleSettingResourceCollection"] + resource_group_name: str, + **kwargs: Any + ) -> 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 +292,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,28 +329,29 @@ 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 - autoscale_setting_name, # type: str - parameters, # type: "_models.AutoscaleSettingResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.AutoscaleSettingResource" + resource_group_name: str, + autoscale_setting_name: str, + parameters: "_models.AutoscaleSettingResource", + **kwargs: Any + ) -> "_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 +367,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] - # 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, 'AutoscaleSettingResource') + + 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,18 +401,20 @@ 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 - autoscale_setting_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + autoscale_setting_name: str, + **kwargs: Any + ) -> 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 +428,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,16 +452,17 @@ 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 - autoscale_setting_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AutoscaleSettingResource" + resource_group_name: str, + autoscale_setting_name: str, + **kwargs: Any + ) -> "_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 +476,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,25 +501,28 @@ 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 - autoscale_setting_name, # type: str - autoscale_setting_resource, # type: "_models.AutoscaleSettingResourcePatch" - **kwargs # type: Any - ): - # type: (...) -> "_models.AutoscaleSettingResource" + resource_group_name: str, + autoscale_setting_name: str, + autoscale_setting_resource: "_models.AutoscaleSettingResourcePatch", + **kwargs: Any + ) -> "_models.AutoscaleSettingResource": """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 +533,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,18 +563,22 @@ 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 - ): - # type: (...) -> Iterable["_models.AutoscaleSettingResourceCollection"] + **kwargs: Any + ) -> Iterable["_models.AutoscaleSettingResourceCollection"]: """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 +586,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 +621,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 c5d271a71e2c..2a56b97cd36d 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,23 +5,50 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = "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 + ) class EventCategoriesOperations(object): """EventCategoriesOperations operations. @@ -45,18 +72,20 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.EventCategoryCollection"] + **kwargs: Any + ) -> Iterable["_models.EventCategoryCollection"]: """Get the list of available event categories supported in the Activity Logs Service.:code:`
`The current list includes the following: Administrative, Security, 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 +93,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 +126,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 d57820bb6d71..becc93fb69e6 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,22 +5,49 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = "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 + ) class Operations(object): """Operations operations. @@ -44,11 +71,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> "_models.OperationListResult" + **kwargs: Any + ) -> "_models.OperationListResult": """Lists all of the available operations from Microsoft.Insights provider. :keyword callable cls: A custom type or function that will be passed the direct response @@ -61,21 +88,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') + + request = build_list_request( + template_url=self.list.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 @@ -89,4 +109,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 91d274582a84..7d141717dc2a 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,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. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + *, + filter: Optional[str] = None, + select: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + 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 + ) class TenantActivityLogsOperations(object): """TenantActivityLogsOperations operations. @@ -45,13 +79,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - filter=None, # type: Optional[str] - select=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.EventDataCollection"] + filter: Optional[str] = None, + select: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.EventDataCollection"]: """Gets the Activity Logs for the Tenant.:code:`
`Everything that is applicable to the API to get the Activity Logs for the subscription is applicable to this API (the parameters, $filter, etc.).:code:`
`One thing to point out here is that this API does *not* retrieve the logs at @@ -84,7 +118,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 +127,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 +164,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 d82479510092..ec9090a57df0 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 224f0bceaf6e..e1f58c99be3f 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 @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class MonitorManagementClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(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 +64,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/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 01811c9b22b5..d78934a87679 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 2f4d172e5c2a..3e6ca5d03b38 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,30 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import 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 - -class MonitorManagementClient(object): +class MonitorManagementClient: """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 +38,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] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + 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: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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 000000000000..74e48ecd07cf --- /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 000000000000..138f663c53a4 --- /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 cac9f5d10f8b..e5754a47ce68 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 96ce9b45c05b..4eba911f1c6e 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 a1b513c610d4..34bea0f7b202 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 dc53aa1b361b..022345195cee 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 000000000000..74e48ecd07cf --- /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 cd9b17b873eb..ab9addf70917 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 121d8fa7a388..77529014142a 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 969fd85250f8..53bc049c9ba6 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 12badcc3e8df..314d1cc68768 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/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/__init__.py index 751752c69a4b..04b1680c0010 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/__init__.py @@ -6,78 +6,42 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import AlertRuleResource - from ._models_py3 import AlertRuleResourceCollection - from ._models_py3 import AlertRuleResourcePatch - from ._models_py3 import DimensionProperties - from ._models_py3 import ErrorContract - from ._models_py3 import ErrorResponse - from ._models_py3 import LocalizableString - from ._models_py3 import LocationThresholdRuleCondition - from ._models_py3 import LogSettings - from ._models_py3 import LogSpecification - from ._models_py3 import ManagementEventAggregationCondition - from ._models_py3 import ManagementEventRuleCondition - from ._models_py3 import MetricAvailability - from ._models_py3 import MetricAvailabilityLocation - from ._models_py3 import MetricDefinition - from ._models_py3 import MetricDefinitionCollection - from ._models_py3 import MetricSettings - from ._models_py3 import MetricSpecification - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationListResult - from ._models_py3 import Resource - from ._models_py3 import RetentionPolicy - from ._models_py3 import RuleAction - from ._models_py3 import RuleCondition - from ._models_py3 import RuleDataSource - from ._models_py3 import RuleEmailAction - from ._models_py3 import RuleManagementEventClaimsDataSource - from ._models_py3 import RuleManagementEventDataSource - from ._models_py3 import RuleMetricDataSource - from ._models_py3 import RuleWebhookAction - from ._models_py3 import ServiceDiagnosticSettingsResource - from ._models_py3 import ServiceSpecification - from ._models_py3 import TableInfoEntry - from ._models_py3 import ThresholdRuleCondition -except (SyntaxError, ImportError): - from ._models import AlertRuleResource # type: ignore - from ._models import AlertRuleResourceCollection # type: ignore - from ._models import AlertRuleResourcePatch # type: ignore - from ._models import DimensionProperties # type: ignore - from ._models import ErrorContract # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import LocalizableString # type: ignore - from ._models import LocationThresholdRuleCondition # type: ignore - from ._models import LogSettings # type: ignore - from ._models import LogSpecification # type: ignore - from ._models import ManagementEventAggregationCondition # type: ignore - from ._models import ManagementEventRuleCondition # type: ignore - from ._models import MetricAvailability # type: ignore - from ._models import MetricAvailabilityLocation # type: ignore - from ._models import MetricDefinition # type: ignore - from ._models import MetricDefinitionCollection # type: ignore - from ._models import MetricSettings # type: ignore - from ._models import MetricSpecification # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationListResult # type: ignore - from ._models import Resource # type: ignore - from ._models import RetentionPolicy # type: ignore - from ._models import RuleAction # type: ignore - from ._models import RuleCondition # type: ignore - from ._models import RuleDataSource # type: ignore - from ._models import RuleEmailAction # type: ignore - from ._models import RuleManagementEventClaimsDataSource # type: ignore - from ._models import RuleManagementEventDataSource # type: ignore - from ._models import RuleMetricDataSource # type: ignore - from ._models import RuleWebhookAction # type: ignore - from ._models import ServiceDiagnosticSettingsResource # type: ignore - from ._models import ServiceSpecification # type: ignore - from ._models import TableInfoEntry # type: ignore - from ._models import ThresholdRuleCondition # type: ignore +from ._models_py3 import AlertRuleResource +from ._models_py3 import AlertRuleResourceCollection +from ._models_py3 import AlertRuleResourcePatch +from ._models_py3 import DimensionProperties +from ._models_py3 import ErrorContract +from ._models_py3 import ErrorResponse +from ._models_py3 import LocalizableString +from ._models_py3 import LocationThresholdRuleCondition +from ._models_py3 import LogSettings +from ._models_py3 import LogSpecification +from ._models_py3 import ManagementEventAggregationCondition +from ._models_py3 import ManagementEventRuleCondition +from ._models_py3 import MetricAvailability +from ._models_py3 import MetricAvailabilityLocation +from ._models_py3 import MetricDefinition +from ._models_py3 import MetricDefinitionCollection +from ._models_py3 import MetricSettings +from ._models_py3 import MetricSpecification +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationListResult +from ._models_py3 import Resource +from ._models_py3 import RetentionPolicy +from ._models_py3 import RuleAction +from ._models_py3 import RuleCondition +from ._models_py3 import RuleDataSource +from ._models_py3 import RuleEmailAction +from ._models_py3 import RuleManagementEventClaimsDataSource +from ._models_py3 import RuleManagementEventDataSource +from ._models_py3 import RuleMetricDataSource +from ._models_py3 import RuleWebhookAction +from ._models_py3 import ServiceDiagnosticSettingsResource +from ._models_py3 import ServiceSpecification +from ._models_py3 import TableInfoEntry +from ._models_py3 import ThresholdRuleCondition + from ._monitor_management_client_enums import ( AggregationType, 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 deleted file mode 100644 index 6381ac0370dc..000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/_models.py +++ /dev/null @@ -1,1395 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class Resource(msrest.serialization.Model): - """An azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :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] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - - -class AlertRuleResource(Resource): - """The alert rule resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :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 - 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 - when an alert condition is resolved. - :type 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 - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'name_properties_name': {'required': True}, - 'is_enabled': {'required': True}, - 'condition': {'required': True}, - 'last_updated_time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'name_properties_name': {'key': 'properties.name', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'is_enabled': {'key': 'properties.isEnabled', 'type': 'bool'}, - 'condition': {'key': 'properties.condition', 'type': 'RuleCondition'}, - 'action': {'key': 'properties.action', 'type': 'RuleAction'}, - 'actions': {'key': 'properties.actions', 'type': '[RuleAction]'}, - 'last_updated_time': {'key': 'properties.lastUpdatedTime', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(AlertRuleResource, self).__init__(**kwargs) - self.name_properties_name = kwargs['name_properties_name'] - self.description = kwargs.get('description', None) - self.provisioning_state = kwargs.get('provisioning_state', None) - self.is_enabled = kwargs['is_enabled'] - self.condition = kwargs['condition'] - self.action = kwargs.get('action', None) - self.actions = kwargs.get('actions', None) - self.last_updated_time = None - - -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] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[AlertRuleResource]'}, - } - - def __init__( - self, - **kwargs - ): - super(AlertRuleResourceCollection, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class AlertRuleResourcePatch(msrest.serialization.Model): - """The alert rule object for patch operations. - - 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 - 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 - when an alert condition is resolved. - :type 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 - """ - - _validation = { - 'last_updated_time': {'readonly': True}, - } - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'name': {'key': 'properties.name', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'is_enabled': {'key': 'properties.isEnabled', 'type': 'bool'}, - 'condition': {'key': 'properties.condition', 'type': 'RuleCondition'}, - 'action': {'key': 'properties.action', 'type': 'RuleAction'}, - 'actions': {'key': 'properties.actions', 'type': '[RuleAction]'}, - 'last_updated_time': {'key': 'properties.lastUpdatedTime', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(AlertRuleResourcePatch, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.name = kwargs.get('name', None) - self.description = kwargs.get('description', None) - self.provisioning_state = kwargs.get('provisioning_state', None) - self.is_enabled = kwargs.get('is_enabled', None) - self.condition = kwargs.get('condition', None) - self.action = kwargs.get('action', None) - self.actions = kwargs.get('actions', None) - self.last_updated_time = None - - -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 - the defaultDimensionValues field below. - :type is_hidden: bool - :param default_dimension_values: Default dimension value to be sent down for the hidden - dimension during query. - :type default_dimension_values: any - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'to_be_exported_for_shoebox': {'key': 'toBeExportedForShoebox', 'type': 'bool'}, - 'is_hidden': {'key': 'isHidden', 'type': 'bool'}, - 'default_dimension_values': {'key': 'defaultDimensionValues', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(DimensionProperties, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display_name = kwargs.get('display_name', None) - self.to_be_exported_for_shoebox = kwargs.get('to_be_exported_for_shoebox', None) - self.is_hidden = kwargs.get('is_hidden', None) - self.default_dimension_values = kwargs.get('default_dimension_values', None) - - -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 - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponse'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorContract, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -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 - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - - -class LocalizableString(msrest.serialization.Model): - """The localizable string class. - - 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 - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LocalizableString, self).__init__(**kwargs) - self.value = kwargs['value'] - self.localized_value = kwargs.get('localized_value', None) - - -class RuleCondition(msrest.serialization.Model): - """The condition that results in the alert rule being activated. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: LocationThresholdRuleCondition, ManagementEventRuleCondition, ThresholdRuleCondition. - - 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: - 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 - """ - - _validation = { - 'odata_type': {'required': True}, - } - - _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'data_source': {'key': 'dataSource', 'type': 'RuleDataSource'}, - } - - _subtype_map = { - 'odata_type': {'Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition': 'LocationThresholdRuleCondition', 'Microsoft.Azure.Management.Insights.Models.ManagementEventRuleCondition': 'ManagementEventRuleCondition', 'Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition': 'ThresholdRuleCondition'} - } - - def __init__( - self, - **kwargs - ): - super(RuleCondition, self).__init__(**kwargs) - self.odata_type = None # type: Optional[str] - self.data_source = kwargs.get('data_source', None) - - -class LocationThresholdRuleCondition(RuleCondition): - """A rule condition based on a certain number of locations failing. - - 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: - 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 - 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 - alert. - :type failed_location_count: int - """ - - _validation = { - 'odata_type': {'required': True}, - 'failed_location_count': {'required': True, 'minimum': 0}, - } - - _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'data_source': {'key': 'dataSource', 'type': 'RuleDataSource'}, - 'window_size': {'key': 'windowSize', 'type': 'duration'}, - 'failed_location_count': {'key': 'failedLocationCount', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(LocationThresholdRuleCondition, self).__init__(**kwargs) - self.odata_type = 'Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition' # type: str - self.window_size = kwargs.get('window_size', None) - self.failed_location_count = kwargs['failed_location_count'] - - -class LogSettings(msrest.serialization.Model): - """Part of MultiTenantDiagnosticSettings. Specifies the settings for a particular log. - - 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 - 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 - """ - - _validation = { - 'enabled': {'required': True}, - } - - _attribute_map = { - 'category': {'key': 'category', 'type': 'str'}, - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'retention_policy': {'key': 'retentionPolicy', 'type': 'RetentionPolicy'}, - } - - def __init__( - self, - **kwargs - ): - super(LogSettings, self).__init__(**kwargs) - self.category = kwargs.get('category', None) - self.enabled = kwargs['enabled'] - self.retention_policy = kwargs.get('retention_policy', None) - - -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 - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'blob_duration': {'key': 'blobDuration', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LogSpecification, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display_name = kwargs.get('display_name', None) - self.blob_duration = kwargs.get('blob_duration', None) - - -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", - "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 - alert activity based on the threshold. If specified then it must be between 5 minutes and 1 - day. - :type window_size: ~datetime.timedelta - """ - - _attribute_map = { - 'operator': {'key': 'operator', 'type': 'str'}, - 'threshold': {'key': 'threshold', 'type': 'float'}, - 'window_size': {'key': 'windowSize', 'type': 'duration'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagementEventAggregationCondition, self).__init__(**kwargs) - self.operator = kwargs.get('operator', None) - self.threshold = kwargs.get('threshold', None) - self.window_size = kwargs.get('window_size', None) - - -class ManagementEventRuleCondition(RuleCondition): - """A management event rule condition. - - 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: - 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 - 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: - ~$(python-base-namespace).v2015_07_01.models.ManagementEventAggregationCondition - """ - - _validation = { - 'odata_type': {'required': True}, - } - - _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'data_source': {'key': 'dataSource', 'type': 'RuleDataSource'}, - 'aggregation': {'key': 'aggregation', 'type': 'ManagementEventAggregationCondition'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagementEventRuleCondition, self).__init__(**kwargs) - self.odata_type = 'Microsoft.Azure.Management.Insights.Models.ManagementEventRuleCondition' # type: str - self.aggregation = kwargs.get('aggregation', None) - - -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 - 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 - 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 - """ - - _attribute_map = { - 'time_grain': {'key': 'timeGrain', 'type': 'duration'}, - 'retention': {'key': 'retention', 'type': 'duration'}, - 'location': {'key': 'location', 'type': 'MetricAvailabilityLocation'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricAvailability, self).__init__(**kwargs) - self.time_grain = kwargs.get('time_grain', None) - self.retention = kwargs.get('retention', None) - self.location = kwargs.get('location', None) - - -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 - """ - - _attribute_map = { - 'table_endpoint': {'key': 'tableEndpoint', 'type': 'str'}, - 'table_info': {'key': 'tableInfo', 'type': '[TableInfoEntry]'}, - 'partition_key': {'key': 'partitionKey', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricAvailabilityLocation, self).__init__(**kwargs) - self.table_endpoint = kwargs.get('table_endpoint', None) - self.table_info = kwargs.get('table_info', None) - self.partition_key = kwargs.get('partition_key', None) - - -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", - "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 - values for display. Possible values include: "None", "Average", "Count", "Minimum", "Maximum", - "Total". - :type 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 - metric. - :type 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 - queried. - :type metric_availabilities: - list[~$(python-base-namespace).v2015_07_01.models.MetricAvailability] - :param id: the resource identifier of the metric definition. - :type id: str - """ - - _attribute_map = { - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'resource_uri': {'key': 'resourceUri', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'LocalizableString'}, - 'category': {'key': 'category', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'primary_aggregation_type': {'key': 'primaryAggregationType', 'type': 'str'}, - 'supported_aggregation_types': {'key': 'supportedAggregationTypes', 'type': '[str]'}, - 'metric_availabilities': {'key': 'metricAvailabilities', 'type': '[MetricAvailability]'}, - 'id': {'key': 'id', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricDefinition, self).__init__(**kwargs) - self.resource_id = kwargs.get('resource_id', None) - self.resource_uri = kwargs.get('resource_uri', None) - self.name = kwargs.get('name', None) - self.category = kwargs.get('category', None) - self.unit = kwargs.get('unit', None) - self.start_time = kwargs.get('start_time', None) - self.end_time = kwargs.get('end_time', None) - self.primary_aggregation_type = kwargs.get('primary_aggregation_type', None) - self.supported_aggregation_types = kwargs.get('supported_aggregation_types', None) - self.metric_availabilities = kwargs.get('metric_availabilities', None) - self.id = kwargs.get('id', None) - - -class MetricDefinitionCollection(msrest.serialization.Model): - """Represents collection of metric definitions. - - 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] - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[MetricDefinition]'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricDefinitionCollection, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.value = kwargs['value'] - - -class MetricSettings(msrest.serialization.Model): - """Part of MultiTenantDiagnosticSettings. Specifies the settings for a particular metric. - - 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 - """ - - _validation = { - 'time_grain': {'required': True}, - 'enabled': {'required': True}, - } - - _attribute_map = { - 'time_grain': {'key': 'timeGrain', 'type': 'duration'}, - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'retention_policy': {'key': 'retentionPolicy', 'type': 'RetentionPolicy'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricSettings, self).__init__(**kwargs) - self.time_grain = kwargs['time_grain'] - self.enabled = kwargs['enabled'] - self.retention_policy = kwargs.get('retention_policy', None) - - -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: - 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: - 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 - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, - 'supported_aggregation_types': {'key': 'supportedAggregationTypes', 'type': '[str]'}, - 'supported_time_grain_types': {'key': 'supportedTimeGrainTypes', 'type': '[str]'}, - 'availabilities': {'key': 'availabilities', 'type': '[str]'}, - 'lock_aggregation_type': {'key': 'lockAggregationType', 'type': 'str'}, - 'category': {'key': 'category', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[DimensionProperties]'}, - 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'bool'}, - 'internal_metric_name': {'key': 'internalMetricName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricSpecification, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display_name = kwargs.get('display_name', None) - self.display_description = kwargs.get('display_description', None) - self.unit = kwargs.get('unit', None) - self.aggregation_type = kwargs.get('aggregation_type', None) - self.supported_aggregation_types = kwargs.get('supported_aggregation_types', None) - self.supported_time_grain_types = kwargs.get('supported_time_grain_types', None) - self.availabilities = kwargs.get('availabilities', None) - self.lock_aggregation_type = kwargs.get('lock_aggregation_type', None) - self.category = kwargs.get('category', None) - self.dimensions = kwargs.get('dimensions', None) - self.fill_gap_with_zero = kwargs.get('fill_gap_with_zero', None) - self.internal_metric_name = kwargs.get('internal_metric_name', None) - - -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 - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'service_specification': {'key': 'properties.serviceSpecification', 'type': 'ServiceSpecification'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.is_data_action = kwargs.get('is_data_action', None) - self.display = kwargs.get('display', None) - self.service_specification = kwargs.get('service_specification', None) - - -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 - """ - - _attribute_map = { - 'publisher': {'key': 'publisher', 'type': 'str'}, - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationDisplay, self).__init__(**kwargs) - self.publisher = kwargs.get('publisher', None) - self.provider = kwargs.get('provider', None) - self.resource = kwargs.get('resource', None) - self.operation = kwargs.get('operation', None) - self.description = kwargs.get('description', None) - - -class 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 - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class RetentionPolicy(msrest.serialization.Model): - """Specifies the retention policy for the log. - - 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 - the events indefinitely. - :type days: int - """ - - _validation = { - 'enabled': {'required': True}, - 'days': {'required': True}, - } - - _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'days': {'key': 'days', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(RetentionPolicy, self).__init__(**kwargs) - self.enabled = kwargs['enabled'] - self.days = kwargs['days'] - - -class RuleAction(msrest.serialization.Model): - """The action that is performed when the alert rule becomes active, and when an alert condition is resolved. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: RuleEmailAction, RuleWebhookAction. - - 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: - RuleEmailAction and RuleWebhookAction.Constant filled by server. - :type odata_type: str - """ - - _validation = { - 'odata_type': {'required': True}, - } - - _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - } - - _subtype_map = { - 'odata_type': {'Microsoft.Azure.Management.Insights.Models.RuleEmailAction': 'RuleEmailAction', 'Microsoft.Azure.Management.Insights.Models.RuleWebhookAction': 'RuleWebhookAction'} - } - - def __init__( - self, - **kwargs - ): - super(RuleAction, self).__init__(**kwargs) - self.odata_type = None # type: Optional[str] - - -class RuleDataSource(msrest.serialization.Model): - """The resource from which the rule collects its data. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: RuleManagementEventDataSource, RuleMetricDataSource. - - 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. - **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 - """ - - _validation = { - 'odata_type': {'required': True}, - } - - _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'resource_uri': {'key': 'resourceUri', 'type': 'str'}, - 'legacy_resource_id': {'key': 'legacyResourceId', 'type': 'str'}, - 'resource_location': {'key': 'resourceLocation', 'type': 'str'}, - 'metric_namespace': {'key': 'metricNamespace', 'type': 'str'}, - } - - _subtype_map = { - 'odata_type': {'Microsoft.Azure.Management.Insights.Models.RuleManagementEventDataSource': 'RuleManagementEventDataSource', 'Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource': 'RuleMetricDataSource'} - } - - def __init__( - self, - **kwargs - ): - super(RuleDataSource, self).__init__(**kwargs) - self.odata_type = None # type: Optional[str] - self.resource_uri = kwargs.get('resource_uri', None) - self.legacy_resource_id = kwargs.get('legacy_resource_id', None) - self.resource_location = kwargs.get('resource_location', None) - self.metric_namespace = kwargs.get('metric_namespace', None) - - -class RuleEmailAction(RuleAction): - """Specifies the action to send email when the rule condition is evaluated. The discriminator is always RuleEmailAction in this case. - - 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: - 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 - activation of the alert. - :type custom_emails: list[str] - """ - - _validation = { - 'odata_type': {'required': True}, - } - - _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'send_to_service_owners': {'key': 'sendToServiceOwners', 'type': 'bool'}, - 'custom_emails': {'key': 'customEmails', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - 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) - self.custom_emails = kwargs.get('custom_emails', None) - - -class RuleManagementEventClaimsDataSource(msrest.serialization.Model): - """The claims for a rule management event data source. - - :param email_address: the email address. - :type email_address: str - """ - - _attribute_map = { - 'email_address': {'key': 'emailAddress', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RuleManagementEventClaimsDataSource, self).__init__(**kwargs) - self.email_address = kwargs.get('email_address', None) - - -class RuleManagementEventDataSource(RuleDataSource): - """A rule management event data source. The discriminator fields is always RuleManagementEventDataSource in this case. - - 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. - **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 - 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 - """ - - _validation = { - 'odata_type': {'required': True}, - } - - _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'resource_uri': {'key': 'resourceUri', 'type': 'str'}, - 'legacy_resource_id': {'key': 'legacyResourceId', 'type': 'str'}, - 'resource_location': {'key': 'resourceLocation', 'type': 'str'}, - 'metric_namespace': {'key': 'metricNamespace', 'type': 'str'}, - 'event_name': {'key': 'eventName', 'type': 'str'}, - 'event_source': {'key': 'eventSource', 'type': 'str'}, - 'level': {'key': 'level', 'type': 'str'}, - 'operation_name': {'key': 'operationName', 'type': 'str'}, - 'resource_group_name': {'key': 'resourceGroupName', 'type': 'str'}, - 'resource_provider_name': {'key': 'resourceProviderName', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'sub_status': {'key': 'subStatus', 'type': 'str'}, - 'claims': {'key': 'claims', 'type': 'RuleManagementEventClaimsDataSource'}, - } - - def __init__( - self, - **kwargs - ): - super(RuleManagementEventDataSource, self).__init__(**kwargs) - self.odata_type = 'Microsoft.Azure.Management.Insights.Models.RuleManagementEventDataSource' # type: str - self.event_name = kwargs.get('event_name', None) - self.event_source = kwargs.get('event_source', None) - self.level = kwargs.get('level', None) - self.operation_name = kwargs.get('operation_name', None) - self.resource_group_name = kwargs.get('resource_group_name', None) - self.resource_provider_name = kwargs.get('resource_provider_name', None) - self.status = kwargs.get('status', None) - self.sub_status = kwargs.get('sub_status', None) - self.claims = kwargs.get('claims', None) - - -class RuleMetricDataSource(RuleDataSource): - """A rule metric data source. The discriminator value is always RuleMetricDataSource in this case. - - 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. - **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 - """ - - _validation = { - 'odata_type': {'required': True}, - } - - _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'resource_uri': {'key': 'resourceUri', 'type': 'str'}, - 'legacy_resource_id': {'key': 'legacyResourceId', 'type': 'str'}, - 'resource_location': {'key': 'resourceLocation', 'type': 'str'}, - 'metric_namespace': {'key': 'metricNamespace', 'type': 'str'}, - 'metric_name': {'key': 'metricName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RuleMetricDataSource, self).__init__(**kwargs) - self.odata_type = 'Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource' # type: str - self.metric_name = kwargs.get('metric_name', None) - - -class RuleWebhookAction(RuleAction): - """Specifies the action to post to service when the rule condition is evaluated. The discriminator is always RuleWebhookAction in this case. - - 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: - 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 - 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] - """ - - _validation = { - 'odata_type': {'required': True}, - } - - _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'service_uri': {'key': 'serviceUri', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(RuleWebhookAction, self).__init__(**kwargs) - self.odata_type = 'Microsoft.Azure.Management.Insights.Models.RuleWebhookAction' # type: str - self.service_uri = kwargs.get('service_uri', None) - self.properties = kwargs.get('properties', None) - - -class ServiceDiagnosticSettingsResource(Resource): - """Description of a service diagnostic setting. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :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 - 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 - 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 - 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 - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'storage_account_id': {'key': 'properties.storageAccountId', 'type': 'str'}, - 'service_bus_rule_id': {'key': 'properties.serviceBusRuleId', 'type': 'str'}, - 'metrics': {'key': 'properties.metrics', 'type': '[MetricSettings]'}, - 'logs': {'key': 'properties.logs', 'type': '[LogSettings]'}, - 'workspace_id': {'key': 'properties.workspaceId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - 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) - self.metrics = kwargs.get('metrics', None) - self.logs = kwargs.get('logs', None) - self.workspace_id = kwargs.get('workspace_id', None) - - -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: - list[~$(python-base-namespace).v2015_07_01.models.MetricSpecification] - :param legacy_metric_specifications: Legacy Metric specifications for operation. Deprecated, do - not use. - :type legacy_metric_specifications: any - """ - - _attribute_map = { - 'log_specifications': {'key': 'logSpecifications', 'type': '[LogSpecification]'}, - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecification]'}, - 'legacy_metric_specifications': {'key': 'legacyMetricSpecifications', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(ServiceSpecification, self).__init__(**kwargs) - self.log_specifications = kwargs.get('log_specifications', None) - self.metric_specifications = kwargs.get('metric_specifications', None) - self.legacy_metric_specifications = kwargs.get('legacy_metric_specifications', None) - - -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 - """ - - _attribute_map = { - 'table_name': {'key': 'tableName', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'sas_token': {'key': 'sasToken', 'type': 'str'}, - 'sas_token_expiration_time': {'key': 'sasTokenExpirationTime', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(TableInfoEntry, self).__init__(**kwargs) - self.table_name = kwargs.get('table_name', None) - self.start_time = kwargs.get('start_time', None) - self.end_time = kwargs.get('end_time', None) - self.sas_token = kwargs.get('sas_token', None) - self.sas_token_expiration_time = kwargs.get('sas_token_expiration_time', None) - - -class ThresholdRuleCondition(RuleCondition): - """A rule condition based on a metric crossing a threshold. - - 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: - 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 - 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 - 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 - 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 - ~$(python-base-namespace).v2015_07_01.models.TimeAggregationOperator - """ - - _validation = { - 'odata_type': {'required': True}, - 'operator': {'required': True}, - 'threshold': {'required': True}, - } - - _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'data_source': {'key': 'dataSource', 'type': 'RuleDataSource'}, - 'operator': {'key': 'operator', 'type': 'str'}, - 'threshold': {'key': 'threshold', 'type': 'float'}, - 'window_size': {'key': 'windowSize', 'type': 'duration'}, - 'time_aggregation': {'key': 'timeAggregation', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ThresholdRuleCondition, self).__init__(**kwargs) - self.odata_type = 'Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition' # type: str - self.operator = kwargs['operator'] - self.threshold = kwargs['threshold'] - self.window_size = kwargs.get('window_size', None) - self.time_aggregation = kwargs.get('time_aggregation', None) 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 5b0966ae5496..fd3490a9af69 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 c2b5066b1b06..1404ed3e3916 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 bfbed600aa58..c342da7320f6 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,23 +5,248 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_or_update_request( + resource_group_name: str, + rule_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + rule_name: str, + subscription_id: str, + **kwargs: Any +) -> 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: str, + rule_name: str, + subscription_id: str, + **kwargs: Any +) -> 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: str, + resource_group_name: str, + rule_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> 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: str, + **kwargs: Any +) -> 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 + ) class AlertRulesOperations(object): """AlertRulesOperations operations. @@ -45,17 +270,17 @@ 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 - rule_name, # type: str - parameters, # type: "_models.AlertRuleResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.AlertRuleResource" + resource_group_name: str, + rule_name: str, + parameters: "_models.AlertRuleResource", + **kwargs: Any + ) -> "_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 +296,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] + + _json = self._serialize.body(parameters, 'AlertRuleResource') - # 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, + 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,18 +330,20 @@ 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 - rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + rule_name: str, + **kwargs: Any + ) -> 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 +357,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,16 +381,17 @@ 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 - rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AlertRuleResource" + resource_group_name: str, + rule_name: str, + **kwargs: Any + ) -> "_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 +405,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,20 +430,22 @@ 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 - rule_name, # type: str - alert_rules_resource, # type: "_models.AlertRuleResourcePatch" - **kwargs # type: Any - ): - # type: (...) -> "_models.AlertRuleResource" + resource_group_name: str, + rule_name: str, + alert_rules_resource: "_models.AlertRuleResourcePatch", + **kwargs: Any + ) -> "_models.AlertRuleResource": """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 +461,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,21 +495,25 @@ 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 - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AlertRuleResourceCollection"] + resource_group_name: str, + **kwargs: Any + ) -> 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 +521,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,27 +558,30 @@ 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 - ): - # type: (...) -> Iterable["_models.AlertRuleResourceCollection"] + **kwargs: Any + ) -> Iterable["_models.AlertRuleResourceCollection"]: """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 +589,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 +624,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 ebae6587c5bd..7d7162b172aa 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,23 +5,60 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + resource_uri: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + 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 + ) class MetricDefinitionsOperations(object): """MetricDefinitionsOperations operations. @@ -45,13 +82,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_uri, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.MetricDefinitionCollection"] + resource_uri: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.MetricDefinitionCollection"]: """Lists the metric definitions for the resource. :param resource_uri: The identifier of the resource. @@ -64,8 +101,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 +112,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 +149,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 a6d8bd648b53..40d3bd1ce1b5 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,22 +5,49 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = "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 + ) class Operations(object): """Operations operations. @@ -44,11 +71,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> "_models.OperationListResult" + **kwargs: Any + ) -> "_models.OperationListResult": """Lists all of the available operations from Microsoft.Insights provider. :keyword callable cls: A custom type or function that will be passed the direct response @@ -61,27 +88,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') + + request = build_list_request( + template_url=self.list.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.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 +110,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 2dc552790fd6..d7ac22592e1b 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,22 +5,96 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_uri: str, + **kwargs: Any +) -> 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: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) class ServiceDiagnosticSettingsOperations(object): """ServiceDiagnosticSettingsOperations operations. @@ -44,12 +118,12 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_uri, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ServiceDiagnosticSettingsResource" + resource_uri: str, + **kwargs: Any + ) -> "_models.ServiceDiagnosticSettingsResource": """Gets the active diagnostic settings for the specified resource. :param resource_uri: The identifier of the resource. @@ -64,31 +138,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') - # 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) @@ -97,21 +161,24 @@ 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 - parameters, # type: "_models.ServiceDiagnosticSettingsResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.ServiceDiagnosticSettingsResource" + resource_uri: str, + parameters: "_models.ServiceDiagnosticSettingsResource", + **kwargs: Any + ) -> "_models.ServiceDiagnosticSettingsResource": """Create or update new diagnostic settings for the specified resource. :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 +189,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 +216,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 d82479510092..ec9090a57df0 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 282a42dca8c1..3c5148998b74 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 @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class MonitorManagementClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(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 +65,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 358d4351074f..8b98756e8957 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 8f67a079ad20..9c79236030cb 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,87 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import 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 - -class MonitorManagementClient(object): +class MonitorManagementClient: """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] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + 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: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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 000000000000..74e48ecd07cf --- /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 000000000000..138f663c53a4 --- /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 cac9f5d10f8b..e5754a47ce68 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 96ce9b45c05b..4eba911f1c6e 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 4fb94b055a2b..71d775201fb9 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 ab351d603d92..acb5d7873254 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 000000000000..74e48ecd07cf --- /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 958a1b2b8603..898e4940c3f2 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 a62a6ec67216..5e191eff2dc5 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 5c218a864c22..6247251a07ec 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 12bbcf4c9cc1..f198e2f4c7b6 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/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/__init__.py index e000ddda2034..2b9edd288653 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/__init__.py @@ -6,62 +6,34 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import AlertRuleResource - from ._models_py3 import AlertRuleResourceCollection - from ._models_py3 import AlertRuleResourcePatch - from ._models_py3 import ErrorResponse - from ._models_py3 import Incident - from ._models_py3 import IncidentListResult - from ._models_py3 import LocalizableString - from ._models_py3 import LocationThresholdRuleCondition - from ._models_py3 import LogProfileCollection - from ._models_py3 import LogProfileResource - from ._models_py3 import LogProfileResourcePatch - from ._models_py3 import ManagementEventAggregationCondition - from ._models_py3 import ManagementEventRuleCondition - from ._models_py3 import MetricAvailability - from ._models_py3 import MetricDefinition - from ._models_py3 import MetricDefinitionCollection - from ._models_py3 import Resource - from ._models_py3 import RetentionPolicy - from ._models_py3 import RuleAction - from ._models_py3 import RuleCondition - from ._models_py3 import RuleDataSource - from ._models_py3 import RuleEmailAction - from ._models_py3 import RuleManagementEventClaimsDataSource - from ._models_py3 import RuleManagementEventDataSource - from ._models_py3 import RuleMetricDataSource - from ._models_py3 import RuleWebhookAction - from ._models_py3 import ThresholdRuleCondition -except (SyntaxError, ImportError): - from ._models import AlertRuleResource # type: ignore - from ._models import AlertRuleResourceCollection # type: ignore - from ._models import AlertRuleResourcePatch # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import Incident # type: ignore - from ._models import IncidentListResult # type: ignore - from ._models import LocalizableString # type: ignore - from ._models import LocationThresholdRuleCondition # type: ignore - from ._models import LogProfileCollection # type: ignore - from ._models import LogProfileResource # type: ignore - from ._models import LogProfileResourcePatch # type: ignore - from ._models import ManagementEventAggregationCondition # type: ignore - from ._models import ManagementEventRuleCondition # type: ignore - from ._models import MetricAvailability # type: ignore - from ._models import MetricDefinition # type: ignore - from ._models import MetricDefinitionCollection # type: ignore - from ._models import Resource # type: ignore - from ._models import RetentionPolicy # type: ignore - from ._models import RuleAction # type: ignore - from ._models import RuleCondition # type: ignore - from ._models import RuleDataSource # type: ignore - from ._models import RuleEmailAction # type: ignore - from ._models import RuleManagementEventClaimsDataSource # type: ignore - from ._models import RuleManagementEventDataSource # type: ignore - from ._models import RuleMetricDataSource # type: ignore - from ._models import RuleWebhookAction # type: ignore - from ._models import ThresholdRuleCondition # type: ignore +from ._models_py3 import AlertRuleResource +from ._models_py3 import AlertRuleResourceCollection +from ._models_py3 import AlertRuleResourcePatch +from ._models_py3 import ErrorResponse +from ._models_py3 import Incident +from ._models_py3 import IncidentListResult +from ._models_py3 import LocalizableString +from ._models_py3 import LocationThresholdRuleCondition +from ._models_py3 import LogProfileCollection +from ._models_py3 import LogProfileResource +from ._models_py3 import LogProfileResourcePatch +from ._models_py3 import ManagementEventAggregationCondition +from ._models_py3 import ManagementEventRuleCondition +from ._models_py3 import MetricAvailability +from ._models_py3 import MetricDefinition +from ._models_py3 import MetricDefinitionCollection +from ._models_py3 import Resource +from ._models_py3 import RetentionPolicy +from ._models_py3 import RuleAction +from ._models_py3 import RuleCondition +from ._models_py3 import RuleDataSource +from ._models_py3 import RuleEmailAction +from ._models_py3 import RuleManagementEventClaimsDataSource +from ._models_py3 import RuleManagementEventDataSource +from ._models_py3 import RuleMetricDataSource +from ._models_py3 import RuleWebhookAction +from ._models_py3 import ThresholdRuleCondition + from ._monitor_management_client_enums import ( AggregationType, 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 deleted file mode 100644 index d737ca3227e1..000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/_models.py +++ /dev/null @@ -1,1101 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class Resource(msrest.serialization.Model): - """An azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :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] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - - -class AlertRuleResource(Resource): - """The alert rule resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :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 - 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 - when an alert condition is resolved. - :type 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 - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'name_properties_name': {'required': True}, - 'is_enabled': {'required': True}, - 'condition': {'required': True}, - 'last_updated_time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'name_properties_name': {'key': 'properties.name', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'is_enabled': {'key': 'properties.isEnabled', 'type': 'bool'}, - 'condition': {'key': 'properties.condition', 'type': 'RuleCondition'}, - 'action': {'key': 'properties.action', 'type': 'RuleAction'}, - 'actions': {'key': 'properties.actions', 'type': '[RuleAction]'}, - 'last_updated_time': {'key': 'properties.lastUpdatedTime', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(AlertRuleResource, self).__init__(**kwargs) - self.name_properties_name = kwargs['name_properties_name'] - self.description = kwargs.get('description', None) - self.provisioning_state = kwargs.get('provisioning_state', None) - self.is_enabled = kwargs['is_enabled'] - self.condition = kwargs['condition'] - self.action = kwargs.get('action', None) - self.actions = kwargs.get('actions', None) - self.last_updated_time = None - - -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] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[AlertRuleResource]'}, - } - - def __init__( - self, - **kwargs - ): - super(AlertRuleResourceCollection, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class AlertRuleResourcePatch(msrest.serialization.Model): - """The alert rule object for patch operations. - - 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 - 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 - when an alert condition is resolved. - :type 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 - """ - - _validation = { - 'last_updated_time': {'readonly': True}, - } - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'name': {'key': 'properties.name', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'is_enabled': {'key': 'properties.isEnabled', 'type': 'bool'}, - 'condition': {'key': 'properties.condition', 'type': 'RuleCondition'}, - 'action': {'key': 'properties.action', 'type': 'RuleAction'}, - 'actions': {'key': 'properties.actions', 'type': '[RuleAction]'}, - 'last_updated_time': {'key': 'properties.lastUpdatedTime', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(AlertRuleResourcePatch, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.name = kwargs.get('name', None) - self.description = kwargs.get('description', None) - self.provisioning_state = kwargs.get('provisioning_state', None) - self.is_enabled = kwargs.get('is_enabled', None) - self.condition = kwargs.get('condition', None) - self.action = kwargs.get('action', None) - self.actions = kwargs.get('actions', None) - self.last_updated_time = None - - -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 - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - - -class Incident(msrest.serialization.Model): - """An alert incident indicates the activation status of an alert rule. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Incident name. - :vartype name: str - :ivar rule_name: Rule name that is associated with the incident. - :vartype rule_name: str - :ivar is_active: A boolean to indicate whether the incident is active or resolved. - :vartype is_active: bool - :ivar activated_time: The time at which the incident was activated in ISO8601 format. - :vartype activated_time: ~datetime.datetime - :ivar resolved_time: The time at which the incident was resolved in ISO8601 format. If null, it - means the incident is still active. - :vartype resolved_time: ~datetime.datetime - """ - - _validation = { - 'name': {'readonly': True}, - 'rule_name': {'readonly': True}, - 'is_active': {'readonly': True}, - 'activated_time': {'readonly': True}, - 'resolved_time': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'rule_name': {'key': 'ruleName', 'type': 'str'}, - 'is_active': {'key': 'isActive', 'type': 'bool'}, - 'activated_time': {'key': 'activatedTime', 'type': 'iso-8601'}, - 'resolved_time': {'key': 'resolvedTime', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(Incident, self).__init__(**kwargs) - self.name = None - self.rule_name = None - self.is_active = None - self.activated_time = None - self.resolved_time = None - - -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] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Incident]'}, - } - - def __init__( - self, - **kwargs - ): - super(IncidentListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class LocalizableString(msrest.serialization.Model): - """The localizable string class. - - 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 - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LocalizableString, self).__init__(**kwargs) - self.value = kwargs['value'] - self.localized_value = kwargs.get('localized_value', None) - - -class RuleCondition(msrest.serialization.Model): - """The condition that results in the alert rule being activated. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: LocationThresholdRuleCondition, ManagementEventRuleCondition, ThresholdRuleCondition. - - 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: - 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 - """ - - _validation = { - 'odata_type': {'required': True}, - } - - _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'data_source': {'key': 'dataSource', 'type': 'RuleDataSource'}, - } - - _subtype_map = { - 'odata_type': {'Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition': 'LocationThresholdRuleCondition', 'Microsoft.Azure.Management.Insights.Models.ManagementEventRuleCondition': 'ManagementEventRuleCondition', 'Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition': 'ThresholdRuleCondition'} - } - - def __init__( - self, - **kwargs - ): - super(RuleCondition, self).__init__(**kwargs) - self.odata_type = None # type: Optional[str] - self.data_source = kwargs.get('data_source', None) - - -class LocationThresholdRuleCondition(RuleCondition): - """A rule condition based on a certain number of locations failing. - - 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: - 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 - 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 - alert. - :type failed_location_count: int - """ - - _validation = { - 'odata_type': {'required': True}, - 'failed_location_count': {'required': True, 'minimum': 0}, - } - - _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'data_source': {'key': 'dataSource', 'type': 'RuleDataSource'}, - 'window_size': {'key': 'windowSize', 'type': 'duration'}, - 'failed_location_count': {'key': 'failedLocationCount', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(LocationThresholdRuleCondition, self).__init__(**kwargs) - self.odata_type = 'Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition' # type: str - self.window_size = kwargs.get('window_size', None) - self.failed_location_count = kwargs['failed_location_count'] - - -class LogProfileCollection(msrest.serialization.Model): - """Represents a collection of log profiles. - - 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] - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[LogProfileResource]'}, - } - - def __init__( - self, - **kwargs - ): - super(LogProfileCollection, self).__init__(**kwargs) - self.value = kwargs['value'] - - -class LogProfileResource(Resource): - """The log profile resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :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 - 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 - 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 - 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 - 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 - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'locations': {'required': True}, - 'categories': {'required': True}, - 'retention_policy': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'storage_account_id': {'key': 'properties.storageAccountId', 'type': 'str'}, - 'service_bus_rule_id': {'key': 'properties.serviceBusRuleId', 'type': 'str'}, - 'locations': {'key': 'properties.locations', 'type': '[str]'}, - 'categories': {'key': 'properties.categories', 'type': '[str]'}, - 'retention_policy': {'key': 'properties.retentionPolicy', 'type': 'RetentionPolicy'}, - } - - def __init__( - self, - **kwargs - ): - 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) - self.locations = kwargs['locations'] - self.categories = kwargs['categories'] - self.retention_policy = kwargs['retention_policy'] - - -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 - 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 - 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 - 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 - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'storage_account_id': {'key': 'properties.storageAccountId', 'type': 'str'}, - 'service_bus_rule_id': {'key': 'properties.serviceBusRuleId', 'type': 'str'}, - 'locations': {'key': 'properties.locations', 'type': '[str]'}, - 'categories': {'key': 'properties.categories', 'type': '[str]'}, - 'retention_policy': {'key': 'properties.retentionPolicy', 'type': 'RetentionPolicy'}, - } - - def __init__( - self, - **kwargs - ): - super(LogProfileResourcePatch, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.storage_account_id = kwargs.get('storage_account_id', None) - self.service_bus_rule_id = kwargs.get('service_bus_rule_id', None) - self.locations = kwargs.get('locations', None) - self.categories = kwargs.get('categories', None) - self.retention_policy = kwargs.get('retention_policy', None) - - -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", - "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 - alert activity based on the threshold. If specified then it must be between 5 minutes and 1 - day. - :type window_size: ~datetime.timedelta - """ - - _attribute_map = { - 'operator': {'key': 'operator', 'type': 'str'}, - 'threshold': {'key': 'threshold', 'type': 'float'}, - 'window_size': {'key': 'windowSize', 'type': 'duration'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagementEventAggregationCondition, self).__init__(**kwargs) - self.operator = kwargs.get('operator', None) - self.threshold = kwargs.get('threshold', None) - self.window_size = kwargs.get('window_size', None) - - -class ManagementEventRuleCondition(RuleCondition): - """A management event rule condition. - - 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: - 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 - 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: - ~$(python-base-namespace).v2016_03_01.models.ManagementEventAggregationCondition - """ - - _validation = { - 'odata_type': {'required': True}, - } - - _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'data_source': {'key': 'dataSource', 'type': 'RuleDataSource'}, - 'aggregation': {'key': 'aggregation', 'type': 'ManagementEventAggregationCondition'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagementEventRuleCondition, self).__init__(**kwargs) - self.odata_type = 'Microsoft.Azure.Management.Insights.Models.ManagementEventRuleCondition' # type: str - self.aggregation = kwargs.get('aggregation', None) - - -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 - 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 - a duration 'PT1M', 'P1D', etc. - :type retention: ~datetime.timedelta - """ - - _attribute_map = { - 'time_grain': {'key': 'timeGrain', 'type': 'duration'}, - 'retention': {'key': 'retention', 'type': 'duration'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricAvailability, self).__init__(**kwargs) - self.time_grain = kwargs.get('time_grain', None) - self.retention = kwargs.get('retention', None) - - -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", - "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 - values for display. Possible values include: "None", "Average", "Count", "Minimum", "Maximum", - "Total". - :type 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 - queried. - :type metric_availabilities: - list[~$(python-base-namespace).v2016_03_01.models.MetricAvailability] - :param id: the resource identifier of the metric definition. - :type id: str - """ - - _attribute_map = { - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'LocalizableString'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'primary_aggregation_type': {'key': 'primaryAggregationType', 'type': 'str'}, - 'metric_availabilities': {'key': 'metricAvailabilities', 'type': '[MetricAvailability]'}, - 'id': {'key': 'id', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricDefinition, self).__init__(**kwargs) - self.resource_id = kwargs.get('resource_id', None) - self.name = kwargs.get('name', None) - self.unit = kwargs.get('unit', None) - self.primary_aggregation_type = kwargs.get('primary_aggregation_type', None) - self.metric_availabilities = kwargs.get('metric_availabilities', None) - self.id = kwargs.get('id', None) - - -class MetricDefinitionCollection(msrest.serialization.Model): - """Represents collection of metric definitions. - - 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] - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[MetricDefinition]'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricDefinitionCollection, self).__init__(**kwargs) - self.value = kwargs['value'] - - -class RetentionPolicy(msrest.serialization.Model): - """Specifies the retention policy for the log. - - 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 - the events indefinitely. - :type days: int - """ - - _validation = { - 'enabled': {'required': True}, - 'days': {'required': True, 'minimum': 0}, - } - - _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'days': {'key': 'days', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(RetentionPolicy, self).__init__(**kwargs) - self.enabled = kwargs['enabled'] - self.days = kwargs['days'] - - -class RuleAction(msrest.serialization.Model): - """The action that is performed when the alert rule becomes active, and when an alert condition is resolved. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: RuleEmailAction, RuleWebhookAction. - - 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: - RuleEmailAction and RuleWebhookAction.Constant filled by server. - :type odata_type: str - """ - - _validation = { - 'odata_type': {'required': True}, - } - - _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - } - - _subtype_map = { - 'odata_type': {'Microsoft.Azure.Management.Insights.Models.RuleEmailAction': 'RuleEmailAction', 'Microsoft.Azure.Management.Insights.Models.RuleWebhookAction': 'RuleWebhookAction'} - } - - def __init__( - self, - **kwargs - ): - super(RuleAction, self).__init__(**kwargs) - self.odata_type = None # type: Optional[str] - - -class RuleDataSource(msrest.serialization.Model): - """The resource from which the rule collects its data. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: RuleManagementEventDataSource, RuleMetricDataSource. - - 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. - **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 - """ - - _validation = { - 'odata_type': {'required': True}, - } - - _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'resource_uri': {'key': 'resourceUri', 'type': 'str'}, - 'legacy_resource_id': {'key': 'legacyResourceId', 'type': 'str'}, - 'resource_location': {'key': 'resourceLocation', 'type': 'str'}, - 'metric_namespace': {'key': 'metricNamespace', 'type': 'str'}, - } - - _subtype_map = { - 'odata_type': {'Microsoft.Azure.Management.Insights.Models.RuleManagementEventDataSource': 'RuleManagementEventDataSource', 'Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource': 'RuleMetricDataSource'} - } - - def __init__( - self, - **kwargs - ): - super(RuleDataSource, self).__init__(**kwargs) - self.odata_type = None # type: Optional[str] - self.resource_uri = kwargs.get('resource_uri', None) - self.legacy_resource_id = kwargs.get('legacy_resource_id', None) - self.resource_location = kwargs.get('resource_location', None) - self.metric_namespace = kwargs.get('metric_namespace', None) - - -class RuleEmailAction(RuleAction): - """Specifies the action to send email when the rule condition is evaluated. The discriminator is always RuleEmailAction in this case. - - 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: - 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 - activation of the alert. - :type custom_emails: list[str] - """ - - _validation = { - 'odata_type': {'required': True}, - } - - _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'send_to_service_owners': {'key': 'sendToServiceOwners', 'type': 'bool'}, - 'custom_emails': {'key': 'customEmails', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - 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) - self.custom_emails = kwargs.get('custom_emails', None) - - -class RuleManagementEventClaimsDataSource(msrest.serialization.Model): - """The claims for a rule management event data source. - - :param email_address: the email address. - :type email_address: str - """ - - _attribute_map = { - 'email_address': {'key': 'emailAddress', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RuleManagementEventClaimsDataSource, self).__init__(**kwargs) - self.email_address = kwargs.get('email_address', None) - - -class RuleManagementEventDataSource(RuleDataSource): - """A rule management event data source. The discriminator fields is always RuleManagementEventDataSource in this case. - - 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. - **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 - 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 - """ - - _validation = { - 'odata_type': {'required': True}, - } - - _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'resource_uri': {'key': 'resourceUri', 'type': 'str'}, - 'legacy_resource_id': {'key': 'legacyResourceId', 'type': 'str'}, - 'resource_location': {'key': 'resourceLocation', 'type': 'str'}, - 'metric_namespace': {'key': 'metricNamespace', 'type': 'str'}, - 'event_name': {'key': 'eventName', 'type': 'str'}, - 'event_source': {'key': 'eventSource', 'type': 'str'}, - 'level': {'key': 'level', 'type': 'str'}, - 'operation_name': {'key': 'operationName', 'type': 'str'}, - 'resource_group_name': {'key': 'resourceGroupName', 'type': 'str'}, - 'resource_provider_name': {'key': 'resourceProviderName', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'sub_status': {'key': 'subStatus', 'type': 'str'}, - 'claims': {'key': 'claims', 'type': 'RuleManagementEventClaimsDataSource'}, - } - - def __init__( - self, - **kwargs - ): - super(RuleManagementEventDataSource, self).__init__(**kwargs) - self.odata_type = 'Microsoft.Azure.Management.Insights.Models.RuleManagementEventDataSource' # type: str - self.event_name = kwargs.get('event_name', None) - self.event_source = kwargs.get('event_source', None) - self.level = kwargs.get('level', None) - self.operation_name = kwargs.get('operation_name', None) - self.resource_group_name = kwargs.get('resource_group_name', None) - self.resource_provider_name = kwargs.get('resource_provider_name', None) - self.status = kwargs.get('status', None) - self.sub_status = kwargs.get('sub_status', None) - self.claims = kwargs.get('claims', None) - - -class RuleMetricDataSource(RuleDataSource): - """A rule metric data source. The discriminator value is always RuleMetricDataSource in this case. - - 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. - **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 - """ - - _validation = { - 'odata_type': {'required': True}, - } - - _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'resource_uri': {'key': 'resourceUri', 'type': 'str'}, - 'legacy_resource_id': {'key': 'legacyResourceId', 'type': 'str'}, - 'resource_location': {'key': 'resourceLocation', 'type': 'str'}, - 'metric_namespace': {'key': 'metricNamespace', 'type': 'str'}, - 'metric_name': {'key': 'metricName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RuleMetricDataSource, self).__init__(**kwargs) - self.odata_type = 'Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource' # type: str - self.metric_name = kwargs.get('metric_name', None) - - -class RuleWebhookAction(RuleAction): - """Specifies the action to post to service when the rule condition is evaluated. The discriminator is always RuleWebhookAction in this case. - - 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: - 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 - 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] - """ - - _validation = { - 'odata_type': {'required': True}, - } - - _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'service_uri': {'key': 'serviceUri', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(RuleWebhookAction, self).__init__(**kwargs) - self.odata_type = 'Microsoft.Azure.Management.Insights.Models.RuleWebhookAction' # type: str - self.service_uri = kwargs.get('service_uri', None) - self.properties = kwargs.get('properties', None) - - -class ThresholdRuleCondition(RuleCondition): - """A rule condition based on a metric crossing a threshold. - - 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: - 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 - 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 - 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 - 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 - ~$(python-base-namespace).v2016_03_01.models.TimeAggregationOperator - """ - - _validation = { - 'odata_type': {'required': True}, - 'operator': {'required': True}, - 'threshold': {'required': True}, - } - - _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'data_source': {'key': 'dataSource', 'type': 'RuleDataSource'}, - 'operator': {'key': 'operator', 'type': 'str'}, - 'threshold': {'key': 'threshold', 'type': 'float'}, - 'window_size': {'key': 'windowSize', 'type': 'duration'}, - 'time_aggregation': {'key': 'timeAggregation', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ThresholdRuleCondition, self).__init__(**kwargs) - self.odata_type = 'Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition' # type: str - self.operator = kwargs['operator'] - self.threshold = kwargs['threshold'] - self.window_size = kwargs.get('window_size', None) - self.time_aggregation = kwargs.get('time_aggregation', None) 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 f9a35585fc3a..abb472b8f34a 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 42b2bb7d2507..46f418eaac30 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 e852df95c901..cc3a151814d4 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,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. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + rule_name: str, + incident_name: str, + subscription_id: str, + **kwargs: Any +) -> 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: str, + rule_name: str, + subscription_id: str, + **kwargs: Any +) -> 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 + ) class AlertRuleIncidentsOperations(object): """AlertRuleIncidentsOperations operations. @@ -45,17 +119,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - rule_name, # type: str - incident_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Incident" + resource_group_name: str, + rule_name: str, + incident_name: str, + **kwargs: Any + ) -> "_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 +145,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,24 +171,27 @@ 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 - rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IncidentListResult"] + resource_group_name: str, + rule_name: str, + **kwargs: Any + ) -> 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 +199,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 +243,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 82bc82bee3de..49c3be62dbb5 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,23 +5,248 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_or_update_request( + resource_group_name: str, + rule_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + rule_name: str, + subscription_id: str, + **kwargs: Any +) -> 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: str, + rule_name: str, + subscription_id: str, + **kwargs: Any +) -> 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: str, + resource_group_name: str, + rule_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> 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: str, + **kwargs: Any +) -> 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 + ) class AlertRulesOperations(object): """AlertRulesOperations operations. @@ -45,17 +270,17 @@ 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 - rule_name, # type: str - parameters, # type: "_models.AlertRuleResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.AlertRuleResource" + resource_group_name: str, + rule_name: str, + parameters: "_models.AlertRuleResource", + **kwargs: Any + ) -> "_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 +296,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] + + _json = self._serialize.body(parameters, 'AlertRuleResource') - # 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, + 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,18 +330,20 @@ 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 - rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + rule_name: str, + **kwargs: Any + ) -> 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 +357,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,16 +381,17 @@ 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 - rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AlertRuleResource" + resource_group_name: str, + rule_name: str, + **kwargs: Any + ) -> "_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 +405,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,20 +430,22 @@ 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 - rule_name, # type: str - alert_rules_resource, # type: "_models.AlertRuleResourcePatch" - **kwargs # type: Any - ): - # type: (...) -> "_models.AlertRuleResource" + resource_group_name: str, + rule_name: str, + alert_rules_resource: "_models.AlertRuleResourcePatch", + **kwargs: Any + ) -> "_models.AlertRuleResource": """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 +461,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,21 +495,25 @@ 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 - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AlertRuleResourceCollection"] + resource_group_name: str, + **kwargs: Any + ) -> 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 +521,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,27 +558,30 @@ 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 - ): - # type: (...) -> Iterable["_models.AlertRuleResourceCollection"] + **kwargs: Any + ) -> Iterable["_models.AlertRuleResourceCollection"]: """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 +589,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 +624,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 84bedb59ac2c..24b2cb6ff2ae 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,23 +5,201 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_delete_request( + log_profile_name: str, + subscription_id: str, + **kwargs: Any +) -> 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: str, + subscription_id: str, + **kwargs: Any +) -> 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: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + subscription_id: str, + log_profile_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> 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 + ) class LogProfilesOperations(object): """LogProfilesOperations operations. @@ -45,12 +223,12 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def delete( self, - log_profile_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + log_profile_name: str, + **kwargs: Any + ) -> None: """Deletes the log profile. :param log_profile_name: The name of the log profile. @@ -65,24 +243,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,12 +265,13 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}'} # type: ignore + + @distributed_trace def get( self, - log_profile_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.LogProfileResource" + log_profile_name: str, + **kwargs: Any + ) -> "_models.LogProfileResource": """Gets the log profile. :param log_profile_name: The name of the log profile. @@ -115,32 +286,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,15 +310,17 @@ 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 - parameters, # type: "_models.LogProfileResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.LogProfileResource" + log_profile_name: str, + parameters: "_models.LogProfileResource", + **kwargs: Any + ) -> "_models.LogProfileResource": """Create or update a log profile in Azure Monitoring REST API. :param log_profile_name: The name of the log profile. @@ -174,31 +337,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,21 +365,24 @@ 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 - log_profiles_resource, # type: "_models.LogProfileResourcePatch" - **kwargs # type: Any - ): - # type: (...) -> "_models.LogProfileResource" + log_profile_name: str, + log_profiles_resource: "_models.LogProfileResourcePatch", + **kwargs: Any + ) -> "_models.LogProfileResource": """Updates an existing LogProfilesResource. To update other fields use the CreateOrUpdate method. :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 +393,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,18 +422,22 @@ 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 - ): - # type: (...) -> Iterable["_models.LogProfileCollection"] + **kwargs: Any + ) -> Iterable["_models.LogProfileCollection"]: """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 +445,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 +485,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 70e65461a6a8..0ff17e7e0de0 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,23 +5,60 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + resource_uri: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + 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 + ) class MetricDefinitionsOperations(object): """MetricDefinitionsOperations operations. @@ -45,13 +82,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_uri, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.MetricDefinitionCollection"] + resource_uri: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.MetricDefinitionCollection"]: """Lists the metric definitions for the resource. :param resource_uri: The identifier of the resource. @@ -64,8 +101,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 +112,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 +149,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 d82479510092..ec9090a57df0 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 49eeeacfbf31..f5100df22e0e 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 @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -33,13 +31,12 @@ class MonitorManagementClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + **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" @@ -62,4 +59,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 16c3223a2e2f..056ea76a8642 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 894c99e96514..fc61134de6fc 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,72 +6,77 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import 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 - -class MonitorManagementClient(object): +class MonitorManagementClient: """Monitor Management Client. :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] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MonitorManagementClientConfiguration(credential, **kwargs) + credential: "TokenCredential", + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + 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: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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 000000000000..74e48ecd07cf --- /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 000000000000..138f663c53a4 --- /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 cac9f5d10f8b..e5754a47ce68 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 96ce9b45c05b..4eba911f1c6e 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 6e6da199d636..e05030315578 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 c050f4b4aa8f..fc77dcd16de0 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 000000000000..74e48ecd07cf --- /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 4e6584b0e1d9..f60892895603 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 18fcacb6e3f4..39efc93f4a2c 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/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/__init__.py index ef62a11f121a..7e5d780d78e1 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/__init__.py @@ -6,30 +6,18 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import ErrorResponse - from ._models_py3 import LocalizableString - from ._models_py3 import LogSettings - from ._models_py3 import Metric - from ._models_py3 import MetricCollection - from ._models_py3 import MetricSettings - from ._models_py3 import MetricValue - from ._models_py3 import Resource - from ._models_py3 import RetentionPolicy - from ._models_py3 import ServiceDiagnosticSettingsResource - from ._models_py3 import ServiceDiagnosticSettingsResourcePatch -except (SyntaxError, ImportError): - from ._models import ErrorResponse # type: ignore - from ._models import LocalizableString # type: ignore - from ._models import LogSettings # type: ignore - from ._models import Metric # type: ignore - from ._models import MetricCollection # type: ignore - from ._models import MetricSettings # type: ignore - from ._models import MetricValue # type: ignore - from ._models import Resource # type: ignore - from ._models import RetentionPolicy # type: ignore - from ._models import ServiceDiagnosticSettingsResource # type: ignore - from ._models import ServiceDiagnosticSettingsResourcePatch # type: ignore +from ._models_py3 import ErrorResponse +from ._models_py3 import LocalizableString +from ._models_py3 import LogSettings +from ._models_py3 import Metric +from ._models_py3 import MetricCollection +from ._models_py3 import MetricSettings +from ._models_py3 import MetricValue +from ._models_py3 import Resource +from ._models_py3 import RetentionPolicy +from ._models_py3 import ServiceDiagnosticSettingsResource +from ._models_py3 import ServiceDiagnosticSettingsResourcePatch + from ._monitor_management_client_enums import ( Unit, 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 deleted file mode 100644 index d5842d8f0aec..000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/_models.py +++ /dev/null @@ -1,445 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class 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 - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - - -class LocalizableString(msrest.serialization.Model): - """The localizable string class. - - 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 - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LocalizableString, self).__init__(**kwargs) - self.value = kwargs['value'] - self.localized_value = kwargs.get('localized_value', None) - - -class LogSettings(msrest.serialization.Model): - """Part of MultiTenantDiagnosticSettings. Specifies the settings for a particular log. - - 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 - 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 - """ - - _validation = { - 'enabled': {'required': True}, - } - - _attribute_map = { - 'category': {'key': 'category', 'type': 'str'}, - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'retention_policy': {'key': 'retentionPolicy', 'type': 'RetentionPolicy'}, - } - - def __init__( - self, - **kwargs - ): - super(LogSettings, self).__init__(**kwargs) - self.category = kwargs.get('category', None) - self.enabled = kwargs['enabled'] - self.retention_policy = kwargs.get('retention_policy', None) - - -class Metric(msrest.serialization.Model): - """A set of metric values in a time range. - - 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 - string. - :type name: ~$(python-base-namespace).v2016_09_01.models.LocalizableString - :param 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] - """ - - _validation = { - 'name': {'required': True}, - 'unit': {'required': True}, - 'data': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'LocalizableString'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'data': {'key': 'data', 'type': '[MetricValue]'}, - } - - def __init__( - self, - **kwargs - ): - super(Metric, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.type = kwargs.get('type', None) - self.name = kwargs['name'] - self.unit = kwargs['unit'] - self.data = kwargs['data'] - - -class MetricCollection(msrest.serialization.Model): - """The collection of metric value sets. - - 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] - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Metric]'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricCollection, self).__init__(**kwargs) - self.value = kwargs['value'] - - -class MetricSettings(msrest.serialization.Model): - """Part of MultiTenantDiagnosticSettings. Specifies the settings for a particular metric. - - 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 - """ - - _validation = { - 'time_grain': {'required': True}, - 'enabled': {'required': True}, - } - - _attribute_map = { - 'time_grain': {'key': 'timeGrain', 'type': 'duration'}, - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'retention_policy': {'key': 'retentionPolicy', 'type': 'RetentionPolicy'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricSettings, self).__init__(**kwargs) - self.time_grain = kwargs['time_grain'] - self.enabled = kwargs['enabled'] - self.retention_policy = kwargs.get('retention_policy', None) - - -class MetricValue(msrest.serialization.Model): - """Represents a metric value. - - 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 - values that contributed to the average value. - :type count: long - """ - - _validation = { - 'time_stamp': {'required': True}, - } - - _attribute_map = { - 'time_stamp': {'key': 'timeStamp', 'type': 'iso-8601'}, - 'average': {'key': 'average', 'type': 'float'}, - 'minimum': {'key': 'minimum', 'type': 'float'}, - 'maximum': {'key': 'maximum', 'type': 'float'}, - 'total': {'key': 'total', 'type': 'float'}, - 'count': {'key': 'count', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricValue, self).__init__(**kwargs) - self.time_stamp = kwargs['time_stamp'] - self.average = kwargs.get('average', None) - self.minimum = kwargs.get('minimum', None) - self.maximum = kwargs.get('maximum', None) - self.total = kwargs.get('total', None) - self.count = kwargs.get('count', None) - - -class Resource(msrest.serialization.Model): - """An azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :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] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - - -class RetentionPolicy(msrest.serialization.Model): - """Specifies the retention policy for the log. - - 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 - the events indefinitely. - :type days: int - """ - - _validation = { - 'enabled': {'required': True}, - 'days': {'required': True, 'minimum': 0}, - } - - _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'days': {'key': 'days', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(RetentionPolicy, self).__init__(**kwargs) - self.enabled = kwargs['enabled'] - self.days = kwargs['days'] - - -class ServiceDiagnosticSettingsResource(Resource): - """Description of a service diagnostic setting. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :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 - 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 - 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 - 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 - 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 - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'storage_account_id': {'key': 'properties.storageAccountId', 'type': 'str'}, - 'service_bus_rule_id': {'key': 'properties.serviceBusRuleId', 'type': 'str'}, - 'event_hub_authorization_rule_id': {'key': 'properties.eventHubAuthorizationRuleId', 'type': 'str'}, - 'metrics': {'key': 'properties.metrics', 'type': '[MetricSettings]'}, - 'logs': {'key': 'properties.logs', 'type': '[LogSettings]'}, - 'workspace_id': {'key': 'properties.workspaceId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - 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) - self.event_hub_authorization_rule_id = kwargs.get('event_hub_authorization_rule_id', None) - self.metrics = kwargs.get('metrics', None) - self.logs = kwargs.get('logs', None) - self.workspace_id = kwargs.get('workspace_id', None) - - -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 - 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 - 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 - 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 - 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 - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'storage_account_id': {'key': 'properties.storageAccountId', 'type': 'str'}, - 'service_bus_rule_id': {'key': 'properties.serviceBusRuleId', 'type': 'str'}, - 'event_hub_authorization_rule_id': {'key': 'properties.eventHubAuthorizationRuleId', 'type': 'str'}, - 'metrics': {'key': 'properties.metrics', 'type': '[MetricSettings]'}, - 'logs': {'key': 'properties.logs', 'type': '[LogSettings]'}, - 'workspace_id': {'key': 'properties.workspaceId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ServiceDiagnosticSettingsResourcePatch, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.storage_account_id = kwargs.get('storage_account_id', None) - self.service_bus_rule_id = kwargs.get('service_bus_rule_id', None) - self.event_hub_authorization_rule_id = kwargs.get('event_hub_authorization_rule_id', None) - self.metrics = kwargs.get('metrics', None) - self.logs = kwargs.get('logs', None) - self.workspace_id = kwargs.get('workspace_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 44a91f381556..99a177ae114d 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 a8d1b59c86f2..1b9cb5dfb067 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 09facc2424ab..1f7abb6576c3 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,23 +5,60 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + resource_uri: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + 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 + ) class MetricsOperations(object): """MetricsOperations operations. @@ -45,13 +82,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_uri, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.MetricCollection"] + resource_uri: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.MetricCollection"]: """Lists the metric values for a resource. :param resource_uri: The identifier of the resource. @@ -77,7 +114,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 +123,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 +160,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 aa768782b641..9c1f8097d6e3 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,22 +5,136 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_uri: str, + **kwargs: Any +) -> 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: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + resource_uri: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) class ServiceDiagnosticSettingsOperations(object): """ServiceDiagnosticSettingsOperations operations. @@ -44,12 +158,12 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_uri, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ServiceDiagnosticSettingsResource" + resource_uri: str, + **kwargs: Any + ) -> "_models.ServiceDiagnosticSettingsResource": """Gets the active diagnostic settings for the specified resource. **WARNING**\ : This method will be deprecated in future releases. @@ -65,31 +179,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') + + 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) @@ -98,22 +202,25 @@ 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 - parameters, # type: "_models.ServiceDiagnosticSettingsResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.ServiceDiagnosticSettingsResource" + resource_uri: str, + parameters: "_models.ServiceDiagnosticSettingsResource", + **kwargs: Any + ) -> "_models.ServiceDiagnosticSettingsResource": """Create or update new diagnostic settings for the specified resource. **WARNING**\ : This method will be deprecated in future releases. :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,22 +258,25 @@ 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 - service_diagnostic_settings_resource, # type: "_models.ServiceDiagnosticSettingsResourcePatch" - **kwargs # type: Any - ): - # type: (...) -> "_models.ServiceDiagnosticSettingsResource" + resource_uri: str, + service_diagnostic_settings_resource: "_models.ServiceDiagnosticSettingsResourcePatch", + **kwargs: Any + ) -> "_models.ServiceDiagnosticSettingsResource": """Updates an existing ServiceDiagnosticSettingsResource. To update other fields use the CreateOrUpdate method. **WARNING**\ : This method will be deprecated in future releases. :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 +287,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 +315,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 d82479510092..ec9090a57df0 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 20b896410adb..23b544c587c2 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 @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class MonitorManagementClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(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 +65,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 fbd1af47ff22..877e90f7a5f9 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 2fd4b9348900..2fff9a7767ce 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,77 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -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 . 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 import TokenCredential -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.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] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + 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: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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 000000000000..74e48ecd07cf --- /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 000000000000..138f663c53a4 --- /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 cac9f5d10f8b..e5754a47ce68 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 96ce9b45c05b..4eba911f1c6e 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 bdfb3a86feb4..79386b6bd350 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 75051515bdf3..ffe1322a32a4 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 000000000000..74e48ecd07cf --- /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 13d3752a3570..d040201f8eea 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/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/models/__init__.py index 0f517fd8fa60..528346189f70 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/models/__init__.py @@ -6,26 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import ActivityLogAlertActionGroup - from ._models_py3 import ActivityLogAlertActionList - from ._models_py3 import ActivityLogAlertAllOfCondition - from ._models_py3 import ActivityLogAlertLeafCondition - from ._models_py3 import ActivityLogAlertList - from ._models_py3 import ActivityLogAlertResource - from ._models_py3 import ActivityLogAlertResourcePatch - from ._models_py3 import ErrorResponse - from ._models_py3 import Resource -except (SyntaxError, ImportError): - from ._models import ActivityLogAlertActionGroup # type: ignore - from ._models import ActivityLogAlertActionList # type: ignore - from ._models import ActivityLogAlertAllOfCondition # type: ignore - from ._models import ActivityLogAlertLeafCondition # type: ignore - from ._models import ActivityLogAlertList # type: ignore - from ._models import ActivityLogAlertResource # type: ignore - from ._models import ActivityLogAlertResourcePatch # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import Resource # type: ignore +from ._models_py3 import ActivityLogAlertActionGroup +from ._models_py3 import ActivityLogAlertActionList +from ._models_py3 import ActivityLogAlertAllOfCondition +from ._models_py3 import ActivityLogAlertLeafCondition +from ._models_py3 import ActivityLogAlertList +from ._models_py3 import ActivityLogAlertResource +from ._models_py3 import ActivityLogAlertResourcePatch +from ._models_py3 import ErrorResponse +from ._models_py3 import Resource + __all__ = [ 'ActivityLogAlertActionGroup', 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 deleted file mode 100644 index c8f2e52df3ed..000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/models/_models.py +++ /dev/null @@ -1,321 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class ActivityLogAlertActionGroup(msrest.serialization.Model): - """A pointer to an Azure Action Group. - - All required parameters must be populated in order to send to Azure. - - :param action_group_id: Required. The 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 - operation. These data are appended to the webhook payload. - :type webhook_properties: dict[str, str] - """ - - _validation = { - 'action_group_id': {'required': True}, - } - - _attribute_map = { - 'action_group_id': {'key': 'actionGroupId', 'type': 'str'}, - 'webhook_properties': {'key': 'webhookProperties', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(ActivityLogAlertActionGroup, self).__init__(**kwargs) - self.action_group_id = kwargs['action_group_id'] - self.webhook_properties = kwargs.get('webhook_properties', None) - - -class ActivityLogAlertActionList(msrest.serialization.Model): - """A list of activity log alert actions. - - :param action_groups: The list of activity log alerts. - :type action_groups: - list[~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertActionGroup] - """ - - _attribute_map = { - 'action_groups': {'key': 'actionGroups', 'type': '[ActivityLogAlertActionGroup]'}, - } - - def __init__( - self, - **kwargs - ): - super(ActivityLogAlertActionList, self).__init__(**kwargs) - self.action_groups = kwargs.get('action_groups', None) - - -class ActivityLogAlertAllOfCondition(msrest.serialization.Model): - """An Activity Log alert condition that is met when all its member conditions are met. - - All required parameters must be populated in order to send to Azure. - - :param all_of: Required. The list of activity log alert conditions. - :type all_of: - list[~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertLeafCondition] - """ - - _validation = { - 'all_of': {'required': True}, - } - - _attribute_map = { - 'all_of': {'key': 'allOf', 'type': '[ActivityLogAlertLeafCondition]'}, - } - - def __init__( - self, - **kwargs - ): - super(ActivityLogAlertAllOfCondition, self).__init__(**kwargs) - self.all_of = kwargs['all_of'] - - -class ActivityLogAlertLeafCondition(msrest.serialization.Model): - """An Activity Log alert condition that is met by comparing an activity log field and value. - - 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 - 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 - determine if the condition is met. - :type equals: str - """ - - _validation = { - 'field': {'required': True}, - 'equals': {'required': True}, - } - - _attribute_map = { - 'field': {'key': 'field', 'type': 'str'}, - 'equals': {'key': 'equals', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ActivityLogAlertLeafCondition, self).__init__(**kwargs) - self.field = kwargs['field'] - self.equals = kwargs['equals'] - - -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_03_01_preview.models.ActivityLogAlertResource] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ActivityLogAlertResource]'}, - } - - def __init__( - self, - **kwargs - ): - super(ActivityLogAlertList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class Resource(msrest.serialization.Model): - """An azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :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] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - - -class ActivityLogAlertResource(Resource): - """An activity log alert resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :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 - 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_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 - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'scopes': {'key': 'properties.scopes', 'type': '[str]'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - 'condition': {'key': 'properties.condition', 'type': 'ActivityLogAlertAllOfCondition'}, - 'actions': {'key': 'properties.actions', 'type': 'ActivityLogAlertActionList'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ActivityLogAlertResource, self).__init__(**kwargs) - self.scopes = kwargs.get('scopes', None) - self.enabled = kwargs.get('enabled', True) - self.condition = kwargs.get('condition', None) - self.actions = kwargs.get('actions', None) - self.description = kwargs.get('description', None) - - -class ActivityLogAlertResourcePatch(Resource): - """An activity log alert resource for patch operations. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :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 - is not enabled, then none of its actions will be activated. - :type enabled: bool - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(ActivityLogAlertResourcePatch, self).__init__(**kwargs) - self.enabled = kwargs.get('enabled', True) - - -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 - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - 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 e22fb206fcee..42196378038c 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 c820ce837e51..70048fb8511e 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,23 +5,248 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + activity_log_alert_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + activity_log_alert_name: str, + **kwargs: Any +) -> 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: str, + resource_group_name: str, + activity_log_alert_name: str, + **kwargs: Any +) -> 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: str, + resource_group_name: str, + activity_log_alert_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_subscription_id_request( + subscription_id: str, + **kwargs: Any +) -> 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: str, + resource_group_name: str, + **kwargs: Any +) -> 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 + ) class ActivityLogAlertsOperations(object): """ActivityLogAlertsOperations operations. @@ -45,22 +270,23 @@ 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 - activity_log_alert_name, # type: str - activity_log_alert, # type: "_models.ActivityLogAlertResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.ActivityLogAlertResource" + resource_group_name: str, + activity_log_alert_name: str, + activity_log_alert: "_models.ActivityLogAlertResource", + **kwargs: Any + ) -> "_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 +297,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] + + _json = self._serialize.body(activity_log_alert, 'ActivityLogAlertResource') - # 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, + 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,18 +331,20 @@ 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 - activity_log_alert_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ActivityLogAlertResource" + resource_group_name: str, + activity_log_alert_name: str, + **kwargs: Any + ) -> "_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 +358,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,18 +383,20 @@ 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 - activity_log_alert_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + activity_log_alert_name: str, + **kwargs: Any + ) -> 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 +410,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,23 +434,25 @@ 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 - activity_log_alert_name, # type: str - activity_log_alert_patch, # type: "_models.ActivityLogAlertResourcePatch" - **kwargs # type: Any - ): - # type: (...) -> "_models.ActivityLogAlertResource" + resource_group_name: str, + activity_log_alert_name: str, + activity_log_alert_patch: "_models.ActivityLogAlertResourcePatch", + **kwargs: Any + ) -> "_models.ActivityLogAlertResource": """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 +463,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,18 +493,22 @@ 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 - ): - # type: (...) -> Iterable["_models.ActivityLogAlertList"] + **kwargs: Any + ) -> Iterable["_models.ActivityLogAlertList"]: """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 +516,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,30 +551,33 @@ 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 - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ActivityLogAlertList"] + resource_group_name: str, + **kwargs: Any + ) -> 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 +585,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 +622,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 d82479510092..ec9090a57df0 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 5f2a86e565f7..1723a0c2143e 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 @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class MonitorManagementClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(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 +65,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 9eb75d521417..93b8dd8db876 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 c030a475a77b..2a3235194c0f 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,78 +6,80 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import 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 - -class MonitorManagementClient(object): +class MonitorManagementClient: """Monitor Management Client. :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] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + 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: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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 000000000000..74e48ecd07cf --- /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 000000000000..138f663c53a4 --- /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 cac9f5d10f8b..e5754a47ce68 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 96ce9b45c05b..4eba911f1c6e 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 77ab731e4a41..9d93745c9a82 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 b23f3b73ad1a..e74e70f31cff 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 000000000000..74e48ecd07cf --- /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 8dcaae576727..6d47fbde7702 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 f58a8bf3f2a1..80e66fb77d49 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/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/__init__.py index ae82597fb027..52785b077363 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/__init__.py @@ -6,46 +6,26 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import ActionGroupList - from ._models_py3 import ActionGroupPatchBody - from ._models_py3 import ActionGroupResource - from ._models_py3 import ActivityLogAlertActionGroup - from ._models_py3 import ActivityLogAlertActionList - from ._models_py3 import ActivityLogAlertAllOfCondition - from ._models_py3 import ActivityLogAlertLeafCondition - from ._models_py3 import ActivityLogAlertList - from ._models_py3 import ActivityLogAlertPatchBody - from ._models_py3 import ActivityLogAlertResource - from ._models_py3 import AutomationRunbookReceiver - from ._models_py3 import AzureAppPushReceiver - from ._models_py3 import EmailReceiver - from ._models_py3 import EnableRequest - from ._models_py3 import ErrorResponse - from ._models_py3 import ItsmReceiver - from ._models_py3 import Resource - from ._models_py3 import SmsReceiver - from ._models_py3 import WebhookReceiver -except (SyntaxError, ImportError): - from ._models import ActionGroupList # type: ignore - from ._models import ActionGroupPatchBody # type: ignore - from ._models import ActionGroupResource # type: ignore - from ._models import ActivityLogAlertActionGroup # type: ignore - from ._models import ActivityLogAlertActionList # type: ignore - from ._models import ActivityLogAlertAllOfCondition # type: ignore - from ._models import ActivityLogAlertLeafCondition # type: ignore - from ._models import ActivityLogAlertList # type: ignore - from ._models import ActivityLogAlertPatchBody # type: ignore - from ._models import ActivityLogAlertResource # type: ignore - from ._models import AutomationRunbookReceiver # type: ignore - from ._models import AzureAppPushReceiver # type: ignore - from ._models import EmailReceiver # type: ignore - from ._models import EnableRequest # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import ItsmReceiver # type: ignore - from ._models import Resource # type: ignore - from ._models import SmsReceiver # type: ignore - from ._models import WebhookReceiver # type: ignore +from ._models_py3 import ActionGroupList +from ._models_py3 import ActionGroupPatchBody +from ._models_py3 import ActionGroupResource +from ._models_py3 import ActivityLogAlertActionGroup +from ._models_py3 import ActivityLogAlertActionList +from ._models_py3 import ActivityLogAlertAllOfCondition +from ._models_py3 import ActivityLogAlertLeafCondition +from ._models_py3 import ActivityLogAlertList +from ._models_py3 import ActivityLogAlertPatchBody +from ._models_py3 import ActivityLogAlertResource +from ._models_py3 import AutomationRunbookReceiver +from ._models_py3 import AzureAppPushReceiver +from ._models_py3 import EmailReceiver +from ._models_py3 import EnableRequest +from ._models_py3 import ErrorResponse +from ._models_py3 import ItsmReceiver +from ._models_py3 import Resource +from ._models_py3 import SmsReceiver +from ._models_py3 import WebhookReceiver + from ._monitor_management_client_enums import ( ReceiverStatus, 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 deleted file mode 100644 index a4233a319945..000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/_models.py +++ /dev/null @@ -1,694 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class 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 - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ActionGroupResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ActionGroupList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -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 - enabled, then none of its actions will be activated. - :type enabled: bool - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(ActionGroupPatchBody, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.enabled = kwargs.get('enabled', True) - - -class Resource(msrest.serialization.Model): - """An azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :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] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - - -class ActionGroupResource(Resource): - """An action group resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :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 - 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: - list[~$(python-base-namespace).v2017_04_01.models.AzureAppPushReceiver] - :param automation_runbook_receivers: The list of AutomationRunbook receivers that are part of - this action group. - :type automation_runbook_receivers: - list[~$(python-base-namespace).v2017_04_01.models.AutomationRunbookReceiver] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'group_short_name': {'max_length': 12, 'min_length': 0}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'group_short_name': {'key': 'properties.groupShortName', 'type': 'str'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - 'email_receivers': {'key': 'properties.emailReceivers', 'type': '[EmailReceiver]'}, - 'sms_receivers': {'key': 'properties.smsReceivers', 'type': '[SmsReceiver]'}, - 'webhook_receivers': {'key': 'properties.webhookReceivers', 'type': '[WebhookReceiver]'}, - 'itsm_receivers': {'key': 'properties.itsmReceivers', 'type': '[ItsmReceiver]'}, - 'azure_app_push_receivers': {'key': 'properties.azureAppPushReceivers', 'type': '[AzureAppPushReceiver]'}, - 'automation_runbook_receivers': {'key': 'properties.automationRunbookReceivers', 'type': '[AutomationRunbookReceiver]'}, - } - - def __init__( - self, - **kwargs - ): - super(ActionGroupResource, self).__init__(**kwargs) - self.group_short_name = kwargs.get('group_short_name', None) - self.enabled = kwargs.get('enabled', True) - self.email_receivers = kwargs.get('email_receivers', None) - self.sms_receivers = kwargs.get('sms_receivers', None) - self.webhook_receivers = kwargs.get('webhook_receivers', None) - self.itsm_receivers = kwargs.get('itsm_receivers', None) - self.azure_app_push_receivers = kwargs.get('azure_app_push_receivers', None) - self.automation_runbook_receivers = kwargs.get('automation_runbook_receivers', None) - - -class ActivityLogAlertActionGroup(msrest.serialization.Model): - """A pointer to an Azure Action Group. - - All required parameters must be populated in order to send to Azure. - - :param action_group_id: Required. The 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 - operation. These data are appended to the webhook payload. - :type webhook_properties: dict[str, str] - """ - - _validation = { - 'action_group_id': {'required': True}, - } - - _attribute_map = { - 'action_group_id': {'key': 'actionGroupId', 'type': 'str'}, - 'webhook_properties': {'key': 'webhookProperties', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(ActivityLogAlertActionGroup, self).__init__(**kwargs) - self.action_group_id = kwargs['action_group_id'] - self.webhook_properties = kwargs.get('webhook_properties', None) - - -class ActivityLogAlertActionList(msrest.serialization.Model): - """A list of activity log alert actions. - - :param action_groups: The list of activity log alerts. - :type action_groups: - list[~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertActionGroup] - """ - - _attribute_map = { - 'action_groups': {'key': 'actionGroups', 'type': '[ActivityLogAlertActionGroup]'}, - } - - def __init__( - self, - **kwargs - ): - super(ActivityLogAlertActionList, self).__init__(**kwargs) - self.action_groups = kwargs.get('action_groups', None) - - -class ActivityLogAlertAllOfCondition(msrest.serialization.Model): - """An Activity Log alert condition that is met when all its member conditions are met. - - All required parameters must be populated in order to send to Azure. - - :param all_of: Required. The list of activity log alert conditions. - :type all_of: list[~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertLeafCondition] - """ - - _validation = { - 'all_of': {'required': True}, - } - - _attribute_map = { - 'all_of': {'key': 'allOf', 'type': '[ActivityLogAlertLeafCondition]'}, - } - - def __init__( - self, - **kwargs - ): - super(ActivityLogAlertAllOfCondition, self).__init__(**kwargs) - self.all_of = kwargs['all_of'] - - -class ActivityLogAlertLeafCondition(msrest.serialization.Model): - """An Activity Log alert condition that is met by comparing an activity log field and value. - - 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 - 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 - determine if the condition is met. - :type equals: str - """ - - _validation = { - 'field': {'required': True}, - 'equals': {'required': True}, - } - - _attribute_map = { - 'field': {'key': 'field', 'type': 'str'}, - 'equals': {'key': 'equals', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ActivityLogAlertLeafCondition, self).__init__(**kwargs) - self.field = kwargs['field'] - self.equals = kwargs['equals'] - - -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 - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ActivityLogAlertResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ActivityLogAlertList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -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 - is not enabled, then none of its actions will be activated. - :type enabled: bool - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(ActivityLogAlertPatchBody, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.enabled = kwargs.get('enabled', True) - - -class ActivityLogAlertResource(Resource): - """An activity log alert resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :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 - 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 - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'scopes': {'key': 'properties.scopes', 'type': '[str]'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - 'condition': {'key': 'properties.condition', 'type': 'ActivityLogAlertAllOfCondition'}, - 'actions': {'key': 'properties.actions', 'type': 'ActivityLogAlertActionList'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ActivityLogAlertResource, self).__init__(**kwargs) - self.scopes = kwargs.get('scopes', None) - self.enabled = kwargs.get('enabled', True) - self.condition = kwargs.get('condition', None) - self.actions = kwargs.get('actions', None) - self.description = kwargs.get('description', None) - - -class AutomationRunbookReceiver(msrest.serialization.Model): - """The Azure Automation Runbook notification receiver. - - 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 - """ - - _validation = { - 'automation_account_id': {'required': True}, - 'runbook_name': {'required': True}, - 'webhook_resource_id': {'required': True}, - 'is_global_runbook': {'required': True}, - } - - _attribute_map = { - 'automation_account_id': {'key': 'automationAccountId', 'type': 'str'}, - 'runbook_name': {'key': 'runbookName', 'type': 'str'}, - 'webhook_resource_id': {'key': 'webhookResourceId', 'type': 'str'}, - 'is_global_runbook': {'key': 'isGlobalRunbook', 'type': 'bool'}, - 'name': {'key': 'name', 'type': 'str'}, - 'service_uri': {'key': 'serviceUri', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AutomationRunbookReceiver, self).__init__(**kwargs) - self.automation_account_id = kwargs['automation_account_id'] - self.runbook_name = kwargs['runbook_name'] - self.webhook_resource_id = kwargs['webhook_resource_id'] - self.is_global_runbook = kwargs['is_global_runbook'] - self.name = kwargs.get('name', None) - self.service_uri = kwargs.get('service_uri', None) - - -class AzureAppPushReceiver(msrest.serialization.Model): - """The Azure mobile App push notification receiver. - - 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 - 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 - """ - - _validation = { - 'name': {'required': True}, - 'email_address': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'email_address': {'key': 'emailAddress', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureAppPushReceiver, self).__init__(**kwargs) - self.name = kwargs['name'] - self.email_address = kwargs['email_address'] - - -class EmailReceiver(msrest.serialization.Model): - """An email receiver. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param 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 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 - """ - - _validation = { - 'name': {'required': True}, - 'email_address': {'required': True}, - 'status': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'email_address': {'key': 'emailAddress', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EmailReceiver, self).__init__(**kwargs) - self.name = kwargs['name'] - self.email_address = kwargs['email_address'] - self.status = None - - -class EnableRequest(msrest.serialization.Model): - """Describes a receiver that should be resubscribed. - - 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 - """ - - _validation = { - 'receiver_name': {'required': True}, - } - - _attribute_map = { - 'receiver_name': {'key': 'receiverName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EnableRequest, self).__init__(**kwargs) - self.receiver_name = kwargs['receiver_name'] - - -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 - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - - -class ItsmReceiver(msrest.serialization.Model): - """An Itsm receiver. - - 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 - 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 - in above workspace. - :type connection_id: str - :param 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 - values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. - :type region: str - """ - - _validation = { - 'name': {'required': True}, - 'workspace_id': {'required': True}, - 'connection_id': {'required': True}, - 'ticket_configuration': {'required': True}, - 'region': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'workspace_id': {'key': 'workspaceId', 'type': 'str'}, - 'connection_id': {'key': 'connectionId', 'type': 'str'}, - 'ticket_configuration': {'key': 'ticketConfiguration', 'type': 'str'}, - 'region': {'key': 'region', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ItsmReceiver, self).__init__(**kwargs) - self.name = kwargs['name'] - self.workspace_id = kwargs['workspace_id'] - self.connection_id = kwargs['connection_id'] - self.ticket_configuration = kwargs['ticket_configuration'] - self.region = kwargs['region'] - - -class SmsReceiver(msrest.serialization.Model): - """An SMS receiver. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param 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 - :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 - """ - - _validation = { - 'name': {'required': True}, - 'country_code': {'required': True}, - 'phone_number': {'required': True}, - 'status': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'country_code': {'key': 'countryCode', 'type': 'str'}, - 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SmsReceiver, self).__init__(**kwargs) - self.name = kwargs['name'] - self.country_code = kwargs['country_code'] - self.phone_number = kwargs['phone_number'] - self.status = None - - -class WebhookReceiver(msrest.serialization.Model): - """A webhook receiver. - - 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 - receivers within an action group. - :type name: str - :param service_uri: Required. The URI where webhooks should be sent. - :type service_uri: str - """ - - _validation = { - 'name': {'required': True}, - 'service_uri': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'service_uri': {'key': 'serviceUri', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - 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 e7619cc6add3..92b25077d832 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 238df22ea2f0..5e8a759db49c 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 ea02f9051b2b..2b3f1dc57e9f 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,23 +5,292 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_or_update_request( + resource_group_name: str, + action_group_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + action_group_name: str, + subscription_id: str, + **kwargs: Any +) -> 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: str, + action_group_name: str, + subscription_id: str, + **kwargs: Any +) -> 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: str, + resource_group_name: str, + action_group_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_subscription_id_request( + subscription_id: str, + **kwargs: Any +) -> 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: str, + subscription_id: str, + **kwargs: Any +) -> 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: str, + action_group_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) class ActionGroupsOperations(object): """ActionGroupsOperations operations. @@ -45,17 +314,17 @@ 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 - action_group_name, # type: str - action_group, # type: "_models.ActionGroupResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.ActionGroupResource" + resource_group_name: str, + action_group_name: str, + action_group: "_models.ActionGroupResource", + **kwargs: Any + ) -> "_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 +340,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,18 +374,20 @@ 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 - action_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ActionGroupResource" + resource_group_name: str, + action_group_name: str, + **kwargs: Any + ) -> "_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 +401,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,18 +426,20 @@ 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 - action_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + action_group_name: str, + **kwargs: Any + ) -> 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,17 +477,18 @@ 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 - action_group_name, # type: str - action_group_patch, # type: "_models.ActionGroupPatchBody" - **kwargs # type: Any - ): - # type: (...) -> "_models.ActionGroupResource" + resource_group_name: str, + action_group_name: str, + action_group_patch: "_models.ActionGroupPatchBody", + **kwargs: Any + ) -> "_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 +504,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,18 +534,21 @@ 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 - ): - # type: (...) -> Iterable["_models.ActionGroupList"] + **kwargs: Any + ) -> Iterable["_models.ActionGroupList"]: """Get a list of all action groups 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 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 +556,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,30 +591,32 @@ 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 - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ActionGroupList"] + resource_group_name: str, + **kwargs: Any + ) -> 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 +624,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,29 +661,30 @@ 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 - action_group_name, # type: str - enable_request, # type: "_models.EnableRequest" - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + action_group_name: str, + enable_request: "_models.EnableRequest", + **kwargs: Any + ) -> None: """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 +700,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 f1b3eaf39f84..d465ef64e4bd 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,23 +5,248 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + activity_log_alert_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + activity_log_alert_name: str, + **kwargs: Any +) -> 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: str, + resource_group_name: str, + activity_log_alert_name: str, + **kwargs: Any +) -> 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: str, + resource_group_name: str, + activity_log_alert_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_subscription_id_request( + subscription_id: str, + **kwargs: Any +) -> 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: str, + resource_group_name: str, + **kwargs: Any +) -> 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 + ) class ActivityLogAlertsOperations(object): """ActivityLogAlertsOperations operations. @@ -45,17 +270,17 @@ 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 - activity_log_alert_name, # type: str - activity_log_alert, # type: "_models.ActivityLogAlertResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.ActivityLogAlertResource" + resource_group_name: str, + activity_log_alert_name: str, + activity_log_alert: "_models.ActivityLogAlertResource", + **kwargs: Any + ) -> "_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 +296,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] + + _json = self._serialize.body(activity_log_alert, 'ActivityLogAlertResource') - # 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, + 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,18 +330,20 @@ 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 - activity_log_alert_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ActivityLogAlertResource" + resource_group_name: str, + activity_log_alert_name: str, + **kwargs: Any + ) -> "_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 +357,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,18 +382,20 @@ 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 - activity_log_alert_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + activity_log_alert_name: str, + **kwargs: Any + ) -> 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 +409,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,23 +433,25 @@ 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 - activity_log_alert_name, # type: str - activity_log_alert_patch, # type: "_models.ActivityLogAlertPatchBody" - **kwargs # type: Any - ): - # type: (...) -> "_models.ActivityLogAlertResource" + resource_group_name: str, + activity_log_alert_name: str, + activity_log_alert_patch: "_models.ActivityLogAlertPatchBody", + **kwargs: Any + ) -> "_models.ActivityLogAlertResource": """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 +462,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,18 +492,22 @@ 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 - ): - # type: (...) -> Iterable["_models.ActivityLogAlertList"] + **kwargs: Any + ) -> Iterable["_models.ActivityLogAlertList"]: """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 +515,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,30 +550,33 @@ 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 - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ActivityLogAlertList"] + resource_group_name: str, + **kwargs: Any + ) -> 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 +584,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 +621,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 d82479510092..ec9090a57df0 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 7f204474d189..adb04d3afc9e 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 @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class MonitorManagementClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(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 +65,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 1ae63ddbf336..0f3d571414fa 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 bc4d0dc8dbcd..747a5873d2a3 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,92 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import 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 - -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.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] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + 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: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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 000000000000..74e48ecd07cf --- /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 000000000000..138f663c53a4 --- /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 cac9f5d10f8b..e5754a47ce68 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 96ce9b45c05b..4eba911f1c6e 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 45862e08ab63..ac5e4fab2ece 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 f01ad0b4a80c..e5c199e8f47c 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 000000000000..74e48ecd07cf --- /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 45f9db049d63..cafab6b4b88b 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 6e9b20cb8146..f57b4c4dd0a9 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 2f1e2fcc8abb..ca5ce67eba08 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 c67d4fab6b8a..7e03d1199249 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 64ba48d799b0..4b0c9ac8f0f1 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/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/__init__.py index 087885d52836..e41ba32b99f7 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/__init__.py @@ -6,52 +6,29 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import DiagnosticSettingsCategoryResource - from ._models_py3 import DiagnosticSettingsCategoryResourceCollection - from ._models_py3 import DiagnosticSettingsResource - from ._models_py3 import DiagnosticSettingsResourceCollection - from ._models_py3 import ErrorResponse - from ._models_py3 import LocalizableString - from ._models_py3 import LogSettings - from ._models_py3 import MetadataValue - from ._models_py3 import Metric - from ._models_py3 import MetricAvailability - from ._models_py3 import MetricDefinition - from ._models_py3 import MetricDefinitionCollection - from ._models_py3 import MetricSettings - from ._models_py3 import MetricValue - from ._models_py3 import ProxyOnlyResource - from ._models_py3 import Response - from ._models_py3 import RetentionPolicy - from ._models_py3 import SubscriptionDiagnosticSettingsResource - from ._models_py3 import SubscriptionDiagnosticSettingsResourceCollection - from ._models_py3 import SubscriptionLogSettings - from ._models_py3 import SubscriptionProxyOnlyResource - from ._models_py3 import TimeSeriesElement -except (SyntaxError, ImportError): - from ._models import DiagnosticSettingsCategoryResource # type: ignore - from ._models import DiagnosticSettingsCategoryResourceCollection # type: ignore - from ._models import DiagnosticSettingsResource # type: ignore - from ._models import DiagnosticSettingsResourceCollection # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import LocalizableString # type: ignore - from ._models import LogSettings # type: ignore - from ._models import MetadataValue # type: ignore - from ._models import Metric # type: ignore - from ._models import MetricAvailability # type: ignore - from ._models import MetricDefinition # type: ignore - from ._models import MetricDefinitionCollection # type: ignore - from ._models import MetricSettings # type: ignore - from ._models import MetricValue # type: ignore - from ._models import ProxyOnlyResource # type: ignore - from ._models import Response # type: ignore - from ._models import RetentionPolicy # type: ignore - from ._models import SubscriptionDiagnosticSettingsResource # type: ignore - from ._models import SubscriptionDiagnosticSettingsResourceCollection # type: ignore - from ._models import SubscriptionLogSettings # type: ignore - from ._models import SubscriptionProxyOnlyResource # type: ignore - from ._models import TimeSeriesElement # type: ignore +from ._models_py3 import DiagnosticSettingsCategoryResource +from ._models_py3 import DiagnosticSettingsCategoryResourceCollection +from ._models_py3 import DiagnosticSettingsResource +from ._models_py3 import DiagnosticSettingsResourceCollection +from ._models_py3 import ErrorResponse +from ._models_py3 import LocalizableString +from ._models_py3 import LogSettings +from ._models_py3 import MetadataValue +from ._models_py3 import Metric +from ._models_py3 import MetricAvailability +from ._models_py3 import MetricDefinition +from ._models_py3 import MetricDefinitionCollection +from ._models_py3 import MetricSettings +from ._models_py3 import MetricValue +from ._models_py3 import ProxyOnlyResource +from ._models_py3 import Response +from ._models_py3 import RetentionPolicy +from ._models_py3 import SubscriptionDiagnosticSettingsResource +from ._models_py3 import SubscriptionDiagnosticSettingsResourceCollection +from ._models_py3 import SubscriptionLogSettings +from ._models_py3 import SubscriptionProxyOnlyResource +from ._models_py3 import TimeSeriesElement + from ._monitor_management_client_enums import ( AggregationType, 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 deleted file mode 100644 index 4f1b71bd9cee..000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/_models.py +++ /dev/null @@ -1,813 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class ProxyOnlyResource(msrest.serialization.Model): - """A proxy only azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ProxyOnlyResource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class DiagnosticSettingsCategoryResource(ProxyOnlyResource): - """The diagnostic settings category resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :param 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 - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'category_type': {'key': 'properties.categoryType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DiagnosticSettingsCategoryResource, self).__init__(**kwargs) - self.category_type = kwargs.get('category_type', None) - - -class DiagnosticSettingsCategoryResourceCollection(msrest.serialization.Model): - """Represents a collection of diagnostic setting category resources. - - :param value: The collection of diagnostic settings category resources. - :type value: - list[~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsCategoryResource] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[DiagnosticSettingsCategoryResource]'}, - } - - def __init__( - self, - **kwargs - ): - super(DiagnosticSettingsCategoryResourceCollection, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class DiagnosticSettingsResource(ProxyOnlyResource): - """The diagnostic setting resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :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 - 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 - 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 - 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 - 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 - 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 - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'storage_account_id': {'key': 'properties.storageAccountId', 'type': 'str'}, - 'service_bus_rule_id': {'key': 'properties.serviceBusRuleId', 'type': 'str'}, - 'event_hub_authorization_rule_id': {'key': 'properties.eventHubAuthorizationRuleId', 'type': 'str'}, - 'event_hub_name': {'key': 'properties.eventHubName', 'type': 'str'}, - 'metrics': {'key': 'properties.metrics', 'type': '[MetricSettings]'}, - 'logs': {'key': 'properties.logs', 'type': '[LogSettings]'}, - 'workspace_id': {'key': 'properties.workspaceId', 'type': 'str'}, - 'log_analytics_destination_type': {'key': 'properties.logAnalyticsDestinationType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - 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) - self.event_hub_authorization_rule_id = kwargs.get('event_hub_authorization_rule_id', None) - self.event_hub_name = kwargs.get('event_hub_name', None) - self.metrics = kwargs.get('metrics', None) - self.logs = kwargs.get('logs', None) - self.workspace_id = kwargs.get('workspace_id', None) - self.log_analytics_destination_type = kwargs.get('log_analytics_destination_type', None) - - -class DiagnosticSettingsResourceCollection(msrest.serialization.Model): - """Represents a collection of alert rule resources. - - :param value: The collection of diagnostic settings resources;. - :type value: - list[~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsResource] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[DiagnosticSettingsResource]'}, - } - - def __init__( - self, - **kwargs - ): - super(DiagnosticSettingsResourceCollection, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -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 - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - - -class LocalizableString(msrest.serialization.Model): - """The localizable string class. - - 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 - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LocalizableString, self).__init__(**kwargs) - self.value = kwargs['value'] - self.localized_value = kwargs.get('localized_value', None) - - -class LogSettings(msrest.serialization.Model): - """Part of MultiTenantDiagnosticSettings. Specifies the settings for a particular log. - - 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 - 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 - """ - - _validation = { - 'enabled': {'required': True}, - } - - _attribute_map = { - 'category': {'key': 'category', 'type': 'str'}, - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'retention_policy': {'key': 'retentionPolicy', 'type': 'RetentionPolicy'}, - } - - def __init__( - self, - **kwargs - ): - super(LogSettings, self).__init__(**kwargs) - self.category = kwargs.get('category', None) - self.enabled = kwargs['enabled'] - self.retention_policy = kwargs.get('retention_policy', None) - - -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 - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'LocalizableString'}, - 'value': {'key': 'value', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MetadataValue, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.value = kwargs.get('value', None) - - -class Metric(msrest.serialization.Model): - """The result data of a query. - - 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 - 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", - "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] - """ - - _validation = { - 'id': {'required': True}, - 'type': {'required': True}, - 'name': {'required': True}, - 'unit': {'required': True}, - 'timeseries': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'LocalizableString'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'error_code': {'key': 'errorCode', 'type': 'str'}, - 'error_message': {'key': 'errorMessage', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'timeseries': {'key': 'timeseries', 'type': '[TimeSeriesElement]'}, - } - - def __init__( - self, - **kwargs - ): - super(Metric, self).__init__(**kwargs) - self.id = kwargs['id'] - self.type = kwargs['type'] - self.name = kwargs['name'] - self.display_description = kwargs.get('display_description', None) - self.error_code = kwargs.get('error_code', None) - self.error_message = kwargs.get('error_message', None) - self.unit = kwargs['unit'] - self.timeseries = kwargs['timeseries'] - - -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 - 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 - a duration 'PT1M', 'P1D', etc. - :type retention: ~datetime.timedelta - """ - - _attribute_map = { - 'time_grain': {'key': 'timeGrain', 'type': 'duration'}, - 'retention': {'key': 'retention', 'type': 'duration'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricAvailability, self).__init__(**kwargs) - self.time_grain = kwargs.get('time_grain', None) - self.retention = kwargs.get('retention', None) - - -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", - "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 - values for display. Possible values include: "None", "Average", "Count", "Minimum", "Maximum", - "Total". - :type 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 - queried. - :type 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 - string. - :type dimensions: list[~$(python-base-namespace).v2017_05_01_preview.models.LocalizableString] - """ - - _attribute_map = { - 'is_dimension_required': {'key': 'isDimensionRequired', 'type': 'bool'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'LocalizableString'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'category': {'key': 'category', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'primary_aggregation_type': {'key': 'primaryAggregationType', 'type': 'str'}, - 'metric_availabilities': {'key': 'metricAvailabilities', 'type': '[MetricAvailability]'}, - 'id': {'key': 'id', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[LocalizableString]'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricDefinition, self).__init__(**kwargs) - self.is_dimension_required = kwargs.get('is_dimension_required', None) - self.resource_id = kwargs.get('resource_id', None) - self.name = kwargs.get('name', None) - self.display_description = kwargs.get('display_description', None) - self.category = kwargs.get('category', None) - self.unit = kwargs.get('unit', None) - self.primary_aggregation_type = kwargs.get('primary_aggregation_type', None) - self.metric_availabilities = kwargs.get('metric_availabilities', None) - self.id = kwargs.get('id', None) - self.dimensions = kwargs.get('dimensions', None) - - -class MetricDefinitionCollection(msrest.serialization.Model): - """Represents collection of metric definitions. - - 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] - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[MetricDefinition]'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricDefinitionCollection, self).__init__(**kwargs) - self.value = kwargs['value'] - - -class MetricSettings(msrest.serialization.Model): - """Part of MultiTenantDiagnosticSettings. Specifies the settings for a particular metric. - - 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 - 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 - """ - - _validation = { - 'enabled': {'required': True}, - } - - _attribute_map = { - 'time_grain': {'key': 'timeGrain', 'type': 'duration'}, - 'category': {'key': 'category', 'type': 'str'}, - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'retention_policy': {'key': 'retentionPolicy', 'type': 'RetentionPolicy'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricSettings, self).__init__(**kwargs) - self.time_grain = kwargs.get('time_grain', None) - self.category = kwargs.get('category', None) - self.enabled = kwargs['enabled'] - self.retention_policy = kwargs.get('retention_policy', None) - - -class MetricValue(msrest.serialization.Model): - """Represents a metric value. - - 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 - values that contributed to the average value. - :type count: long - """ - - _validation = { - 'time_stamp': {'required': True}, - } - - _attribute_map = { - 'time_stamp': {'key': 'timeStamp', 'type': 'iso-8601'}, - 'average': {'key': 'average', 'type': 'float'}, - 'minimum': {'key': 'minimum', 'type': 'float'}, - 'maximum': {'key': 'maximum', 'type': 'float'}, - 'total': {'key': 'total', 'type': 'float'}, - 'count': {'key': 'count', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricValue, self).__init__(**kwargs) - self.time_stamp = kwargs['time_stamp'] - self.average = kwargs.get('average', None) - self.minimum = kwargs.get('minimum', None) - self.maximum = kwargs.get('maximum', None) - self.total = kwargs.get('total', None) - self.count = kwargs.get('count', None) - - -class Response(msrest.serialization.Model): - """The response to a metrics query. - - 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 - 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] - """ - - _validation = { - 'cost': {'minimum': 0}, - 'timespan': {'required': True}, - 'value': {'required': True}, - } - - _attribute_map = { - 'cost': {'key': 'cost', 'type': 'int'}, - 'timespan': {'key': 'timespan', 'type': 'str'}, - 'interval': {'key': 'interval', 'type': 'duration'}, - 'value': {'key': 'value', 'type': '[Metric]'}, - } - - def __init__( - self, - **kwargs - ): - super(Response, self).__init__(**kwargs) - self.cost = kwargs.get('cost', None) - self.timespan = kwargs['timespan'] - self.interval = kwargs.get('interval', None) - self.value = kwargs['value'] - - -class RetentionPolicy(msrest.serialization.Model): - """Specifies the retention policy for the log. - - 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 - the events indefinitely. - :type days: int - """ - - _validation = { - 'enabled': {'required': True}, - 'days': {'required': True, 'minimum': 0}, - } - - _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'days': {'key': 'days', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(RetentionPolicy, self).__init__(**kwargs) - self.enabled = kwargs['enabled'] - self.days = kwargs['days'] - - -class SubscriptionProxyOnlyResource(msrest.serialization.Model): - """A proxy only azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :param location: Location of the resource. - :type location: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SubscriptionProxyOnlyResource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = kwargs.get('location', None) - - -class SubscriptionDiagnosticSettingsResource(SubscriptionProxyOnlyResource): - """The subscription diagnostic setting resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :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 - 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 - 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 - 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 - like to send Diagnostic Logs. Example: - /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2. - :type workspace_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'storage_account_id': {'key': 'properties.storageAccountId', 'type': 'str'}, - 'service_bus_rule_id': {'key': 'properties.serviceBusRuleId', 'type': 'str'}, - 'event_hub_authorization_rule_id': {'key': 'properties.eventHubAuthorizationRuleId', 'type': 'str'}, - 'event_hub_name': {'key': 'properties.eventHubName', 'type': 'str'}, - 'logs': {'key': 'properties.logs', 'type': '[SubscriptionLogSettings]'}, - 'workspace_id': {'key': 'properties.workspaceId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - 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) - self.event_hub_authorization_rule_id = kwargs.get('event_hub_authorization_rule_id', None) - self.event_hub_name = kwargs.get('event_hub_name', None) - self.logs = kwargs.get('logs', None) - self.workspace_id = kwargs.get('workspace_id', None) - - -class SubscriptionDiagnosticSettingsResourceCollection(msrest.serialization.Model): - """Represents a collection of subscription diagnostic settings resources. - - :param value: The collection of subscription diagnostic settings resources. - :type value: - list[~$(python-base-namespace).v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResource] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SubscriptionDiagnosticSettingsResource]'}, - } - - def __init__( - self, - **kwargs - ): - super(SubscriptionDiagnosticSettingsResourceCollection, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class SubscriptionLogSettings(msrest.serialization.Model): - """Part of Subscription diagnostic setting. Specifies the settings for a particular log. - - 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 - """ - - _validation = { - 'enabled': {'required': True}, - } - - _attribute_map = { - 'category': {'key': 'category', 'type': 'str'}, - 'enabled': {'key': 'enabled', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(SubscriptionLogSettings, self).__init__(**kwargs) - self.category = kwargs.get('category', None) - self.enabled = kwargs['enabled'] - - -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] - """ - - _attribute_map = { - 'metadatavalues': {'key': 'metadatavalues', 'type': '[MetadataValue]'}, - 'data': {'key': 'data', 'type': '[MetricValue]'}, - } - - def __init__( - self, - **kwargs - ): - 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 c5e381a974b8..5e7f0b6cacbc 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 a9c23992cba4..4e17f31bcd8c 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 34a67c997d28..6a6819601998 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,22 +5,88 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_uri: str, + name: str, + **kwargs: Any +) -> 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: str, + **kwargs: Any +) -> 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 + ) class DiagnosticSettingsCategoryOperations(object): """DiagnosticSettingsCategoryOperations operations. @@ -44,13 +110,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_uri, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DiagnosticSettingsCategoryResource" + resource_uri: str, + name: str, + **kwargs: Any + ) -> "_models.DiagnosticSettingsCategoryResource": """Gets the diagnostic settings category for the specified resource. :param resource_uri: The identifier of the resource. @@ -67,32 +133,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') + + 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) - # 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('DiagnosticSettingsCategoryResource', pipeline_response) @@ -101,21 +157,24 @@ 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 - **kwargs # type: Any - ): - # type: (...) -> "_models.DiagnosticSettingsCategoryResourceCollection" + resource_uri: str, + **kwargs: Any + ) -> "_models.DiagnosticSettingsCategoryResourceCollection": """Lists the diagnostic settings categories for the specified 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: 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 +182,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 +205,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 1a0812a78dbd..537aa0d67b93 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,22 +5,164 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_uri: str, + name: str, + **kwargs: Any +) -> 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: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_uri: str, + name: str, + **kwargs: Any +) -> 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: str, + **kwargs: Any +) -> 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 + ) class DiagnosticSettingsOperations(object): """DiagnosticSettingsOperations operations. @@ -44,13 +186,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_uri, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DiagnosticSettingsResource" + resource_uri: str, + name: str, + **kwargs: Any + ) -> "_models.DiagnosticSettingsResource": """Gets the active diagnostic settings for the specified resource. :param resource_uri: The identifier of the resource. @@ -67,32 +209,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') + + 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) - # 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('DiagnosticSettingsResource', pipeline_response) @@ -101,16 +233,18 @@ 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 - name, # type: str - parameters, # type: "_models.DiagnosticSettingsResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.DiagnosticSettingsResource" + resource_uri: str, + name: str, + parameters: "_models.DiagnosticSettingsResource", + **kwargs: Any + ) -> "_models.DiagnosticSettingsResource": """Creates or updates diagnostic settings for the specified resource. :param resource_uri: The identifier of the resource. @@ -118,7 +252,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 +264,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] - # 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) @@ -168,15 +293,17 @@ 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 - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_uri: str, + name: str, + **kwargs: Any + ) -> None: """Deletes existing diagnostic settings for the specified resource. :param resource_uri: The identifier of the resource. @@ -193,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 = { - '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,19 +343,21 @@ def delete( delete.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}'} # type: ignore + + @distributed_trace def list( self, - resource_uri, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DiagnosticSettingsResourceCollection" + resource_uri: str, + **kwargs: Any + ) -> "_models.DiagnosticSettingsResourceCollection": """Gets the active diagnostic settings list for the specified 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: 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 +365,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) + + 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) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.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 +388,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 8ea5c705647b..c836a6bd1441 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,23 +5,56 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + resource_uri: str, + **kwargs: Any +) -> 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 + ) class MetricDefinitionsOperations(object): """MetricDefinitionsOperations operations. @@ -45,19 +78,21 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_uri, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.MetricDefinitionCollection"] + resource_uri: str, + **kwargs: Any + ) -> Iterable["_models.MetricDefinitionCollection"]: """Lists the metric definitions for the 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 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 +100,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 +135,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 797f7c758f49..6fe2455241b8 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,22 +6,80 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime -from typing import TYPE_CHECKING +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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + resource_uri: str, + *, + timespan: Optional[str] = None, + interval: Optional[datetime.timedelta] = None, + metric: Optional[str] = None, + aggregation: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + filter: Optional[str] = None, + result_type: Optional[Union[str, "_models.ResultType"]] = None, + **kwargs: Any +) -> HttpRequest: + 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 + ) class MetricsOperations(object): """MetricsOperations operations. @@ -45,20 +103,20 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_uri, # type: str - timespan=None, # type: Optional[str] - interval=None, # type: Optional[datetime.timedelta] - metric=None, # type: Optional[str] - aggregation=None, # type: Optional[str] - top=None, # type: Optional[int] - orderby=None, # type: Optional[str] - filter=None, # type: Optional[str] - result_type=None, # type: Optional[Union[str, "_models.ResultType"]] - **kwargs # type: Any - ): - # type: (...) -> "_models.Response" + resource_uri: str, + timespan: Optional[str] = None, + interval: Optional[datetime.timedelta] = None, + metric: Optional[str] = None, + aggregation: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + filter: Optional[str] = None, + result_type: Optional[Union[str, "_models.ResultType"]] = None, + **kwargs: Any + ) -> "_models.Response": """**Lists the metric values for a resource**. :param resource_uri: The identifier of the resource. @@ -103,47 +161,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 +192,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 00fd46a8c877..89e7e61db03f 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,22 +5,164 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + subscription_id: str, + name: str, + **kwargs: Any +) -> 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: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + name: str, + **kwargs: Any +) -> 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: str, + **kwargs: Any +) -> 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 + ) class SubscriptionDiagnosticSettingsOperations(object): """SubscriptionDiagnosticSettingsOperations operations. @@ -44,19 +186,20 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SubscriptionDiagnosticSettingsResource" + name: str, + **kwargs: Any + ) -> "_models.SubscriptionDiagnosticSettingsResource": """Gets the active subscription diagnostic settings for the specified resource. :param name: The name of the diagnostic setting. :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 +207,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') + + 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) - # 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('SubscriptionDiagnosticSettingsResource', pipeline_response) @@ -98,24 +231,28 @@ 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 - parameters, # type: "_models.SubscriptionDiagnosticSettingsResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.SubscriptionDiagnosticSettingsResource" + name: str, + parameters: "_models.SubscriptionDiagnosticSettingsResource", + **kwargs: Any + ) -> "_models.SubscriptionDiagnosticSettingsResource": """Creates or updates subscription diagnostic settings for the specified resource. :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 +260,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] - # 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) @@ -162,14 +289,16 @@ 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 - **kwargs # type: Any - ): - # type: (...) -> None + name: str, + **kwargs: Any + ) -> None: """Deletes existing subscription diagnostic settings for the specified resource. :param name: The name of the diagnostic setting. @@ -184,32 +313,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,16 +336,18 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}'} # type: ignore + + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> "_models.SubscriptionDiagnosticSettingsResourceCollection" + **kwargs: Any + ) -> "_models.SubscriptionDiagnosticSettingsResourceCollection": """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: 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 +355,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) + + 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) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.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 +378,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 d82479510092..ec9090a57df0 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 6dd30405ac62..2f232283b850 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 @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -33,13 +31,12 @@ class MonitorManagementClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + **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" @@ -62,4 +59,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 be87d4f16fcc..dc6519555c3a 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 6b0003ef7c34..54b7a3e3d3f5 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,74 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -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 . 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 import TokenCredential -class MonitorManagementClient(object): +class MonitorManagementClient: """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] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MonitorManagementClientConfiguration(credential, **kwargs) + credential: "TokenCredential", + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + 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: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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 000000000000..74e48ecd07cf --- /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 000000000000..138f663c53a4 --- /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 cac9f5d10f8b..e5754a47ce68 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 96ce9b45c05b..4eba911f1c6e 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 f0599c4e5ec2..b94ccd520e18 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 66e7e2379476..294998b3c92d 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 000000000000..74e48ecd07cf --- /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 dbf2ab029f66..c8caf0224f93 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/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/models/__init__.py index 6bd9d401e19d..5ed46c55c546 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/models/__init__.py @@ -6,22 +6,14 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import Baseline - from ._models_py3 import BaselineMetadataValue - from ._models_py3 import BaselineResponse - from ._models_py3 import CalculateBaselineResponse - from ._models_py3 import ErrorResponse - from ._models_py3 import LocalizableString - from ._models_py3 import TimeSeriesInformation -except (SyntaxError, ImportError): - from ._models import Baseline # type: ignore - from ._models import BaselineMetadataValue # type: ignore - from ._models import BaselineResponse # type: ignore - from ._models import CalculateBaselineResponse # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import LocalizableString # type: ignore - from ._models import TimeSeriesInformation # type: ignore +from ._models_py3 import Baseline +from ._models_py3 import BaselineMetadataValue +from ._models_py3 import BaselineResponse +from ._models_py3 import CalculateBaselineResponse +from ._models_py3 import ErrorResponse +from ._models_py3 import LocalizableString +from ._models_py3 import TimeSeriesInformation + from ._monitor_management_client_enums import ( ResultType, 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 deleted file mode 100644 index 7cdac8f92b2a..000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/models/_models.py +++ /dev/null @@ -1,257 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class Baseline(msrest.serialization.Model): - """The baseline values for a single sensitivity value. - - All required parameters must be populated in order to send to Azure. - - :param 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] - """ - - _validation = { - 'sensitivity': {'required': True}, - 'low_thresholds': {'required': True}, - 'high_thresholds': {'required': True}, - } - - _attribute_map = { - 'sensitivity': {'key': 'sensitivity', 'type': 'str'}, - 'low_thresholds': {'key': 'lowThresholds', 'type': '[float]'}, - 'high_thresholds': {'key': 'highThresholds', 'type': '[float]'}, - 'timestamps': {'key': 'timestamps', 'type': '[iso-8601]'}, - } - - def __init__( - self, - **kwargs - ): - super(Baseline, self).__init__(**kwargs) - self.sensitivity = kwargs['sensitivity'] - self.low_thresholds = kwargs['low_thresholds'] - self.high_thresholds = kwargs['high_thresholds'] - self.timestamps = kwargs.get('timestamps', None) - - -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 - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'LocalizableString'}, - 'value': {'key': 'value', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(BaselineMetadataValue, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.value = kwargs.get('value', None) - - -class BaselineResponse(msrest.serialization.Model): - """The response to a baseline query. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: the metric baseline Id. - :vartype id: str - :ivar type: the resource type of the baseline resource. - :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 - 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: - list[~$(python-base-namespace).v2017_11_01_preview.models.BaselineMetadataValue] - """ - - _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'name': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'LocalizableString'}, - 'timespan': {'key': 'properties.timespan', 'type': 'str'}, - 'interval': {'key': 'properties.interval', 'type': 'duration'}, - 'aggregation': {'key': 'properties.aggregation', 'type': 'str'}, - 'timestamps': {'key': 'properties.timestamps', 'type': '[iso-8601]'}, - 'baseline': {'key': 'properties.baseline', 'type': '[Baseline]'}, - 'metadata': {'key': 'properties.metadata', 'type': '[BaselineMetadataValue]'}, - } - - def __init__( - self, - **kwargs - ): - super(BaselineResponse, self).__init__(**kwargs) - self.id = None - self.type = None - self.name = None - self.timespan = kwargs.get('timespan', None) - self.interval = kwargs.get('interval', None) - self.aggregation = kwargs.get('aggregation', None) - self.timestamps = kwargs.get('timestamps', None) - self.baseline = kwargs.get('baseline', None) - self.metadata = kwargs.get('metadata', None) - - -class CalculateBaselineResponse(msrest.serialization.Model): - """The response to a calculate baseline call. - - 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] - """ - - _validation = { - 'type': {'required': True}, - 'baseline': {'required': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'timestamps': {'key': 'timestamps', 'type': '[iso-8601]'}, - 'baseline': {'key': 'baseline', 'type': '[Baseline]'}, - } - - def __init__( - self, - **kwargs - ): - super(CalculateBaselineResponse, self).__init__(**kwargs) - self.type = kwargs['type'] - self.timestamps = kwargs.get('timestamps', None) - self.baseline = kwargs['baseline'] - - -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 - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - - -class LocalizableString(msrest.serialization.Model): - """The localizable string class. - - 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 - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LocalizableString, self).__init__(**kwargs) - self.value = kwargs['value'] - self.localized_value = kwargs.get('localized_value', None) - - -class TimeSeriesInformation(msrest.serialization.Model): - """The time series info needed for calculating the baseline. - - 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] - """ - - _validation = { - 'sensitivities': {'required': True}, - 'values': {'required': True}, - } - - _attribute_map = { - 'sensitivities': {'key': 'sensitivities', 'type': '[str]'}, - 'values': {'key': 'values', 'type': '[float]'}, - 'timestamps': {'key': 'timestamps', 'type': '[iso-8601]'}, - } - - def __init__( - self, - **kwargs - ): - super(TimeSeriesInformation, self).__init__(**kwargs) - self.sensitivities = kwargs['sensitivities'] - self.values = kwargs['values'] - self.timestamps = kwargs.get('timestamps', None) 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 343075e3c0dc..ddf9d5c536cf 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 6b954160c37c..84dc084ea9ed 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 d3198ee56882..872dfcde5bca 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,22 +6,114 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime -from typing import TYPE_CHECKING +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 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 +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +def build_get_request( + resource_uri: str, + metric_name: str, + *, + timespan: Optional[str] = None, + interval: Optional[datetime.timedelta] = None, + aggregation: Optional[str] = None, + sensitivities: Optional[str] = None, + result_type: Optional[Union[str, "_models.ResultType"]] = None, + **kwargs: Any +) -> HttpRequest: + 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: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) class MetricBaselineOperations(object): """MetricBaselineOperations operations. @@ -45,18 +137,18 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_uri, # type: str - metric_name, # type: str - timespan=None, # type: Optional[str] - interval=None, # type: Optional[datetime.timedelta] - aggregation=None, # type: Optional[str] - sensitivities=None, # type: Optional[str] - result_type=None, # type: Optional[Union[str, "_models.ResultType"]] - **kwargs # type: Any - ): - # type: (...) -> "_models.BaselineResponse" + resource_uri: str, + metric_name: str, + timespan: Optional[str] = None, + interval: Optional[datetime.timedelta] = None, + aggregation: Optional[str] = None, + sensitivities: Optional[str] = None, + result_type: Optional[Union[str, "_models.ResultType"]] = None, + **kwargs: Any + ) -> "_models.BaselineResponse": """**Gets the baseline values for a specific metric**. :param resource_uri: The identifier of the resource. It has the following structure: @@ -88,42 +180,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,15 +209,17 @@ 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 - time_series_information, # type: "_models.TimeSeriesInformation" - **kwargs # type: Any - ): - # type: (...) -> "_models.CalculateBaselineResponse" + resource_uri: str, + time_series_information: "_models.TimeSeriesInformation", + **kwargs: Any + ) -> "_models.CalculateBaselineResponse": """**Lists the baseline values for a resource**. :param resource_uri: The identifier of the resource. It has the following structure: @@ -150,7 +229,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 +241,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] + + _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 = 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 +269,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 d82479510092..ec9090a57df0 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 a1191ae931c4..e6aeff663d71 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 @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -33,13 +31,12 @@ class MonitorManagementClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + **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" @@ -62,4 +59,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 d10acf8b52db..18bc077c7cd8 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 fde0624d9475..c477802680d4 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,74 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -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 . 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 import TokenCredential -class MonitorManagementClient(object): +class MonitorManagementClient: """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] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MonitorManagementClientConfiguration(credential, **kwargs) + credential: "TokenCredential", + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + 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: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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 000000000000..74e48ecd07cf --- /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 000000000000..138f663c53a4 --- /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 cac9f5d10f8b..e5754a47ce68 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 96ce9b45c05b..4eba911f1c6e 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 8278395d0e83..cf4b6135bb51 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 174248807f3e..da77ac77c9fa 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 000000000000..74e48ecd07cf --- /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 0db0d9d75a4e..f58ee93aa86d 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/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/__init__.py index 243ba1098bad..ba000c367032 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/__init__.py @@ -6,16 +6,11 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import ErrorResponse - from ._models_py3 import MetricNamespace - from ._models_py3 import MetricNamespaceCollection - from ._models_py3 import MetricNamespaceName -except (SyntaxError, ImportError): - from ._models import ErrorResponse # type: ignore - from ._models import MetricNamespace # type: ignore - from ._models import MetricNamespaceCollection # type: ignore - from ._models import MetricNamespaceName # type: ignore +from ._models_py3 import ErrorResponse +from ._models_py3 import MetricNamespace +from ._models_py3 import MetricNamespaceCollection +from ._models_py3 import MetricNamespaceName + from ._monitor_management_client_enums import ( NamespaceClassification, 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 deleted file mode 100644 index 4e9ee9c2fe29..000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/_models.py +++ /dev/null @@ -1,113 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class 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 - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - - -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 - ~$(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 - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'classification': {'key': 'classification', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'MetricNamespaceName'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricNamespace, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.type = kwargs.get('type', None) - self.name = kwargs.get('name', None) - self.classification = kwargs.get('classification', None) - self.properties = kwargs.get('properties', None) - - -class MetricNamespaceCollection(msrest.serialization.Model): - """Represents collection of metric namespaces. - - 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] - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[MetricNamespace]'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricNamespaceCollection, self).__init__(**kwargs) - self.value = kwargs['value'] - - -class MetricNamespaceName(msrest.serialization.Model): - """The fully qualified metric namespace name. - - :param metric_namespace_name: The metric namespace name. - :type metric_namespace_name: str - """ - - _attribute_map = { - 'metric_namespace_name': {'key': 'metricNamespaceName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - 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 e31361dc0b99..92439e54e50b 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 8df48e53f31d..903fea1fdcca 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 97505136a476..44f3cf0e9159 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,23 +5,60 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + resource_uri: str, + *, + start_time: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + 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 + ) class MetricNamespacesOperations(object): """MetricNamespacesOperations operations. @@ -45,13 +82,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_uri, # type: str - start_time=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.MetricNamespaceCollection"] + resource_uri: str, + start_time: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.MetricNamespaceCollection"]: """Lists the metric namespaces for the resource. :param resource_uri: The identifier of the resource. @@ -60,8 +97,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 +108,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 +145,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 d82479510092..ec9090a57df0 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 2a02767f7a67..140c72aa1b0c 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 @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -33,13 +31,12 @@ class MonitorManagementClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + **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" @@ -62,4 +59,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 213c25c681a7..99fa18757f37 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 5059198cc5e5..a539766bbfaa 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,77 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import 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 - -class MonitorManagementClient(object): +class MonitorManagementClient: """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] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MonitorManagementClientConfiguration(credential, **kwargs) + credential: "TokenCredential", + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + 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: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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 000000000000..74e48ecd07cf --- /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 000000000000..138f663c53a4 --- /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 cac9f5d10f8b..e5754a47ce68 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 96ce9b45c05b..4eba911f1c6e 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 693bca4bcf25..cffdc2d34b31 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 b1fe92be01a3..11c57b3a714a 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 000000000000..74e48ecd07cf --- /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 0345cdbc7dcb..fda3b5ccdbe2 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 dca74acb8dcf..bc650c2c02f1 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/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/__init__.py index 7e8c48f6ea43..cb58f8a05df3 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/__init__.py @@ -6,28 +6,17 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import ErrorResponse - from ._models_py3 import LocalizableString - from ._models_py3 import MetadataValue - from ._models_py3 import Metric - from ._models_py3 import MetricAvailability - from ._models_py3 import MetricDefinition - from ._models_py3 import MetricDefinitionCollection - from ._models_py3 import MetricValue - from ._models_py3 import Response - from ._models_py3 import TimeSeriesElement -except (SyntaxError, ImportError): - from ._models import ErrorResponse # type: ignore - from ._models import LocalizableString # type: ignore - from ._models import MetadataValue # type: ignore - from ._models import Metric # type: ignore - from ._models import MetricAvailability # type: ignore - from ._models import MetricDefinition # type: ignore - from ._models import MetricDefinitionCollection # type: ignore - from ._models import MetricValue # type: ignore - from ._models import Response # type: ignore - from ._models import TimeSeriesElement # type: ignore +from ._models_py3 import ErrorResponse +from ._models_py3 import LocalizableString +from ._models_py3 import MetadataValue +from ._models_py3 import Metric +from ._models_py3 import MetricAvailability +from ._models_py3 import MetricDefinition +from ._models_py3 import MetricDefinitionCollection +from ._models_py3 import MetricValue +from ._models_py3 import Response +from ._models_py3 import TimeSeriesElement + from ._monitor_management_client_enums import ( AggregationType, 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 deleted file mode 100644 index f474ab6343f0..000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/_models.py +++ /dev/null @@ -1,393 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class 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 - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - - -class LocalizableString(msrest.serialization.Model): - """The localizable string class. - - 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 - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LocalizableString, self).__init__(**kwargs) - self.value = kwargs['value'] - self.localized_value = kwargs.get('localized_value', None) - - -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 - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'LocalizableString'}, - 'value': {'key': 'value', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MetadataValue, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.value = kwargs.get('value', None) - - -class Metric(msrest.serialization.Model): - """The result data of a query. - - 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 - 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", - "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] - """ - - _validation = { - 'id': {'required': True}, - 'type': {'required': True}, - 'name': {'required': True}, - 'unit': {'required': True}, - 'timeseries': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'LocalizableString'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'error_code': {'key': 'errorCode', 'type': 'str'}, - 'error_message': {'key': 'errorMessage', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'timeseries': {'key': 'timeseries', 'type': '[TimeSeriesElement]'}, - } - - def __init__( - self, - **kwargs - ): - super(Metric, self).__init__(**kwargs) - self.id = kwargs['id'] - self.type = kwargs['type'] - self.name = kwargs['name'] - self.display_description = kwargs.get('display_description', None) - self.error_code = kwargs.get('error_code', None) - self.error_message = kwargs.get('error_message', None) - self.unit = kwargs['unit'] - self.timeseries = kwargs['timeseries'] - - -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 - 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 - a duration 'PT1M', 'P1D', etc. - :type retention: ~datetime.timedelta - """ - - _attribute_map = { - 'time_grain': {'key': 'timeGrain', 'type': 'duration'}, - 'retention': {'key': 'retention', 'type': 'duration'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricAvailability, self).__init__(**kwargs) - self.time_grain = kwargs.get('time_grain', None) - self.retention = kwargs.get('retention', None) - - -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", - "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", - "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 - values for display. Possible values include: "None", "Average", "Count", "Minimum", "Maximum", - "Total". - :type 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 - ~$(python-base-namespace).v2018_01_01.models.AggregationType] - :param metric_availabilities: the collection of what aggregation intervals are available to be - queried. - :type 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 - string. - :type dimensions: list[~$(python-base-namespace).v2018_01_01.models.LocalizableString] - """ - - _attribute_map = { - 'is_dimension_required': {'key': 'isDimensionRequired', 'type': 'bool'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'namespace': {'key': 'namespace', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'LocalizableString'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'category': {'key': 'category', 'type': 'str'}, - 'metric_class': {'key': 'metricClass', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'primary_aggregation_type': {'key': 'primaryAggregationType', 'type': 'str'}, - 'supported_aggregation_types': {'key': 'supportedAggregationTypes', 'type': '[str]'}, - 'metric_availabilities': {'key': 'metricAvailabilities', 'type': '[MetricAvailability]'}, - 'id': {'key': 'id', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[LocalizableString]'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricDefinition, self).__init__(**kwargs) - self.is_dimension_required = kwargs.get('is_dimension_required', None) - self.resource_id = kwargs.get('resource_id', None) - self.namespace = kwargs.get('namespace', None) - self.name = kwargs.get('name', None) - self.display_description = kwargs.get('display_description', None) - self.category = kwargs.get('category', None) - self.metric_class = kwargs.get('metric_class', None) - self.unit = kwargs.get('unit', None) - self.primary_aggregation_type = kwargs.get('primary_aggregation_type', None) - self.supported_aggregation_types = kwargs.get('supported_aggregation_types', None) - self.metric_availabilities = kwargs.get('metric_availabilities', None) - self.id = kwargs.get('id', None) - self.dimensions = kwargs.get('dimensions', None) - - -class MetricDefinitionCollection(msrest.serialization.Model): - """Represents collection of metric definitions. - - 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] - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[MetricDefinition]'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricDefinitionCollection, self).__init__(**kwargs) - self.value = kwargs['value'] - - -class MetricValue(msrest.serialization.Model): - """Represents a metric value. - - 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 - values that contributed to the average value. - :type count: float - """ - - _validation = { - 'time_stamp': {'required': True}, - } - - _attribute_map = { - 'time_stamp': {'key': 'timeStamp', 'type': 'iso-8601'}, - 'average': {'key': 'average', 'type': 'float'}, - 'minimum': {'key': 'minimum', 'type': 'float'}, - 'maximum': {'key': 'maximum', 'type': 'float'}, - 'total': {'key': 'total', 'type': 'float'}, - 'count': {'key': 'count', 'type': 'float'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricValue, self).__init__(**kwargs) - self.time_stamp = kwargs['time_stamp'] - self.average = kwargs.get('average', None) - self.minimum = kwargs.get('minimum', None) - self.maximum = kwargs.get('maximum', None) - self.total = kwargs.get('total', None) - self.count = kwargs.get('count', None) - - -class Response(msrest.serialization.Model): - """The response to a metrics query. - - 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 - 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] - """ - - _validation = { - 'cost': {'minimum': 0}, - 'timespan': {'required': True}, - 'value': {'required': True}, - } - - _attribute_map = { - 'cost': {'key': 'cost', 'type': 'int'}, - 'timespan': {'key': 'timespan', 'type': 'str'}, - 'interval': {'key': 'interval', 'type': 'duration'}, - 'namespace': {'key': 'namespace', 'type': 'str'}, - 'resourceregion': {'key': 'resourceregion', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[Metric]'}, - } - - def __init__( - self, - **kwargs - ): - super(Response, self).__init__(**kwargs) - self.cost = kwargs.get('cost', None) - self.timespan = kwargs['timespan'] - self.interval = kwargs.get('interval', None) - self.namespace = kwargs.get('namespace', None) - self.resourceregion = kwargs.get('resourceregion', None) - self.value = kwargs['value'] - - -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] - """ - - _attribute_map = { - 'metadatavalues': {'key': 'metadatavalues', 'type': '[MetadataValue]'}, - 'data': {'key': 'data', 'type': '[MetricValue]'}, - } - - def __init__( - self, - **kwargs - ): - 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 d82c93e35b59..f7a0b02333a9 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 6f8d86605f13..fd09dbefdcc6 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 c3c1565f29c7..d4fbf7397d34 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,23 +5,60 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + resource_uri: str, + *, + metricnamespace: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + 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 + ) class MetricDefinitionsOperations(object): """MetricDefinitionsOperations operations. @@ -45,13 +82,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_uri, # type: str - metricnamespace=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.MetricDefinitionCollection"] + resource_uri: str, + metricnamespace: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.MetricDefinitionCollection"]: """Lists the metric definitions for the resource. :param resource_uri: The identifier of the resource. @@ -59,8 +96,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 +107,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 +144,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 5f9c37f40680..526a3d88304c 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,22 +6,83 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime -from typing import TYPE_CHECKING +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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + resource_uri: str, + *, + timespan: Optional[str] = None, + interval: Optional[datetime.timedelta] = None, + metricnames: Optional[str] = None, + aggregation: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + filter: Optional[str] = None, + result_type: Optional[Union[str, "_models.ResultType"]] = None, + metricnamespace: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + 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 + ) class MetricsOperations(object): """MetricsOperations operations. @@ -45,21 +106,21 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_uri, # type: str - timespan=None, # type: Optional[str] - interval=None, # type: Optional[datetime.timedelta] - metricnames=None, # type: Optional[str] - aggregation=None, # type: Optional[str] - top=None, # type: Optional[int] - orderby=None, # type: Optional[str] - filter=None, # type: Optional[str] - result_type=None, # type: Optional[Union[str, "_models.ResultType"]] - metricnamespace=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.Response" + resource_uri: str, + timespan: Optional[str] = None, + interval: Optional[datetime.timedelta] = None, + metricnames: Optional[str] = None, + aggregation: Optional[str] = None, + top: Optional[int] = None, + orderby: Optional[str] = None, + filter: Optional[str] = None, + result_type: Optional[Union[str, "_models.ResultType"]] = None, + metricnamespace: Optional[str] = None, + **kwargs: Any + ) -> "_models.Response": """**Lists the metric values for a resource**. :param resource_uri: The identifier of the resource. @@ -111,49 +172,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 +204,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 d82479510092..ec9090a57df0 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 779b6a13b7c4..02f3bff47a57 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 @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class MonitorManagementClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(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 +65,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 72ef172f9306..29e4460a8b75 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 bdf4e77f7ef0..0096c6fd0b18 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,26 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import 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 - -class MonitorManagementClient(object): +class MonitorManagementClient: """Monitor Management Client. :ivar action_groups: ActionGroupsOperations operations @@ -33,56 +29,60 @@ 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] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + 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: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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 000000000000..74e48ecd07cf --- /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 000000000000..138f663c53a4 --- /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 cac9f5d10f8b..e5754a47ce68 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 96ce9b45c05b..4eba911f1c6e 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 aa202fc38ef3..f68f113b2fde 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 c4d3e8ba5c32..42cd3189dd06 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 000000000000..74e48ecd07cf --- /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 9f3045ddf232..87b98768d8b0 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 96cb5971700c..6b4ff7fc1c34 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 0c216dfd6653..8be671ebb385 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/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/__init__.py index 6feb745bd333..83660d376814 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/__init__.py @@ -6,70 +6,38 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import ActionGroupList - from ._models_py3 import ActionGroupPatchBody - from ._models_py3 import ActionGroupResource - from ._models_py3 import AutomationRunbookReceiver - from ._models_py3 import AzureAppPushReceiver - from ._models_py3 import AzureFunctionReceiver - from ._models_py3 import DynamicMetricCriteria - from ._models_py3 import DynamicThresholdFailingPeriods - from ._models_py3 import EmailReceiver - from ._models_py3 import EnableRequest - from ._models_py3 import ErrorResponse - from ._models_py3 import ItsmReceiver - from ._models_py3 import LogicAppReceiver - from ._models_py3 import MetricAlertAction - from ._models_py3 import MetricAlertCriteria - from ._models_py3 import MetricAlertMultipleResourceMultipleMetricCriteria - from ._models_py3 import MetricAlertResource - from ._models_py3 import MetricAlertResourceCollection - from ._models_py3 import MetricAlertResourcePatch - from ._models_py3 import MetricAlertSingleResourceMultipleMetricCriteria - from ._models_py3 import MetricAlertStatus - from ._models_py3 import MetricAlertStatusCollection - from ._models_py3 import MetricAlertStatusProperties - from ._models_py3 import MetricCriteria - from ._models_py3 import MetricDimension - from ._models_py3 import MultiMetricCriteria - from ._models_py3 import Resource - from ._models_py3 import SmsReceiver - from ._models_py3 import VoiceReceiver - from ._models_py3 import WebhookReceiver - from ._models_py3 import WebtestLocationAvailabilityCriteria -except (SyntaxError, ImportError): - from ._models import ActionGroupList # type: ignore - from ._models import ActionGroupPatchBody # type: ignore - from ._models import ActionGroupResource # type: ignore - from ._models import AutomationRunbookReceiver # type: ignore - from ._models import AzureAppPushReceiver # type: ignore - from ._models import AzureFunctionReceiver # type: ignore - from ._models import DynamicMetricCriteria # type: ignore - from ._models import DynamicThresholdFailingPeriods # type: ignore - from ._models import EmailReceiver # type: ignore - from ._models import EnableRequest # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import ItsmReceiver # type: ignore - from ._models import LogicAppReceiver # type: ignore - from ._models import MetricAlertAction # type: ignore - from ._models import MetricAlertCriteria # type: ignore - from ._models import MetricAlertMultipleResourceMultipleMetricCriteria # type: ignore - from ._models import MetricAlertResource # type: ignore - from ._models import MetricAlertResourceCollection # type: ignore - from ._models import MetricAlertResourcePatch # type: ignore - from ._models import MetricAlertSingleResourceMultipleMetricCriteria # type: ignore - from ._models import MetricAlertStatus # type: ignore - from ._models import MetricAlertStatusCollection # type: ignore - from ._models import MetricAlertStatusProperties # type: ignore - from ._models import MetricCriteria # type: ignore - from ._models import MetricDimension # type: ignore - from ._models import MultiMetricCriteria # type: ignore - from ._models import Resource # type: ignore - from ._models import SmsReceiver # type: ignore - from ._models import VoiceReceiver # type: ignore - from ._models import WebhookReceiver # type: ignore - from ._models import WebtestLocationAvailabilityCriteria # type: ignore +from ._models_py3 import ActionGroupList +from ._models_py3 import ActionGroupPatchBody +from ._models_py3 import ActionGroupResource +from ._models_py3 import AutomationRunbookReceiver +from ._models_py3 import AzureAppPushReceiver +from ._models_py3 import AzureFunctionReceiver +from ._models_py3 import DynamicMetricCriteria +from ._models_py3 import DynamicThresholdFailingPeriods +from ._models_py3 import EmailReceiver +from ._models_py3 import EnableRequest +from ._models_py3 import ErrorResponse +from ._models_py3 import ItsmReceiver +from ._models_py3 import LogicAppReceiver +from ._models_py3 import MetricAlertAction +from ._models_py3 import MetricAlertCriteria +from ._models_py3 import MetricAlertMultipleResourceMultipleMetricCriteria +from ._models_py3 import MetricAlertResource +from ._models_py3 import MetricAlertResourceCollection +from ._models_py3 import MetricAlertResourcePatch +from ._models_py3 import MetricAlertSingleResourceMultipleMetricCriteria +from ._models_py3 import MetricAlertStatus +from ._models_py3 import MetricAlertStatusCollection +from ._models_py3 import MetricAlertStatusProperties +from ._models_py3 import MetricCriteria +from ._models_py3 import MetricDimension +from ._models_py3 import MultiMetricCriteria +from ._models_py3 import Resource +from ._models_py3 import SmsReceiver +from ._models_py3 import VoiceReceiver +from ._models_py3 import WebhookReceiver +from ._models_py3 import WebtestLocationAvailabilityCriteria + from ._monitor_management_client_enums import ( AggregationTypeEnum, 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 deleted file mode 100644 index bd481af12a40..000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/_models.py +++ /dev/null @@ -1,1356 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class 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 - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ActionGroupResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ActionGroupList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -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 - enabled, then none of its actions will be activated. - :type enabled: bool - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(ActionGroupPatchBody, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.enabled = kwargs.get('enabled', True) - - -class Resource(msrest.serialization.Model): - """An azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :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] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - - -class ActionGroupResource(Resource): - """An action group resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :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 - 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: - list[~$(python-base-namespace).v2018_03_01.models.AzureAppPushReceiver] - :param automation_runbook_receivers: The list of AutomationRunbook receivers that are part of - this action group. - :type 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 - action group. - :type azure_function_receivers: - list[~$(python-base-namespace).v2018_03_01.models.AzureFunctionReceiver] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'group_short_name': {'max_length': 12, 'min_length': 0}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'group_short_name': {'key': 'properties.groupShortName', 'type': 'str'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - 'email_receivers': {'key': 'properties.emailReceivers', 'type': '[EmailReceiver]'}, - 'sms_receivers': {'key': 'properties.smsReceivers', 'type': '[SmsReceiver]'}, - 'webhook_receivers': {'key': 'properties.webhookReceivers', 'type': '[WebhookReceiver]'}, - 'itsm_receivers': {'key': 'properties.itsmReceivers', 'type': '[ItsmReceiver]'}, - 'azure_app_push_receivers': {'key': 'properties.azureAppPushReceivers', 'type': '[AzureAppPushReceiver]'}, - 'automation_runbook_receivers': {'key': 'properties.automationRunbookReceivers', 'type': '[AutomationRunbookReceiver]'}, - 'voice_receivers': {'key': 'properties.voiceReceivers', 'type': '[VoiceReceiver]'}, - 'logic_app_receivers': {'key': 'properties.logicAppReceivers', 'type': '[LogicAppReceiver]'}, - 'azure_function_receivers': {'key': 'properties.azureFunctionReceivers', 'type': '[AzureFunctionReceiver]'}, - } - - def __init__( - self, - **kwargs - ): - super(ActionGroupResource, self).__init__(**kwargs) - self.group_short_name = kwargs.get('group_short_name', None) - self.enabled = kwargs.get('enabled', True) - self.email_receivers = kwargs.get('email_receivers', None) - self.sms_receivers = kwargs.get('sms_receivers', None) - self.webhook_receivers = kwargs.get('webhook_receivers', None) - self.itsm_receivers = kwargs.get('itsm_receivers', None) - self.azure_app_push_receivers = kwargs.get('azure_app_push_receivers', None) - self.automation_runbook_receivers = kwargs.get('automation_runbook_receivers', None) - self.voice_receivers = kwargs.get('voice_receivers', None) - self.logic_app_receivers = kwargs.get('logic_app_receivers', None) - self.azure_function_receivers = kwargs.get('azure_function_receivers', None) - - -class AutomationRunbookReceiver(msrest.serialization.Model): - """The Azure Automation Runbook notification receiver. - - 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 - """ - - _validation = { - 'automation_account_id': {'required': True}, - 'runbook_name': {'required': True}, - 'webhook_resource_id': {'required': True}, - 'is_global_runbook': {'required': True}, - } - - _attribute_map = { - 'automation_account_id': {'key': 'automationAccountId', 'type': 'str'}, - 'runbook_name': {'key': 'runbookName', 'type': 'str'}, - 'webhook_resource_id': {'key': 'webhookResourceId', 'type': 'str'}, - 'is_global_runbook': {'key': 'isGlobalRunbook', 'type': 'bool'}, - 'name': {'key': 'name', 'type': 'str'}, - 'service_uri': {'key': 'serviceUri', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AutomationRunbookReceiver, self).__init__(**kwargs) - self.automation_account_id = kwargs['automation_account_id'] - self.runbook_name = kwargs['runbook_name'] - self.webhook_resource_id = kwargs['webhook_resource_id'] - self.is_global_runbook = kwargs['is_global_runbook'] - self.name = kwargs.get('name', None) - self.service_uri = kwargs.get('service_uri', None) - - -class AzureAppPushReceiver(msrest.serialization.Model): - """The Azure mobile App push notification receiver. - - 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 - 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 - """ - - _validation = { - 'name': {'required': True}, - 'email_address': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'email_address': {'key': 'emailAddress', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureAppPushReceiver, self).__init__(**kwargs) - self.name = kwargs['name'] - self.email_address = kwargs['email_address'] - - -class AzureFunctionReceiver(msrest.serialization.Model): - """An azure function receiver. - - 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 - 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 - """ - - _validation = { - 'name': {'required': True}, - 'function_app_resource_id': {'required': True}, - 'function_name': {'required': True}, - 'http_trigger_url': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'function_app_resource_id': {'key': 'functionAppResourceId', 'type': 'str'}, - 'function_name': {'key': 'functionName', 'type': 'str'}, - 'http_trigger_url': {'key': 'httpTriggerUrl', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureFunctionReceiver, self).__init__(**kwargs) - self.name = kwargs['name'] - self.function_app_resource_id = kwargs['function_app_resource_id'] - self.function_name = kwargs['function_name'] - self.http_trigger_url = kwargs['http_trigger_url'] - - -class MultiMetricCriteria(msrest.serialization.Model): - """The types of conditions for a multi resource alert. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: DynamicMetricCriteria, MetricCriteria. - - All required parameters must be populated in order to send to Azure. - - :param 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 - emitted, by causing the metric validation to be skipped. - :type skip_metric_validation: bool - """ - - _validation = { - 'criterion_type': {'required': True}, - 'name': {'required': True}, - 'metric_name': {'required': True}, - 'time_aggregation': {'required': True}, - } - - _attribute_map = { - 'additional_properties': {'key': '', 'type': '{object}'}, - 'criterion_type': {'key': 'criterionType', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'metric_name': {'key': 'metricName', 'type': 'str'}, - 'metric_namespace': {'key': 'metricNamespace', 'type': 'str'}, - 'time_aggregation': {'key': 'timeAggregation', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[MetricDimension]'}, - 'skip_metric_validation': {'key': 'skipMetricValidation', 'type': 'bool'}, - } - - _subtype_map = { - 'criterion_type': {'DynamicThresholdCriterion': 'DynamicMetricCriteria', 'StaticThresholdCriterion': 'MetricCriteria'} - } - - def __init__( - self, - **kwargs - ): - super(MultiMetricCriteria, self).__init__(**kwargs) - self.additional_properties = kwargs.get('additional_properties', None) - self.criterion_type = 'MultiMetricCriteria' # type: str - self.name = kwargs['name'] - self.metric_name = kwargs['metric_name'] - self.metric_namespace = kwargs.get('metric_namespace', None) - self.time_aggregation = kwargs['time_aggregation'] - self.dimensions = kwargs.get('dimensions', None) - self.skip_metric_validation = kwargs.get('skip_metric_validation', None) - - -class DynamicMetricCriteria(MultiMetricCriteria): - """Criterion for dynamic threshold. - - All required parameters must be populated in order to send to Azure. - - :param 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 - 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. - 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 - will affect how tight the threshold is to the metric series pattern. Possible values include: - "Low", "Medium", "High". - :type 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 - lookback time window required to raise an alert. - :type 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 - metric historical data and calculate the dynamic thresholds (in ISO8601 format). - :type ignore_data_before: ~datetime.datetime - """ - - _validation = { - 'criterion_type': {'required': True}, - 'name': {'required': True}, - 'metric_name': {'required': True}, - 'time_aggregation': {'required': True}, - 'operator': {'required': True}, - 'alert_sensitivity': {'required': True}, - 'failing_periods': {'required': True}, - } - - _attribute_map = { - 'additional_properties': {'key': '', 'type': '{object}'}, - 'criterion_type': {'key': 'criterionType', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'metric_name': {'key': 'metricName', 'type': 'str'}, - 'metric_namespace': {'key': 'metricNamespace', 'type': 'str'}, - 'time_aggregation': {'key': 'timeAggregation', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[MetricDimension]'}, - 'skip_metric_validation': {'key': 'skipMetricValidation', 'type': 'bool'}, - 'operator': {'key': 'operator', 'type': 'str'}, - 'alert_sensitivity': {'key': 'alertSensitivity', 'type': 'str'}, - 'failing_periods': {'key': 'failingPeriods', 'type': 'DynamicThresholdFailingPeriods'}, - 'ignore_data_before': {'key': 'ignoreDataBefore', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(DynamicMetricCriteria, self).__init__(**kwargs) - self.criterion_type = 'DynamicThresholdCriterion' # type: str - self.operator = kwargs['operator'] - self.alert_sensitivity = kwargs['alert_sensitivity'] - self.failing_periods = kwargs['failing_periods'] - self.ignore_data_before = kwargs.get('ignore_data_before', None) - - -class DynamicThresholdFailingPeriods(msrest.serialization.Model): - """The minimum number of violations required within the selected lookback time window required to raise an alert. - - 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 - 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. - Should be smaller or equal to numberOfEvaluationPeriods. - :type min_failing_periods_to_alert: float - """ - - _validation = { - 'number_of_evaluation_periods': {'required': True}, - 'min_failing_periods_to_alert': {'required': True}, - } - - _attribute_map = { - 'number_of_evaluation_periods': {'key': 'numberOfEvaluationPeriods', 'type': 'float'}, - 'min_failing_periods_to_alert': {'key': 'minFailingPeriodsToAlert', 'type': 'float'}, - } - - def __init__( - self, - **kwargs - ): - 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'] - - -class EmailReceiver(msrest.serialization.Model): - """An email receiver. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param 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 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 - """ - - _validation = { - 'name': {'required': True}, - 'email_address': {'required': True}, - 'status': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'email_address': {'key': 'emailAddress', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EmailReceiver, self).__init__(**kwargs) - self.name = kwargs['name'] - self.email_address = kwargs['email_address'] - self.status = None - - -class EnableRequest(msrest.serialization.Model): - """Describes a receiver that should be resubscribed. - - 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 - """ - - _validation = { - 'receiver_name': {'required': True}, - } - - _attribute_map = { - 'receiver_name': {'key': 'receiverName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EnableRequest, self).__init__(**kwargs) - self.receiver_name = kwargs['receiver_name'] - - -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 - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - - -class ItsmReceiver(msrest.serialization.Model): - """An Itsm receiver. - - 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 - 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 - in above workspace. - :type connection_id: str - :param 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 - values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. - :type region: str - """ - - _validation = { - 'name': {'required': True}, - 'workspace_id': {'required': True}, - 'connection_id': {'required': True}, - 'ticket_configuration': {'required': True}, - 'region': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'workspace_id': {'key': 'workspaceId', 'type': 'str'}, - 'connection_id': {'key': 'connectionId', 'type': 'str'}, - 'ticket_configuration': {'key': 'ticketConfiguration', 'type': 'str'}, - 'region': {'key': 'region', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ItsmReceiver, self).__init__(**kwargs) - self.name = kwargs['name'] - self.workspace_id = kwargs['workspace_id'] - self.connection_id = kwargs['connection_id'] - self.ticket_configuration = kwargs['ticket_configuration'] - self.region = kwargs['region'] - - -class LogicAppReceiver(msrest.serialization.Model): - """A logic app receiver. - - 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 - 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 - """ - - _validation = { - 'name': {'required': True}, - 'resource_id': {'required': True}, - 'callback_url': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'callback_url': {'key': 'callbackUrl', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LogicAppReceiver, self).__init__(**kwargs) - self.name = kwargs['name'] - self.resource_id = kwargs['resource_id'] - self.callback_url = kwargs['callback_url'] - - -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 - appended to the alert payload sent as input to the webhook. - :type web_hook_properties: dict[str, str] - """ - - _attribute_map = { - 'action_group_id': {'key': 'actionGroupId', 'type': 'str'}, - 'web_hook_properties': {'key': 'webHookProperties', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - 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) - - -class MetricAlertCriteria(msrest.serialization.Model): - """The rule criteria that defines the conditions of the alert rule. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: MetricAlertMultipleResourceMultipleMetricCriteria, MetricAlertSingleResourceMultipleMetricCriteria, WebtestLocationAvailabilityCriteria. - - All required parameters must be populated in order to send to Azure. - - :param 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", - "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", - "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria". - :type odata_type: str or ~$(python-base-namespace).v2018_03_01.models.Odatatype - """ - - _validation = { - 'odata_type': {'required': True}, - } - - _attribute_map = { - 'additional_properties': {'key': '', 'type': '{object}'}, - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - } - - _subtype_map = { - 'odata_type': {'Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria': 'MetricAlertMultipleResourceMultipleMetricCriteria', 'Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria': 'MetricAlertSingleResourceMultipleMetricCriteria', 'Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria': 'WebtestLocationAvailabilityCriteria'} - } - - def __init__( - self, - **kwargs - ): - super(MetricAlertCriteria, self).__init__(**kwargs) - self.additional_properties = kwargs.get('additional_properties', None) - self.odata_type = 'MetricAlertCriteria' # type: str - - -class MetricAlertMultipleResourceMultipleMetricCriteria(MetricAlertCriteria): - """Specifies the metric alert criteria for multiple resource that has multiple metric criteria. - - All required parameters must be populated in order to send to Azure. - - :param 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", - "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] - """ - - _validation = { - 'odata_type': {'required': True}, - } - - _attribute_map = { - 'additional_properties': {'key': '', 'type': '{object}'}, - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'all_of': {'key': 'allOf', 'type': '[MultiMetricCriteria]'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricAlertMultipleResourceMultipleMetricCriteria, self).__init__(**kwargs) - self.odata_type = 'Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria' # type: str - self.all_of = kwargs.get('all_of', None) - - -class MetricAlertResource(Resource): - """The metric alert resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :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 - 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 - 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 - 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 - 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 - 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. - The default is true. - :type auto_mitigate: bool - :param 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] - :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. - :vartype is_migrated: bool - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'severity': {'required': True}, - 'enabled': {'required': True}, - 'scopes': {'required': True}, - 'evaluation_frequency': {'required': True}, - 'window_size': {'required': True}, - 'criteria': {'required': True}, - 'last_updated_time': {'readonly': True}, - 'is_migrated': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'severity': {'key': 'properties.severity', 'type': 'int'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - 'scopes': {'key': 'properties.scopes', 'type': '[str]'}, - 'evaluation_frequency': {'key': 'properties.evaluationFrequency', 'type': 'duration'}, - 'window_size': {'key': 'properties.windowSize', 'type': 'duration'}, - 'target_resource_type': {'key': 'properties.targetResourceType', 'type': 'str'}, - 'target_resource_region': {'key': 'properties.targetResourceRegion', 'type': 'str'}, - 'criteria': {'key': 'properties.criteria', 'type': 'MetricAlertCriteria'}, - 'auto_mitigate': {'key': 'properties.autoMitigate', 'type': 'bool'}, - 'actions': {'key': 'properties.actions', 'type': '[MetricAlertAction]'}, - 'last_updated_time': {'key': 'properties.lastUpdatedTime', 'type': 'iso-8601'}, - 'is_migrated': {'key': 'properties.isMigrated', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricAlertResource, self).__init__(**kwargs) - self.description = kwargs.get('description', None) - self.severity = kwargs['severity'] - self.enabled = kwargs['enabled'] - self.scopes = kwargs['scopes'] - self.evaluation_frequency = kwargs['evaluation_frequency'] - self.window_size = kwargs['window_size'] - self.target_resource_type = kwargs.get('target_resource_type', None) - self.target_resource_region = kwargs.get('target_resource_region', None) - self.criteria = kwargs['criteria'] - self.auto_mitigate = kwargs.get('auto_mitigate', None) - self.actions = kwargs.get('actions', None) - self.last_updated_time = None - self.is_migrated = None - - -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] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[MetricAlertResource]'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricAlertResourceCollection, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class MetricAlertResourcePatch(msrest.serialization.Model): - """The metric alert resource for patch operations. - - 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 - 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 - duration format. - :type evaluation_frequency: ~datetime.timedelta - :param 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 - 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 - 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. - The default is true. - :type auto_mitigate: bool - :param 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] - :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. - :vartype is_migrated: bool - """ - - _validation = { - 'last_updated_time': {'readonly': True}, - 'is_migrated': {'readonly': True}, - } - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'severity': {'key': 'properties.severity', 'type': 'int'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - 'scopes': {'key': 'properties.scopes', 'type': '[str]'}, - 'evaluation_frequency': {'key': 'properties.evaluationFrequency', 'type': 'duration'}, - 'window_size': {'key': 'properties.windowSize', 'type': 'duration'}, - 'target_resource_type': {'key': 'properties.targetResourceType', 'type': 'str'}, - 'target_resource_region': {'key': 'properties.targetResourceRegion', 'type': 'str'}, - 'criteria': {'key': 'properties.criteria', 'type': 'MetricAlertCriteria'}, - 'auto_mitigate': {'key': 'properties.autoMitigate', 'type': 'bool'}, - 'actions': {'key': 'properties.actions', 'type': '[MetricAlertAction]'}, - 'last_updated_time': {'key': 'properties.lastUpdatedTime', 'type': 'iso-8601'}, - 'is_migrated': {'key': 'properties.isMigrated', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricAlertResourcePatch, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.description = kwargs.get('description', None) - self.severity = kwargs.get('severity', None) - self.enabled = kwargs.get('enabled', None) - self.scopes = kwargs.get('scopes', None) - self.evaluation_frequency = kwargs.get('evaluation_frequency', None) - self.window_size = kwargs.get('window_size', None) - self.target_resource_type = kwargs.get('target_resource_type', None) - self.target_resource_region = kwargs.get('target_resource_region', None) - self.criteria = kwargs.get('criteria', None) - self.auto_mitigate = kwargs.get('auto_mitigate', None) - self.actions = kwargs.get('actions', None) - self.last_updated_time = None - self.is_migrated = None - - -class MetricAlertSingleResourceMultipleMetricCriteria(MetricAlertCriteria): - """Specifies the metric alert criteria for a single resource that has multiple metric criteria. - - All required parameters must be populated in order to send to Azure. - - :param 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", - "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] - """ - - _validation = { - 'odata_type': {'required': True}, - } - - _attribute_map = { - 'additional_properties': {'key': '', 'type': '{object}'}, - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'all_of': {'key': 'allOf', 'type': '[MetricCriteria]'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricAlertSingleResourceMultipleMetricCriteria, self).__init__(**kwargs) - self.odata_type = 'Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria' # type: str - self.all_of = kwargs.get('all_of', None) - - -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 - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'MetricAlertStatusProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricAlertStatus, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.id = kwargs.get('id', None) - self.type = kwargs.get('type', None) - self.properties = kwargs.get('properties', None) - - -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] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[MetricAlertStatus]'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricAlertStatusCollection, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -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 - """ - - _attribute_map = { - 'dimensions': {'key': 'dimensions', 'type': '{str}'}, - 'status': {'key': 'status', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricAlertStatusProperties, self).__init__(**kwargs) - self.dimensions = kwargs.get('dimensions', None) - self.status = kwargs.get('status', None) - self.timestamp = kwargs.get('timestamp', None) - - -class MetricCriteria(MultiMetricCriteria): - """Criterion to filter metrics. - - All required parameters must be populated in order to send to Azure. - - :param 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 - emitted, by causing the metric validation to be skipped. - :type skip_metric_validation: bool - :param 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 - """ - - _validation = { - 'criterion_type': {'required': True}, - 'name': {'required': True}, - 'metric_name': {'required': True}, - 'time_aggregation': {'required': True}, - 'operator': {'required': True}, - 'threshold': {'required': True}, - } - - _attribute_map = { - 'additional_properties': {'key': '', 'type': '{object}'}, - 'criterion_type': {'key': 'criterionType', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'metric_name': {'key': 'metricName', 'type': 'str'}, - 'metric_namespace': {'key': 'metricNamespace', 'type': 'str'}, - 'time_aggregation': {'key': 'timeAggregation', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[MetricDimension]'}, - 'skip_metric_validation': {'key': 'skipMetricValidation', 'type': 'bool'}, - 'operator': {'key': 'operator', 'type': 'str'}, - 'threshold': {'key': 'threshold', 'type': 'float'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricCriteria, self).__init__(**kwargs) - self.criterion_type = 'StaticThresholdCriterion' # type: str - self.operator = kwargs['operator'] - self.threshold = kwargs['threshold'] - - -class MetricDimension(msrest.serialization.Model): - """Specifies a metric dimension. - - 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] - """ - - _validation = { - 'name': {'required': True}, - 'operator': {'required': True}, - 'values': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'operator': {'key': 'operator', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricDimension, self).__init__(**kwargs) - self.name = kwargs['name'] - self.operator = kwargs['operator'] - self.values = kwargs['values'] - - -class SmsReceiver(msrest.serialization.Model): - """An SMS receiver. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param 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 - :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 - """ - - _validation = { - 'name': {'required': True}, - 'country_code': {'required': True}, - 'phone_number': {'required': True}, - 'status': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'country_code': {'key': 'countryCode', 'type': 'str'}, - 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SmsReceiver, self).__init__(**kwargs) - self.name = kwargs['name'] - self.country_code = kwargs['country_code'] - self.phone_number = kwargs['phone_number'] - self.status = None - - -class VoiceReceiver(msrest.serialization.Model): - """A voice receiver. - - 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 - """ - - _validation = { - 'name': {'required': True}, - 'country_code': {'required': True}, - 'phone_number': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'country_code': {'key': 'countryCode', 'type': 'str'}, - 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(VoiceReceiver, self).__init__(**kwargs) - self.name = kwargs['name'] - self.country_code = kwargs['country_code'] - self.phone_number = kwargs['phone_number'] - - -class WebhookReceiver(msrest.serialization.Model): - """A webhook receiver. - - 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 - receivers within an action group. - :type name: str - :param service_uri: Required. The URI where webhooks should be sent. - :type service_uri: str - """ - - _validation = { - 'name': {'required': True}, - 'service_uri': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'service_uri': {'key': 'serviceUri', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WebhookReceiver, self).__init__(**kwargs) - self.name = kwargs['name'] - self.service_uri = kwargs['service_uri'] - - -class WebtestLocationAvailabilityCriteria(MetricAlertCriteria): - """Specifies the metric alert rule criteria for a web test resource. - - All required parameters must be populated in order to send to Azure. - - :param 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", - "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 - """ - - _validation = { - 'odata_type': {'required': True}, - 'web_test_id': {'required': True}, - 'component_id': {'required': True}, - 'failed_location_count': {'required': True}, - } - - _attribute_map = { - 'additional_properties': {'key': '', 'type': '{object}'}, - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'web_test_id': {'key': 'webTestId', 'type': 'str'}, - 'component_id': {'key': 'componentId', 'type': 'str'}, - 'failed_location_count': {'key': 'failedLocationCount', 'type': 'float'}, - } - - def __init__( - self, - **kwargs - ): - super(WebtestLocationAvailabilityCriteria, self).__init__(**kwargs) - self.odata_type = 'Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria' # type: str - self.web_test_id = kwargs['web_test_id'] - self.component_id = kwargs['component_id'] - self.failed_location_count = kwargs['failed_location_count'] 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 fb4bbdf427c7..2c3669778fdb 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 3cb30eec4074..66dfce38fc14 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 d50c72b70007..414a2fd90471 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,23 +5,292 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_or_update_request( + resource_group_name: str, + action_group_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + action_group_name: str, + subscription_id: str, + **kwargs: Any +) -> 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: str, + action_group_name: str, + subscription_id: str, + **kwargs: Any +) -> 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: str, + resource_group_name: str, + action_group_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_subscription_id_request( + subscription_id: str, + **kwargs: Any +) -> 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: str, + subscription_id: str, + **kwargs: Any +) -> 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: str, + action_group_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) class ActionGroupsOperations(object): """ActionGroupsOperations operations. @@ -45,17 +314,17 @@ 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 - action_group_name, # type: str - action_group, # type: "_models.ActionGroupResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.ActionGroupResource" + resource_group_name: str, + action_group_name: str, + action_group: "_models.ActionGroupResource", + **kwargs: Any + ) -> "_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 +340,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,18 +374,20 @@ 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 - action_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ActionGroupResource" + resource_group_name: str, + action_group_name: str, + **kwargs: Any + ) -> "_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 +401,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,18 +426,20 @@ 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 - action_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + action_group_name: str, + **kwargs: Any + ) -> 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,17 +477,18 @@ 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 - action_group_name, # type: str - action_group_patch, # type: "_models.ActionGroupPatchBody" - **kwargs # type: Any - ): - # type: (...) -> "_models.ActionGroupResource" + resource_group_name: str, + action_group_name: str, + action_group_patch: "_models.ActionGroupPatchBody", + **kwargs: Any + ) -> "_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 +504,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,18 +534,21 @@ 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 - ): - # type: (...) -> Iterable["_models.ActionGroupList"] + **kwargs: Any + ) -> Iterable["_models.ActionGroupList"]: """Get a list of all action groups 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 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 +556,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,30 +591,32 @@ 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 - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ActionGroupList"] + resource_group_name: str, + **kwargs: Any + ) -> 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 +624,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,29 +661,30 @@ 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 - action_group_name, # type: str - enable_request, # type: "_models.EnableRequest" - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + action_group_name: str, + enable_request: "_models.EnableRequest", + **kwargs: Any + ) -> None: """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 +700,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 4a6efc48270e..4fa32fef790b 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,23 +5,248 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "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: str, + resource_group_name: str, + **kwargs: Any +) -> 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: str, + resource_group_name: str, + rule_name: str, + **kwargs: Any +) -> 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: str, + resource_group_name: str, + rule_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + subscription_id: str, + resource_group_name: str, + rule_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + rule_name: str, + **kwargs: Any +) -> 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 + ) class MetricAlertsOperations(object): """MetricAlertsOperations operations. @@ -45,16 +270,18 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_subscription( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.MetricAlertResourceCollection"] + **kwargs: Any + ) -> Iterable["_models.MetricAlertResourceCollection"]: """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 +289,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,30 +324,33 @@ 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 - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.MetricAlertResourceCollection"] + resource_group_name: str, + **kwargs: Any + ) -> 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 +358,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,27 +395,28 @@ 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 - rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.MetricAlertResource" + resource_group_name: str, + rule_name: str, + **kwargs: Any + ) -> "_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 +430,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,19 +455,21 @@ 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 - rule_name, # type: str - parameters, # type: "_models.MetricAlertResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.MetricAlertResource" + resource_group_name: str, + rule_name: str, + parameters: "_models.MetricAlertResource", + **kwargs: Any + ) -> "_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 +485,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,19 +515,21 @@ 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 - rule_name, # type: str - parameters, # type: "_models.MetricAlertResourcePatch" - **kwargs # type: Any - ): - # type: (...) -> "_models.MetricAlertResource" + resource_group_name: str, + rule_name: str, + parameters: "_models.MetricAlertResourcePatch", + **kwargs: Any + ) -> "_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 +545,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,18 +575,20 @@ 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 - rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + rule_name: str, + **kwargs: Any + ) -> 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 +602,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 121c90a9fdaa..05b7c8f94d81 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,22 +5,96 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + resource_group_name: str, + rule_name: str, + **kwargs: Any +) -> 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: str, + resource_group_name: str, + rule_name: str, + status_name: str, + **kwargs: Any +) -> 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 + ) class MetricAlertsStatusOperations(object): """MetricAlertsStatusOperations operations. @@ -44,16 +118,16 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.MetricAlertStatusCollection" + resource_group_name: str, + rule_name: str, + **kwargs: Any + ) -> "_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 +141,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') + + 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) - # 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('MetricAlertStatusCollection', pipeline_response) @@ -102,19 +166,21 @@ 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 - rule_name, # type: str - status_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.MetricAlertStatusCollection" + resource_group_name: str, + rule_name: str, + status_name: str, + **kwargs: Any + ) -> "_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 +196,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 +222,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 d82479510092..ec9090a57df0 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 b6128ee1573c..6fb25c5332d8 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 @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class MonitorManagementClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(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 +65,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 1096c3229c33..14e0dd203124 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 956b94a97ccb..e41f47416657 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,77 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -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 . 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 import TokenCredential -class MonitorManagementClient(object): +class MonitorManagementClient: """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] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + 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: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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 000000000000..74e48ecd07cf --- /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 000000000000..138f663c53a4 --- /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 cac9f5d10f8b..e5754a47ce68 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 96ce9b45c05b..4eba911f1c6e 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 601c1798da2a..8af9a49138cd 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 ea933cca6b44..c73fd5d4fc0e 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 000000000000..74e48ecd07cf --- /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 67665d0db68e..e85418a0b030 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/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/__init__.py index 31b0b1f63a15..7e948df4f724 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/__init__.py @@ -6,40 +6,23 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import Action - from ._models_py3 import AlertingAction - from ._models_py3 import AzNsActionGroup - from ._models_py3 import Criteria - from ._models_py3 import Dimension - from ._models_py3 import ErrorContract - from ._models_py3 import ErrorResponse - from ._models_py3 import LogMetricTrigger - from ._models_py3 import LogSearchRuleResource - from ._models_py3 import LogSearchRuleResourceCollection - from ._models_py3 import LogSearchRuleResourcePatch - from ._models_py3 import LogToMetricAction - from ._models_py3 import Resource - from ._models_py3 import Schedule - from ._models_py3 import Source - from ._models_py3 import TriggerCondition -except (SyntaxError, ImportError): - from ._models import Action # type: ignore - from ._models import AlertingAction # type: ignore - from ._models import AzNsActionGroup # type: ignore - from ._models import Criteria # type: ignore - from ._models import Dimension # type: ignore - from ._models import ErrorContract # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import LogMetricTrigger # type: ignore - from ._models import LogSearchRuleResource # type: ignore - from ._models import LogSearchRuleResourceCollection # type: ignore - from ._models import LogSearchRuleResourcePatch # type: ignore - from ._models import LogToMetricAction # type: ignore - from ._models import Resource # type: ignore - from ._models import Schedule # type: ignore - from ._models import Source # type: ignore - from ._models import TriggerCondition # type: ignore +from ._models_py3 import Action +from ._models_py3 import AlertingAction +from ._models_py3 import AzNsActionGroup +from ._models_py3 import Criteria +from ._models_py3 import Dimension +from ._models_py3 import ErrorContract +from ._models_py3 import ErrorResponse +from ._models_py3 import LogMetricTrigger +from ._models_py3 import LogSearchRuleResource +from ._models_py3 import LogSearchRuleResourceCollection +from ._models_py3 import LogSearchRuleResourcePatch +from ._models_py3 import LogToMetricAction +from ._models_py3 import Resource +from ._models_py3 import Schedule +from ._models_py3 import Source +from ._models_py3 import TriggerCondition + from ._monitor_management_client_enums import ( AlertSeverity, 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 deleted file mode 100644 index b59b0546318a..000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/_models.py +++ /dev/null @@ -1,610 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class Action(msrest.serialization.Model): - """Action descriptor. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: AlertingAction, LogToMetricAction. - - All required parameters must be populated in order to send to Azure. - - :param odata_type: Required. Specifies the action. Supported values - AlertingAction, - LogToMetricAction.Constant filled by server. - :type odata_type: str - """ - - _validation = { - 'odata_type': {'required': True}, - } - - _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - } - - _subtype_map = { - 'odata_type': {'Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction': 'AlertingAction', 'Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.LogToMetricAction': 'LogToMetricAction'} - } - - def __init__( - self, - **kwargs - ): - super(Action, self).__init__(**kwargs) - self.odata_type = None # type: Optional[str] - - -class AlertingAction(Action): - """Specify action need to be taken when rule type is Alert. - - All required parameters must be populated in order to send to Azure. - - :param 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", - "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 - """ - - _validation = { - 'odata_type': {'required': True}, - 'severity': {'required': True}, - 'trigger': {'required': True}, - } - - _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'severity': {'key': 'severity', 'type': 'str'}, - 'azns_action': {'key': 'aznsAction', 'type': 'AzNsActionGroup'}, - 'throttling_in_min': {'key': 'throttlingInMin', 'type': 'int'}, - 'trigger': {'key': 'trigger', 'type': 'TriggerCondition'}, - } - - def __init__( - self, - **kwargs - ): - 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'] - self.azns_action = kwargs.get('azns_action', None) - self.throttling_in_min = kwargs.get('throttling_in_min', None) - self.trigger = kwargs['trigger'] - - -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 - group. - :type custom_webhook_payload: str - """ - - _attribute_map = { - 'action_group': {'key': 'actionGroup', 'type': '[str]'}, - 'email_subject': {'key': 'emailSubject', 'type': 'str'}, - 'custom_webhook_payload': {'key': 'customWebhookPayload', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AzNsActionGroup, self).__init__(**kwargs) - self.action_group = kwargs.get('action_group', None) - self.email_subject = kwargs.get('email_subject', None) - self.custom_webhook_payload = kwargs.get('custom_webhook_payload', None) - - -class Criteria(msrest.serialization.Model): - """Specifies the criteria for converting log to metric. - - 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] - """ - - _validation = { - 'metric_name': {'required': True}, - } - - _attribute_map = { - 'metric_name': {'key': 'metricName', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[Dimension]'}, - } - - def __init__( - self, - **kwargs - ): - super(Criteria, self).__init__(**kwargs) - self.metric_name = kwargs['metric_name'] - self.dimensions = kwargs.get('dimensions', None) - - -class Dimension(msrest.serialization.Model): - """Specifies the criteria for converting log to metric. - - 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] - """ - - _validation = { - 'name': {'required': True}, - 'operator': {'required': True}, - 'values': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'operator': {'key': 'operator', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(Dimension, self).__init__(**kwargs) - self.name = kwargs['name'] - self.operator = kwargs['operator'] - self.values = kwargs['values'] - - -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 - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponse'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorContract, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -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 - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - - -class LogMetricTrigger(msrest.serialization.Model): - """A log metrics trigger descriptor. - - :param 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 - ~$(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 - include: "Consecutive", "Total". Default value: "Consecutive". - :type 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 - """ - - _attribute_map = { - 'threshold_operator': {'key': 'thresholdOperator', 'type': 'str'}, - 'threshold': {'key': 'threshold', 'type': 'float'}, - 'metric_trigger_type': {'key': 'metricTriggerType', 'type': 'str'}, - 'metric_column': {'key': 'metricColumn', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LogMetricTrigger, self).__init__(**kwargs) - self.threshold_operator = kwargs.get('threshold_operator', "GreaterThanOrEqual") - self.threshold = kwargs.get('threshold', None) - self.metric_trigger_type = kwargs.get('metric_trigger_type', "Consecutive") - self.metric_column = kwargs.get('metric_column', None) - - -class Resource(msrest.serialization.Model): - """An azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :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 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. - :vartype kind: str - :ivar etag: The etag field is *not* required. If it is provided in the response body, it must - also be provided as a header per the normal etag convention. Entity tags are used for - comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in - the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range - (section 14.27) header fields. - :vartype etag: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'kind': {'readonly': True}, - 'etag': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - self.kind = None - self.etag = None - - -class LogSearchRuleResource(Resource): - """The Log Search Rule resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :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 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. - :vartype kind: str - :ivar etag: The etag field is *not* required. If it is provided in the response body, it must - also be provided as a header per the normal etag convention. Entity tags are used for - comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in - the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range - (section 14.27) header fields. - :vartype etag: 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 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 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 - - 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 - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'kind': {'readonly': True}, - 'etag': {'readonly': True}, - 'created_with_api_version': {'readonly': True}, - 'is_legacy_log_analytics_rule': {'readonly': True}, - 'last_updated_time': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'source': {'required': True}, - 'action': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'created_with_api_version': {'key': 'properties.createdWithApiVersion', 'type': 'str'}, - 'is_legacy_log_analytics_rule': {'key': 'properties.isLegacyLogAnalyticsRule', 'type': 'bool'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'auto_mitigate': {'key': 'properties.autoMitigate', 'type': 'bool'}, - 'enabled': {'key': 'properties.enabled', 'type': 'str'}, - 'last_updated_time': {'key': 'properties.lastUpdatedTime', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'source': {'key': 'properties.source', 'type': 'Source'}, - 'schedule': {'key': 'properties.schedule', 'type': 'Schedule'}, - 'action': {'key': 'properties.action', 'type': 'Action'}, - } - - def __init__( - self, - **kwargs - ): - super(LogSearchRuleResource, self).__init__(**kwargs) - self.created_with_api_version = None - self.is_legacy_log_analytics_rule = None - self.description = kwargs.get('description', None) - self.display_name = kwargs.get('display_name', None) - self.auto_mitigate = kwargs.get('auto_mitigate', False) - self.enabled = kwargs.get('enabled', None) - self.last_updated_time = None - self.provisioning_state = None - self.source = kwargs['source'] - self.schedule = kwargs.get('schedule', None) - self.action = kwargs['action'] - - -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] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[LogSearchRuleResource]'}, - } - - def __init__( - self, - **kwargs - ): - super(LogSearchRuleResourceCollection, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -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 - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'enabled': {'key': 'properties.enabled', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LogSearchRuleResourcePatch, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.enabled = kwargs.get('enabled', None) - - -class LogToMetricAction(Action): - """Specify action need to be taken when rule type is converting log to metric. - - All required parameters must be populated in order to send to Azure. - - :param 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] - """ - - _validation = { - 'odata_type': {'required': True}, - 'criteria': {'required': True}, - } - - _attribute_map = { - 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, - 'criteria': {'key': 'criteria', 'type': '[Criteria]'}, - } - - def __init__( - self, - **kwargs - ): - 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'] - - -class Schedule(msrest.serialization.Model): - """Defines how often to run the search and the time interval. - - 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 - evaluated. - :type frequency_in_minutes: int - :param 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 - """ - - _validation = { - 'frequency_in_minutes': {'required': True}, - 'time_window_in_minutes': {'required': True}, - } - - _attribute_map = { - 'frequency_in_minutes': {'key': 'frequencyInMinutes', 'type': 'int'}, - 'time_window_in_minutes': {'key': 'timeWindowInMinutes', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(Schedule, self).__init__(**kwargs) - self.frequency_in_minutes = kwargs['frequency_in_minutes'] - self.time_window_in_minutes = kwargs['time_window_in_minutes'] - - -class Source(msrest.serialization.Model): - """Specifies the log search query. - - 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 - """ - - _validation = { - 'data_source_id': {'required': True}, - } - - _attribute_map = { - 'query': {'key': 'query', 'type': 'str'}, - 'authorized_resources': {'key': 'authorizedResources', 'type': '[str]'}, - 'data_source_id': {'key': 'dataSourceId', 'type': 'str'}, - 'query_type': {'key': 'queryType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Source, self).__init__(**kwargs) - self.query = kwargs.get('query', None) - self.authorized_resources = kwargs.get('authorized_resources', None) - self.data_source_id = kwargs['data_source_id'] - self.query_type = kwargs.get('query_type', None) - - -class TriggerCondition(msrest.serialization.Model): - """The condition that results in the Log Search rule. - - 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 - ~$(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 - """ - - _validation = { - 'threshold_operator': {'required': True}, - 'threshold': {'required': True}, - } - - _attribute_map = { - 'threshold_operator': {'key': 'thresholdOperator', 'type': 'str'}, - 'threshold': {'key': 'threshold', 'type': 'float'}, - 'metric_trigger': {'key': 'metricTrigger', 'type': 'LogMetricTrigger'}, - } - - def __init__( - self, - **kwargs - ): - super(TriggerCondition, self).__init__(**kwargs) - self.threshold_operator = kwargs.get('threshold_operator', "GreaterThanOrEqual") - self.threshold = kwargs['threshold'] - self.metric_trigger = kwargs.get('metric_trigger', None) 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 97d28d3679a9..f4941e6938ed 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 ce9b4a5dd1d8..d0d3448a6a6e 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 3df057ea5665..1c948e2cac15 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,23 +5,256 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + rule_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + rule_name: str, + subscription_id: str, + **kwargs: Any +) -> 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: str, + resource_group_name: str, + rule_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + rule_name: str, + subscription_id: str, + **kwargs: Any +) -> 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: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + 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: str, + subscription_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + 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 + ) class ScheduledQueryRulesOperations(object): """ScheduledQueryRulesOperations operations. @@ -45,17 +278,17 @@ 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 - rule_name, # type: str - parameters, # type: "_models.LogSearchRuleResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.LogSearchRuleResource" + resource_group_name: str, + rule_name: str, + parameters: "_models.LogSearchRuleResource", + **kwargs: Any + ) -> "_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 +304,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] + + _json = self._serialize.body(parameters, 'LogSearchRuleResource') - # 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, '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,18 +338,20 @@ 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 - rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.LogSearchRuleResource" + resource_group_name: str, + rule_name: str, + **kwargs: Any + ) -> "_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 +365,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,19 +390,21 @@ 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 - rule_name, # type: str - parameters, # type: "_models.LogSearchRuleResourcePatch" - **kwargs # type: Any - ): - # type: (...) -> "_models.LogSearchRuleResource" + resource_group_name: str, + rule_name: str, + parameters: "_models.LogSearchRuleResourcePatch", + **kwargs: Any + ) -> "_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 +420,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,18 +450,20 @@ 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 - rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + rule_name: str, + **kwargs: Any + ) -> 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 +477,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,20 +501,23 @@ 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] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.LogSearchRuleResourceCollection"] + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.LogSearchRuleResourceCollection"]: """List the Log Search rules within a subscription group. :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"] @@ -323,36 +525,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,34 +562,37 @@ 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 - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.LogSearchRuleResourceCollection"] + resource_group_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> 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 +600,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 +639,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 d82479510092..ec9090a57df0 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 f6b03c03aaa5..cc2cd2e5d57c 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 @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class MonitorManagementClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(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 +65,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 cfd4d8a7a17b..5aeafd91a05d 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 9eec57542a68..f0184e69c831 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,82 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import 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 - -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.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] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + 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: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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 000000000000..74e48ecd07cf --- /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 000000000000..138f663c53a4 --- /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 cac9f5d10f8b..e5754a47ce68 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 96ce9b45c05b..4eba911f1c6e 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 3219bb1c9dc8..f4bfd2172596 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 06402e692be0..6a2eb35ec8f3 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 000000000000..74e48ecd07cf --- /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 897035d273d3..80d6e126d47d 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 3e4d561f6256..2caa8649a889 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/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/__init__.py index 1dab1d930479..fc0647fb2952 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/__init__.py @@ -6,38 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import DataSource - from ._models_py3 import DataSourceConfiguration - from ._models_py3 import ErrorResponse - from ._models_py3 import EtwEventConfiguration - from ._models_py3 import EtwProviderConfiguration - from ._models_py3 import EventLogConfiguration - from ._models_py3 import GuestDiagnosticSettingsAssociationList - from ._models_py3 import GuestDiagnosticSettingsAssociationResource - from ._models_py3 import GuestDiagnosticSettingsAssociationResourcePatch - from ._models_py3 import GuestDiagnosticSettingsList - from ._models_py3 import GuestDiagnosticSettingsPatchResource - from ._models_py3 import GuestDiagnosticSettingsResource - from ._models_py3 import PerformanceCounterConfiguration - from ._models_py3 import Resource - from ._models_py3 import SinkConfiguration -except (SyntaxError, ImportError): - from ._models import DataSource # type: ignore - from ._models import DataSourceConfiguration # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import EtwEventConfiguration # type: ignore - from ._models import EtwProviderConfiguration # type: ignore - from ._models import EventLogConfiguration # type: ignore - from ._models import GuestDiagnosticSettingsAssociationList # type: ignore - from ._models import GuestDiagnosticSettingsAssociationResource # type: ignore - from ._models import GuestDiagnosticSettingsAssociationResourcePatch # type: ignore - from ._models import GuestDiagnosticSettingsList # type: ignore - from ._models import GuestDiagnosticSettingsPatchResource # type: ignore - from ._models import GuestDiagnosticSettingsResource # type: ignore - from ._models import PerformanceCounterConfiguration # type: ignore - from ._models import Resource # type: ignore - from ._models import SinkConfiguration # type: ignore +from ._models_py3 import DataSource +from ._models_py3 import DataSourceConfiguration +from ._models_py3 import ErrorResponse +from ._models_py3 import EtwEventConfiguration +from ._models_py3 import EtwProviderConfiguration +from ._models_py3 import EventLogConfiguration +from ._models_py3 import GuestDiagnosticSettingsAssociationList +from ._models_py3 import GuestDiagnosticSettingsAssociationResource +from ._models_py3 import GuestDiagnosticSettingsAssociationResourcePatch +from ._models_py3 import GuestDiagnosticSettingsList +from ._models_py3 import GuestDiagnosticSettingsPatchResource +from ._models_py3 import GuestDiagnosticSettingsResource +from ._models_py3 import PerformanceCounterConfiguration +from ._models_py3 import Resource +from ._models_py3 import SinkConfiguration + from ._monitor_management_client_enums import ( DataSourceKind, 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 deleted file mode 100644 index 06ae1bbd2382..000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/_models.py +++ /dev/null @@ -1,506 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class DataSource(msrest.serialization.Model): - """Data source object contains configuration to collect telemetry and one or more sinks to send that telemetry data to. - - All required parameters must be populated in order to send to Azure. - - :param 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: - ~$(python-base-namespace).v2018_06_01_preview.models.DataSourceConfiguration - :param sinks: Required. - :type sinks: list[~$(python-base-namespace).v2018_06_01_preview.models.SinkConfiguration] - """ - - _validation = { - 'kind': {'required': True}, - 'configuration': {'required': True}, - 'sinks': {'required': True}, - } - - _attribute_map = { - 'kind': {'key': 'kind', 'type': 'str'}, - 'configuration': {'key': 'configuration', 'type': 'DataSourceConfiguration'}, - 'sinks': {'key': 'sinks', 'type': '[SinkConfiguration]'}, - } - - def __init__( - self, - **kwargs - ): - super(DataSource, self).__init__(**kwargs) - self.kind = kwargs['kind'] - self.configuration = kwargs['configuration'] - self.sinks = kwargs['sinks'] - - -class DataSourceConfiguration(msrest.serialization.Model): - """DataSourceConfiguration. - - :param providers: ETW providers configuration. - :type providers: - list[~$(python-base-namespace).v2018_06_01_preview.models.EtwProviderConfiguration] - :param perf_counters: Performance counter configuration. - :type perf_counters: - list[~$(python-base-namespace).v2018_06_01_preview.models.PerformanceCounterConfiguration] - :param event_logs: Windows event logs configuration. - :type event_logs: - list[~$(python-base-namespace).v2018_06_01_preview.models.EventLogConfiguration] - """ - - _attribute_map = { - 'providers': {'key': 'providers', 'type': '[EtwProviderConfiguration]'}, - 'perf_counters': {'key': 'perfCounters', 'type': '[PerformanceCounterConfiguration]'}, - 'event_logs': {'key': 'eventLogs', 'type': '[EventLogConfiguration]'}, - } - - def __init__( - self, - **kwargs - ): - super(DataSourceConfiguration, self).__init__(**kwargs) - self.providers = kwargs.get('providers', None) - self.perf_counters = kwargs.get('perf_counters', None) - self.event_logs = kwargs.get('event_logs', None) - - -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 - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - - -class EtwEventConfiguration(msrest.serialization.Model): - """EtwEventConfiguration. - - 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 - """ - - _validation = { - 'name': {'required': True}, - 'id': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'int'}, - 'filter': {'key': 'filter', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EtwEventConfiguration, self).__init__(**kwargs) - self.name = kwargs['name'] - self.id = kwargs['id'] - self.filter = kwargs.get('filter', None) - - -class EtwProviderConfiguration(msrest.serialization.Model): - """EtwProviderConfiguration. - - 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] - """ - - _validation = { - 'id': {'required': True}, - 'events': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'events': {'key': 'events', 'type': '[EtwEventConfiguration]'}, - } - - def __init__( - self, - **kwargs - ): - super(EtwProviderConfiguration, self).__init__(**kwargs) - self.id = kwargs['id'] - self.events = kwargs['events'] - - -class EventLogConfiguration(msrest.serialization.Model): - """EventLogConfiguration. - - 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 - """ - - _validation = { - 'log_name': {'required': True}, - } - - _attribute_map = { - 'log_name': {'key': 'logName', 'type': 'str'}, - 'filter': {'key': 'filter', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EventLogConfiguration, self).__init__(**kwargs) - self.log_name = kwargs['log_name'] - self.filter = kwargs.get('filter', None) - - -class GuestDiagnosticSettingsAssociationList(msrest.serialization.Model): - """A list of guest diagnostic settings association. - - :param value: The list of guest diagnostic settings association. - :type 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 - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[GuestDiagnosticSettingsAssociationResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(GuestDiagnosticSettingsAssociationList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class Resource(msrest.serialization.Model): - """An azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :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] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - - -class GuestDiagnosticSettingsAssociationResource(Resource): - """Virtual machine guest diagnostic settings resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :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 - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'guest_diagnostic_settings_name': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'guest_diagnostic_settings_name': {'key': 'properties.guestDiagnosticSettingsName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(GuestDiagnosticSettingsAssociationResource, self).__init__(**kwargs) - self.guest_diagnostic_settings_name = kwargs['guest_diagnostic_settings_name'] - - -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 - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'guest_diagnostic_settings_name': {'key': 'properties.guestDiagnosticSettingsName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(GuestDiagnosticSettingsAssociationResourcePatch, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.guest_diagnostic_settings_name = kwargs.get('guest_diagnostic_settings_name', None) - - -class GuestDiagnosticSettingsList(msrest.serialization.Model): - """A list of guest diagnostic settings. - - :param value: The list of guest diagnostic settings. - :type 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 - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[GuestDiagnosticSettingsResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(GuestDiagnosticSettingsList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -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 - ~$(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 - data. - :type data_sources: list[~$(python-base-namespace).v2018_06_01_preview.models.DataSource] - :param proxy_setting: - :type proxy_setting: str - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'os_type': {'key': 'properties.osType', 'type': 'str'}, - 'data_sources': {'key': 'properties.dataSources', 'type': '[DataSource]'}, - 'proxy_setting': {'key': 'properties.proxySetting', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(GuestDiagnosticSettingsPatchResource, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.os_type = kwargs.get('os_type', None) - self.data_sources = kwargs.get('data_sources', None) - self.proxy_setting = kwargs.get('proxy_setting', None) - - -class GuestDiagnosticSettingsResource(Resource): - """Virtual machine guest diagnostics settings resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :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 - ~$(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 - data. - :type data_sources: list[~$(python-base-namespace).v2018_06_01_preview.models.DataSource] - :param proxy_setting: - :type proxy_setting: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'os_type': {'key': 'properties.osType', 'type': 'str'}, - 'data_sources': {'key': 'properties.dataSources', 'type': '[DataSource]'}, - 'proxy_setting': {'key': 'properties.proxySetting', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(GuestDiagnosticSettingsResource, self).__init__(**kwargs) - self.os_type = kwargs.get('os_type', None) - self.data_sources = kwargs.get('data_sources', None) - self.proxy_setting = kwargs.get('proxy_setting', None) - - -class PerformanceCounterConfiguration(msrest.serialization.Model): - """PerformanceCounterConfiguration. - - 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 - """ - - _validation = { - 'name': {'required': True}, - 'sampling_period': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'sampling_period': {'key': 'samplingPeriod', 'type': 'str'}, - 'instance': {'key': 'instance', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PerformanceCounterConfiguration, self).__init__(**kwargs) - self.name = kwargs['name'] - self.sampling_period = kwargs['sampling_period'] - self.instance = kwargs.get('instance', None) - - -class SinkConfiguration(msrest.serialization.Model): - """SinkConfiguration. - - All required parameters must be populated in order to send to Azure. - - :param kind: Required. Possible values include: "EventHub", "ApplicationInsights", - "LogAnalytics". - :type kind: str or ~$(python-base-namespace).v2018_06_01_preview.models.SinkConfigurationKind - """ - - _validation = { - 'kind': {'required': True}, - } - - _attribute_map = { - 'kind': {'key': 'kind', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - 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 9f72f55fcb22..dffaff76a32f 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 fdd4cc87df81..c0cdf7ff95e6 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 21e8b221b17a..f0b56e14d6de 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,23 +5,240 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_or_update_request( + resource_uri: str, + association_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + resource_uri: str, + association_name: str, + **kwargs: Any +) -> 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: str, + association_name: str, + **kwargs: Any +) -> 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: str, + association_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> 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: str, + subscription_id: str, + **kwargs: Any +) -> 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 + ) class GuestDiagnosticsSettingsAssociationOperations(object): """GuestDiagnosticsSettingsAssociationOperations operations. @@ -45,14 +262,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def create_or_update( self, - resource_uri, # type: str - association_name, # type: str - diagnostic_settings_association, # type: "_models.GuestDiagnosticSettingsAssociationResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.GuestDiagnosticSettingsAssociationResource" + resource_uri: str, + association_name: str, + diagnostic_settings_association: "_models.GuestDiagnosticSettingsAssociationResource", + **kwargs: Any + ) -> "_models.GuestDiagnosticSettingsAssociationResource": """Creates or updates guest diagnostics settings association. :param resource_uri: The fully qualified ID of the resource, including the resource name and @@ -62,10 +279,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 +292,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] + + _json = self._serialize.body(diagnostic_settings_association, 'GuestDiagnosticSettingsAssociationResource') - # 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, + 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,15 +325,17 @@ 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 - association_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.GuestDiagnosticSettingsAssociationResource" + resource_uri: str, + association_name: str, + **kwargs: Any + ) -> "_models.GuestDiagnosticSettingsAssociationResource": """Gets guest diagnostics association settings. :param resource_uri: The fully qualified ID of the resource, including the resource name and @@ -134,7 +345,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 +354,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,15 +378,17 @@ 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 - association_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_uri: str, + association_name: str, + **kwargs: Any + ) -> None: """Delete guest diagnostics association settings. :param resource_uri: The fully qualified ID of the resource, including the resource name and @@ -202,32 +406,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,14 +429,15 @@ def delete( delete.metadata = {'url': '/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}'} # type: ignore + + @distributed_trace def update( self, - resource_uri, # type: str - association_name, # type: str - parameters, # type: "_models.GuestDiagnosticSettingsAssociationResourcePatch" - **kwargs # type: Any - ): - # type: (...) -> "_models.GuestDiagnosticSettingsAssociationResource" + resource_uri: str, + association_name: str, + parameters: "_models.GuestDiagnosticSettingsAssociationResourcePatch", + **kwargs: Any + ) -> "_models.GuestDiagnosticSettingsAssociationResource": """Updates an existing guestDiagnosticsSettingsAssociation Resource. To update other fields use the CreateOrUpdate method. @@ -252,10 +447,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 +460,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,18 +489,22 @@ 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 - ): - # type: (...) -> Iterable["_models.GuestDiagnosticSettingsAssociationList"] + **kwargs: Any + ) -> Iterable["_models.GuestDiagnosticSettingsAssociationList"]: """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 +512,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,30 +547,33 @@ 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 - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.GuestDiagnosticSettingsAssociationList"] + resource_group_name: str, + **kwargs: Any + ) -> 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 +581,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 +618,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 c7b5ae16539e..ec1a75a48f6b 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,23 +5,248 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_or_update_request( + resource_group_name: str, + diagnostic_settings_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + diagnostic_settings_name: str, + subscription_id: str, + **kwargs: Any +) -> 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: str, + diagnostic_settings_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + diagnostic_settings_name: str, + subscription_id: str, + **kwargs: Any +) -> 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: str, + **kwargs: Any +) -> 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: str, + subscription_id: str, + **kwargs: Any +) -> 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 + ) class GuestDiagnosticsSettingsOperations(object): """GuestDiagnosticsSettingsOperations operations. @@ -45,22 +270,23 @@ 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 - diagnostic_settings_name, # type: str - diagnostic_settings, # type: "_models.GuestDiagnosticSettingsResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.GuestDiagnosticSettingsResource" + resource_group_name: str, + diagnostic_settings_name: str, + diagnostic_settings: "_models.GuestDiagnosticSettingsResource", + **kwargs: Any + ) -> "_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 +297,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] + + _json = self._serialize.body(diagnostic_settings, 'GuestDiagnosticSettingsResource') - # 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, + 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,18 +331,20 @@ 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 - diagnostic_settings_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.GuestDiagnosticSettingsResource" + resource_group_name: str, + diagnostic_settings_name: str, + **kwargs: Any + ) -> "_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 +358,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,24 +383,27 @@ 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 - diagnostic_settings_name, # type: str - parameters, # type: "_models.GuestDiagnosticSettingsPatchResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.GuestDiagnosticSettingsResource" + resource_group_name: str, + diagnostic_settings_name: str, + parameters: "_models.GuestDiagnosticSettingsPatchResource", + **kwargs: Any + ) -> "_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 +414,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,18 +448,20 @@ 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 - diagnostic_settings_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + diagnostic_settings_name: str, + **kwargs: Any + ) -> 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 +475,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,16 +499,19 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}'} # type: ignore + + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.GuestDiagnosticSettingsList"] + **kwargs: Any + ) -> Iterable["_models.GuestDiagnosticSettingsList"]: """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 +519,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,30 +554,33 @@ 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 - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.GuestDiagnosticSettingsList"] + resource_group_name: str, + **kwargs: Any + ) -> 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 +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('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 +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_09_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/__init__.py index d82479510092..ec9090a57df0 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 08864a677576..58852411de43 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 @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class MonitorManagementClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(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 +65,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 11badcc855fc..55a9c50840f2 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 cdaddbe30328..ac4a74437887 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,83 +6,83 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import 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 - -class MonitorManagementClient(object): +class MonitorManagementClient: """Monitor Management Client. :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] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + 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: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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 000000000000..74e48ecd07cf --- /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 000000000000..138f663c53a4 --- /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 cac9f5d10f8b..e5754a47ce68 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 96ce9b45c05b..4eba911f1c6e 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 c2ff4d18ad78..3149ad11a362 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 52c95081d8ec..13df9dc4d055 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 000000000000..74e48ecd07cf --- /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 fbf6c3294322..0ba01330e7c1 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 c8c76e693c6a..13ea4d73c051 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 0bc346ea0e7e..2837800f421e 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/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/__init__.py index b7bdabe81db6..ea8c1f240a93 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/__init__.py @@ -6,54 +6,30 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import ActionGroupList - from ._models_py3 import ActionGroupPatchBody - from ._models_py3 import ActionGroupResource - from ._models_py3 import ArmRoleReceiver - from ._models_py3 import AutomationRunbookReceiver - from ._models_py3 import AzureAppPushReceiver - from ._models_py3 import AzureFunctionReceiver - from ._models_py3 import Baseline - from ._models_py3 import BaselineMetadataValue - from ._models_py3 import BaselineResponse - from ._models_py3 import CalculateBaselineResponse - from ._models_py3 import CalculateBaselineResponseStatistics - from ._models_py3 import EmailReceiver - from ._models_py3 import EnableRequest - from ._models_py3 import ErrorResponse - from ._models_py3 import ItsmReceiver - from ._models_py3 import LocalizableString - from ._models_py3 import LogicAppReceiver - from ._models_py3 import Resource - from ._models_py3 import SmsReceiver - from ._models_py3 import TimeSeriesInformation - from ._models_py3 import VoiceReceiver - from ._models_py3 import WebhookReceiver -except (SyntaxError, ImportError): - from ._models import ActionGroupList # type: ignore - from ._models import ActionGroupPatchBody # type: ignore - from ._models import ActionGroupResource # type: ignore - from ._models import ArmRoleReceiver # type: ignore - from ._models import AutomationRunbookReceiver # type: ignore - from ._models import AzureAppPushReceiver # type: ignore - from ._models import AzureFunctionReceiver # type: ignore - from ._models import Baseline # type: ignore - from ._models import BaselineMetadataValue # type: ignore - from ._models import BaselineResponse # type: ignore - from ._models import CalculateBaselineResponse # type: ignore - from ._models import CalculateBaselineResponseStatistics # type: ignore - from ._models import EmailReceiver # type: ignore - from ._models import EnableRequest # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import ItsmReceiver # type: ignore - from ._models import LocalizableString # type: ignore - from ._models import LogicAppReceiver # type: ignore - from ._models import Resource # type: ignore - from ._models import SmsReceiver # type: ignore - from ._models import TimeSeriesInformation # type: ignore - from ._models import VoiceReceiver # type: ignore - from ._models import WebhookReceiver # type: ignore +from ._models_py3 import ActionGroupList +from ._models_py3 import ActionGroupPatchBody +from ._models_py3 import ActionGroupResource +from ._models_py3 import ArmRoleReceiver +from ._models_py3 import AutomationRunbookReceiver +from ._models_py3 import AzureAppPushReceiver +from ._models_py3 import AzureFunctionReceiver +from ._models_py3 import Baseline +from ._models_py3 import BaselineMetadataValue +from ._models_py3 import BaselineResponse +from ._models_py3 import CalculateBaselineResponse +from ._models_py3 import CalculateBaselineResponseStatistics +from ._models_py3 import EmailReceiver +from ._models_py3 import EnableRequest +from ._models_py3 import ErrorResponse +from ._models_py3 import ItsmReceiver +from ._models_py3 import LocalizableString +from ._models_py3 import LogicAppReceiver +from ._models_py3 import Resource +from ._models_py3 import SmsReceiver +from ._models_py3 import TimeSeriesInformation +from ._models_py3 import VoiceReceiver +from ._models_py3 import WebhookReceiver + from ._monitor_management_client_enums import ( ErrorType, 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 deleted file mode 100644 index 5e39f2d75afc..000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/_models.py +++ /dev/null @@ -1,930 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class 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 - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ActionGroupResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ActionGroupList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -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 - enabled, then none of its actions will be activated. - :type enabled: bool - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(ActionGroupPatchBody, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.enabled = kwargs.get('enabled', True) - - -class Resource(msrest.serialization.Model): - """An azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :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] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - - -class ActionGroupResource(Resource): - """An action group resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :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 - 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: - list[~$(python-base-namespace).v2018_09_01.models.AzureAppPushReceiver] - :param automation_runbook_receivers: The list of AutomationRunbook receivers that are part of - this action group. - :type 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 - action group. - :type 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. - 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] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'group_short_name': {'max_length': 12, 'min_length': 0}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'group_short_name': {'key': 'properties.groupShortName', 'type': 'str'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - 'email_receivers': {'key': 'properties.emailReceivers', 'type': '[EmailReceiver]'}, - 'sms_receivers': {'key': 'properties.smsReceivers', 'type': '[SmsReceiver]'}, - 'webhook_receivers': {'key': 'properties.webhookReceivers', 'type': '[WebhookReceiver]'}, - 'itsm_receivers': {'key': 'properties.itsmReceivers', 'type': '[ItsmReceiver]'}, - 'azure_app_push_receivers': {'key': 'properties.azureAppPushReceivers', 'type': '[AzureAppPushReceiver]'}, - 'automation_runbook_receivers': {'key': 'properties.automationRunbookReceivers', 'type': '[AutomationRunbookReceiver]'}, - 'voice_receivers': {'key': 'properties.voiceReceivers', 'type': '[VoiceReceiver]'}, - 'logic_app_receivers': {'key': 'properties.logicAppReceivers', 'type': '[LogicAppReceiver]'}, - 'azure_function_receivers': {'key': 'properties.azureFunctionReceivers', 'type': '[AzureFunctionReceiver]'}, - 'arm_role_receivers': {'key': 'properties.armRoleReceivers', 'type': '[ArmRoleReceiver]'}, - } - - def __init__( - self, - **kwargs - ): - super(ActionGroupResource, self).__init__(**kwargs) - self.group_short_name = kwargs.get('group_short_name', None) - self.enabled = kwargs.get('enabled', True) - self.email_receivers = kwargs.get('email_receivers', None) - self.sms_receivers = kwargs.get('sms_receivers', None) - self.webhook_receivers = kwargs.get('webhook_receivers', None) - self.itsm_receivers = kwargs.get('itsm_receivers', None) - self.azure_app_push_receivers = kwargs.get('azure_app_push_receivers', None) - self.automation_runbook_receivers = kwargs.get('automation_runbook_receivers', None) - self.voice_receivers = kwargs.get('voice_receivers', None) - self.logic_app_receivers = kwargs.get('logic_app_receivers', None) - self.azure_function_receivers = kwargs.get('azure_function_receivers', None) - self.arm_role_receivers = kwargs.get('arm_role_receivers', None) - - -class ArmRoleReceiver(msrest.serialization.Model): - """An arm role receiver. - - 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 - receivers within an action group. - :type name: str - :param role_id: Required. The arm role id. - :type role_id: str - """ - - _validation = { - 'name': {'required': True}, - 'role_id': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'role_id': {'key': 'roleId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ArmRoleReceiver, self).__init__(**kwargs) - self.name = kwargs['name'] - self.role_id = kwargs['role_id'] - - -class AutomationRunbookReceiver(msrest.serialization.Model): - """The Azure Automation Runbook notification receiver. - - 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 - """ - - _validation = { - 'automation_account_id': {'required': True}, - 'runbook_name': {'required': True}, - 'webhook_resource_id': {'required': True}, - 'is_global_runbook': {'required': True}, - } - - _attribute_map = { - 'automation_account_id': {'key': 'automationAccountId', 'type': 'str'}, - 'runbook_name': {'key': 'runbookName', 'type': 'str'}, - 'webhook_resource_id': {'key': 'webhookResourceId', 'type': 'str'}, - 'is_global_runbook': {'key': 'isGlobalRunbook', 'type': 'bool'}, - 'name': {'key': 'name', 'type': 'str'}, - 'service_uri': {'key': 'serviceUri', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AutomationRunbookReceiver, self).__init__(**kwargs) - self.automation_account_id = kwargs['automation_account_id'] - self.runbook_name = kwargs['runbook_name'] - self.webhook_resource_id = kwargs['webhook_resource_id'] - self.is_global_runbook = kwargs['is_global_runbook'] - self.name = kwargs.get('name', None) - self.service_uri = kwargs.get('service_uri', None) - - -class AzureAppPushReceiver(msrest.serialization.Model): - """The Azure mobile App push notification receiver. - - 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 - 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 - """ - - _validation = { - 'name': {'required': True}, - 'email_address': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'email_address': {'key': 'emailAddress', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureAppPushReceiver, self).__init__(**kwargs) - self.name = kwargs['name'] - self.email_address = kwargs['email_address'] - - -class AzureFunctionReceiver(msrest.serialization.Model): - """An azure function receiver. - - 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 - 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 - """ - - _validation = { - 'name': {'required': True}, - 'function_app_resource_id': {'required': True}, - 'function_name': {'required': True}, - 'http_trigger_url': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'function_app_resource_id': {'key': 'functionAppResourceId', 'type': 'str'}, - 'function_name': {'key': 'functionName', 'type': 'str'}, - 'http_trigger_url': {'key': 'httpTriggerUrl', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureFunctionReceiver, self).__init__(**kwargs) - self.name = kwargs['name'] - self.function_app_resource_id = kwargs['function_app_resource_id'] - self.function_name = kwargs['function_name'] - self.http_trigger_url = kwargs['http_trigger_url'] - - -class Baseline(msrest.serialization.Model): - """The baseline values for a single sensitivity value. - - All required parameters must be populated in order to send to Azure. - - :param 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 - ~$(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 - """ - - _validation = { - 'sensitivity': {'required': True}, - 'low_thresholds': {'required': True}, - 'high_thresholds': {'required': True}, - } - - _attribute_map = { - 'sensitivity': {'key': 'sensitivity', 'type': 'str'}, - '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'}, - } - - def __init__( - self, - **kwargs - ): - super(Baseline, self).__init__(**kwargs) - self.sensitivity = kwargs['sensitivity'] - self.low_thresholds = kwargs['low_thresholds'] - self.high_thresholds = kwargs['high_thresholds'] - self.timestamps = kwargs.get('timestamps', None) - self.prediction_result_type = kwargs.get('prediction_result_type', None) - self.error_type = kwargs.get('error_type', None) - - -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 - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'LocalizableString'}, - 'value': {'key': 'value', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(BaselineMetadataValue, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.value = kwargs.get('value', None) - - -class BaselineResponse(msrest.serialization.Model): - """The response to a baseline query. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The metric baseline ID. - :vartype id: str - :ivar type: The resource type of the baseline resource. - :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 - ~$(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 - 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 - :ivar internal_operation_id: internal operation id. - :vartype internal_operation_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'name': {'readonly': True}, - 'internal_operation_id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'LocalizableString'}, - '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'}, - 'timespan': {'key': 'properties.timespan', 'type': 'str'}, - 'interval': {'key': 'properties.interval', 'type': 'duration'}, - 'aggregation': {'key': 'properties.aggregation', 'type': 'str'}, - 'internal_operation_id': {'key': 'properties.internalOperationId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(BaselineResponse, self).__init__(**kwargs) - self.id = None - self.type = None - self.name = None - self.timestamps = kwargs.get('timestamps', None) - self.baseline = kwargs.get('baseline', None) - self.metdata = kwargs.get('metdata', None) - self.prediction_result_type = kwargs.get('prediction_result_type', None) - self.error_type = kwargs.get('error_type', None) - self.timespan = kwargs.get('timespan', None) - self.interval = kwargs.get('interval', None) - self.aggregation = kwargs.get('aggregation', None) - self.internal_operation_id = None - - -class CalculateBaselineResponse(msrest.serialization.Model): - """The response to a calculate baseline call. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param 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: - ~$(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 - """ - - _validation = { - 'type': {'required': True}, - 'baseline': {'required': True}, - 'internal_operation_id': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'timestamps': {'key': 'timestamps', 'type': '[iso-8601]'}, - 'baseline': {'key': 'baseline', 'type': '[Baseline]'}, - 'statistics': {'key': 'statistics', 'type': 'CalculateBaselineResponseStatistics'}, - 'internal_operation_id': {'key': 'internalOperationId', 'type': 'str'}, - 'error_type': {'key': 'errorType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CalculateBaselineResponse, self).__init__(**kwargs) - self.type = kwargs['type'] - self.timestamps = kwargs.get('timestamps', None) - self.baseline = kwargs['baseline'] - self.statistics = kwargs.get('statistics', None) - self.internal_operation_id = None - self.error_type = kwargs.get('error_type', None) - - -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 - """ - - _attribute_map = { - 'is_eligible': {'key': 'isEligible', 'type': 'bool'}, - 'status': {'key': 'status', 'type': '[str]'}, - 'seasonality_period': {'key': 'seasonalityPeriod', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(CalculateBaselineResponseStatistics, self).__init__(**kwargs) - self.is_eligible = kwargs.get('is_eligible', None) - self.status = kwargs.get('status', None) - self.seasonality_period = kwargs.get('seasonality_period', None) - - -class EmailReceiver(msrest.serialization.Model): - """An email receiver. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param 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 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 - """ - - _validation = { - 'name': {'required': True}, - 'email_address': {'required': True}, - 'status': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'email_address': {'key': 'emailAddress', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EmailReceiver, self).__init__(**kwargs) - self.name = kwargs['name'] - self.email_address = kwargs['email_address'] - self.status = None - - -class EnableRequest(msrest.serialization.Model): - """Describes a receiver that should be resubscribed. - - 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 - """ - - _validation = { - 'receiver_name': {'required': True}, - } - - _attribute_map = { - 'receiver_name': {'key': 'receiverName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EnableRequest, self).__init__(**kwargs) - self.receiver_name = kwargs['receiver_name'] - - -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 - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - - -class ItsmReceiver(msrest.serialization.Model): - """An Itsm receiver. - - 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 - 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 - in above workspace. - :type connection_id: str - :param 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 - values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. - :type region: str - """ - - _validation = { - 'name': {'required': True}, - 'workspace_id': {'required': True}, - 'connection_id': {'required': True}, - 'ticket_configuration': {'required': True}, - 'region': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'workspace_id': {'key': 'workspaceId', 'type': 'str'}, - 'connection_id': {'key': 'connectionId', 'type': 'str'}, - 'ticket_configuration': {'key': 'ticketConfiguration', 'type': 'str'}, - 'region': {'key': 'region', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ItsmReceiver, self).__init__(**kwargs) - self.name = kwargs['name'] - self.workspace_id = kwargs['workspace_id'] - self.connection_id = kwargs['connection_id'] - self.ticket_configuration = kwargs['ticket_configuration'] - self.region = kwargs['region'] - - -class LocalizableString(msrest.serialization.Model): - """The localizable string class. - - 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 - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LocalizableString, self).__init__(**kwargs) - self.value = kwargs['value'] - self.localized_value = kwargs.get('localized_value', None) - - -class LogicAppReceiver(msrest.serialization.Model): - """A logic app receiver. - - 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 - 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 - """ - - _validation = { - 'name': {'required': True}, - 'resource_id': {'required': True}, - 'callback_url': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'callback_url': {'key': 'callbackUrl', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LogicAppReceiver, self).__init__(**kwargs) - self.name = kwargs['name'] - self.resource_id = kwargs['resource_id'] - self.callback_url = kwargs['callback_url'] - - -class SmsReceiver(msrest.serialization.Model): - """An SMS receiver. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param 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 - :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 - """ - - _validation = { - 'name': {'required': True}, - 'country_code': {'required': True}, - 'phone_number': {'required': True}, - 'status': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'country_code': {'key': 'countryCode', 'type': 'str'}, - 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SmsReceiver, self).__init__(**kwargs) - self.name = kwargs['name'] - self.country_code = kwargs['country_code'] - self.phone_number = kwargs['phone_number'] - self.status = None - - -class TimeSeriesInformation(msrest.serialization.Model): - """The time series info needed for calculating the baseline. - - 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] - """ - - _validation = { - 'sensitivities': {'required': True}, - 'values': {'required': True}, - } - - _attribute_map = { - 'sensitivities': {'key': 'sensitivities', 'type': '[str]'}, - 'values': {'key': 'values', 'type': '[float]'}, - 'timestamps': {'key': 'timestamps', 'type': '[iso-8601]'}, - } - - def __init__( - self, - **kwargs - ): - super(TimeSeriesInformation, self).__init__(**kwargs) - self.sensitivities = kwargs['sensitivities'] - self.values = kwargs['values'] - self.timestamps = kwargs.get('timestamps', None) - - -class VoiceReceiver(msrest.serialization.Model): - """A voice receiver. - - 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 - """ - - _validation = { - 'name': {'required': True}, - 'country_code': {'required': True}, - 'phone_number': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'country_code': {'key': 'countryCode', 'type': 'str'}, - 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(VoiceReceiver, self).__init__(**kwargs) - self.name = kwargs['name'] - self.country_code = kwargs['country_code'] - self.phone_number = kwargs['phone_number'] - - -class WebhookReceiver(msrest.serialization.Model): - """A webhook receiver. - - 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 - receivers within an action group. - :type name: str - :param service_uri: Required. The URI where webhooks should be sent. - :type service_uri: str - """ - - _validation = { - 'name': {'required': True}, - 'service_uri': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'service_uri': {'key': 'serviceUri', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - 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 6bb97b5a84c6..6f09b8bfb067 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 2968ce09e7c2..200d8caf46bb 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 cbaa9affec08..56910bb93299 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,23 +5,292 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_or_update_request( + resource_group_name: str, + action_group_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + action_group_name: str, + subscription_id: str, + **kwargs: Any +) -> 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: str, + action_group_name: str, + subscription_id: str, + **kwargs: Any +) -> 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: str, + resource_group_name: str, + action_group_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_subscription_id_request( + subscription_id: str, + **kwargs: Any +) -> 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: str, + subscription_id: str, + **kwargs: Any +) -> 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: str, + action_group_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) class ActionGroupsOperations(object): """ActionGroupsOperations operations. @@ -45,17 +314,17 @@ 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 - action_group_name, # type: str - action_group, # type: "_models.ActionGroupResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.ActionGroupResource" + resource_group_name: str, + action_group_name: str, + action_group: "_models.ActionGroupResource", + **kwargs: Any + ) -> "_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 +340,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,18 +374,20 @@ 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 - action_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ActionGroupResource" + resource_group_name: str, + action_group_name: str, + **kwargs: Any + ) -> "_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 +401,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,18 +426,20 @@ 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 - action_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + action_group_name: str, + **kwargs: Any + ) -> 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,17 +477,18 @@ 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 - action_group_name, # type: str - action_group_patch, # type: "_models.ActionGroupPatchBody" - **kwargs # type: Any - ): - # type: (...) -> "_models.ActionGroupResource" + resource_group_name: str, + action_group_name: str, + action_group_patch: "_models.ActionGroupPatchBody", + **kwargs: Any + ) -> "_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 +504,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,18 +534,21 @@ 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 - ): - # type: (...) -> Iterable["_models.ActionGroupList"] + **kwargs: Any + ) -> Iterable["_models.ActionGroupList"]: """Get a list of all action groups 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 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 +556,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,30 +591,32 @@ 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 - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ActionGroupList"] + resource_group_name: str, + **kwargs: Any + ) -> 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 +624,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,29 +661,30 @@ 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 - action_group_name, # type: str - enable_request, # type: "_models.EnableRequest" - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + action_group_name: str, + enable_request: "_models.EnableRequest", + **kwargs: Any + ) -> None: """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 +700,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 15dd5f3f22de..991aea74f1e0 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,22 +6,80 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime -from typing import TYPE_CHECKING +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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_uri: str, + *, + metricnames: Optional[str] = None, + timespan: Optional[str] = None, + interval: Optional[datetime.timedelta] = None, + aggregation: Optional[str] = None, + sensitivities: Optional[str] = None, + result_type: Optional[Union[str, "_models.ResultType"]] = None, + metricnamespace: Optional[str] = None, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + 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 + ) class BaselineOperations(object): """BaselineOperations operations. @@ -45,20 +103,20 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_uri, # type: str - metricnames=None, # type: Optional[str] - timespan=None, # type: Optional[str] - interval=None, # type: Optional[datetime.timedelta] - aggregation=None, # type: Optional[str] - sensitivities=None, # type: Optional[str] - result_type=None, # type: Optional[Union[str, "_models.ResultType"]] - metricnamespace=None, # type: Optional[str] - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.BaselineResponse" + resource_uri: str, + metricnames: Optional[str] = None, + timespan: Optional[str] = None, + interval: Optional[datetime.timedelta] = None, + aggregation: Optional[str] = None, + sensitivities: Optional[str] = None, + result_type: Optional[Union[str, "_models.ResultType"]] = None, + metricnamespace: Optional[str] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> "_models.BaselineResponse": """**Gets the baseline values for a resource**. :param resource_uri: The identifier of the resource. It has the following structure: @@ -97,47 +155,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 +186,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 a5b894a44c00..100616099a95 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,22 +6,120 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime -from typing import TYPE_CHECKING +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 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 +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +def build_get_request( + resource_uri: str, + metric_name: str, + *, + timespan: Optional[str] = None, + interval: Optional[datetime.timedelta] = None, + aggregation: Optional[str] = None, + sensitivities: Optional[str] = None, + result_type: Optional[Union[str, "_models.ResultType"]] = None, + metricnamespace: Optional[str] = None, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + 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: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) class MetricBaselineOperations(object): """MetricBaselineOperations operations. @@ -45,20 +143,20 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_uri, # type: str - metric_name, # type: str - timespan=None, # type: Optional[str] - interval=None, # type: Optional[datetime.timedelta] - aggregation=None, # type: Optional[str] - sensitivities=None, # type: Optional[str] - result_type=None, # type: Optional[Union[str, "_models.ResultType"]] - metricnamespace=None, # type: Optional[str] - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.BaselineResponse" + resource_uri: str, + metric_name: str, + timespan: Optional[str] = None, + interval: Optional[datetime.timedelta] = None, + aggregation: Optional[str] = None, + sensitivities: Optional[str] = None, + result_type: Optional[Union[str, "_models.ResultType"]] = None, + metricnamespace: Optional[str] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> "_models.BaselineResponse": """**Gets the baseline values for a specific metric**. :param resource_uri: The identifier of the resource. It has the following structure: @@ -95,46 +193,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,15 +224,17 @@ 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 - time_series_information, # type: "_models.TimeSeriesInformation" - **kwargs # type: Any - ): - # type: (...) -> "_models.CalculateBaselineResponse" + resource_uri: str, + time_series_information: "_models.TimeSeriesInformation", + **kwargs: Any + ) -> "_models.CalculateBaselineResponse": """**Lists the baseline values for a resource**. :param resource_uri: The identifier of the resource. It has the following structure: @@ -161,7 +244,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 +256,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] + + _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 = 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 +284,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 d82479510092..ec9090a57df0 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 3b7dbb10194c..97fb7d1dca33 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 @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -33,13 +31,12 @@ class MonitorManagementClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + **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" @@ -62,4 +59,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 108ef76686e1..f48dd5306487 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 4c8063f8d99d..a614ecab0d59 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,74 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -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 . 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 import TokenCredential -class MonitorManagementClient(object): +class MonitorManagementClient: """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] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MonitorManagementClientConfiguration(credential, **kwargs) + credential: "TokenCredential", + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + 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: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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 000000000000..74e48ecd07cf --- /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 000000000000..138f663c53a4 --- /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 cac9f5d10f8b..e5754a47ce68 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 96ce9b45c05b..4eba911f1c6e 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 d8d2e140bf30..77ea6d2eeead 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 d517e654aef7..d7e018bff1c2 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 000000000000..74e48ecd07cf --- /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 fa9ce068a20a..19cbf3f37127 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/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/__init__.py index 94c27fef8dc0..f574db4714d0 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/__init__.py @@ -6,20 +6,13 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import DataContainer - from ._models_py3 import Error - from ._models_py3 import ProxyResource - from ._models_py3 import ResponseWithError - from ._models_py3 import VMInsightsOnboardingStatus - from ._models_py3 import WorkspaceInfo -except (SyntaxError, ImportError): - from ._models import DataContainer # type: ignore - from ._models import Error # type: ignore - from ._models import ProxyResource # type: ignore - from ._models import ResponseWithError # type: ignore - from ._models import VMInsightsOnboardingStatus # type: ignore - from ._models import WorkspaceInfo # type: ignore +from ._models_py3 import DataContainer +from ._models_py3 import Error +from ._models_py3 import ProxyResource +from ._models_py3 import ResponseWithError +from ._models_py3 import VMInsightsOnboardingStatus +from ._models_py3 import WorkspaceInfo + from ._monitor_management_client_enums import ( DataStatus, 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 deleted file mode 100644 index 05352ea9024f..000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/_models.py +++ /dev/null @@ -1,213 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class DataContainer(msrest.serialization.Model): - """Information about a container with data for a given resource. - - 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 - """ - - _validation = { - 'workspace': {'required': True}, - } - - _attribute_map = { - 'workspace': {'key': 'workspace', 'type': 'WorkspaceInfo'}, - } - - def __init__( - self, - **kwargs - ): - super(DataContainer, self).__init__(**kwargs) - self.workspace = kwargs['workspace'] - - -class Error(msrest.serialization.Model): - """Error details. - - 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 - """ - - _validation = { - 'code': {'required': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Error, self).__init__(**kwargs) - self.code = kwargs['code'] - self.message = kwargs.get('message', None) - - -class ProxyResource(msrest.serialization.Model): - """An azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ProxyResource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class ResponseWithError(msrest.serialization.Model): - """An error response from the API. - - 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 - """ - - _validation = { - 'error': {'required': True}, - } - - _attribute_map = { - 'error': {'key': 'error', 'type': 'Error'}, - } - - def __init__( - self, - **kwargs - ): - super(ResponseWithError, self).__init__(**kwargs) - self.error = kwargs['error'] - - -class VMInsightsOnboardingStatus(ProxyResource): - """VM Insights onboarding status for a resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :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 - 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 - ~$(python-base-namespace).v2018_11_27_preview.models.OnboardingStatus - :param 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] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'resource_id': {'key': 'properties.resourceId', 'type': 'str'}, - 'onboarding_status': {'key': 'properties.onboardingStatus', 'type': 'str'}, - 'data_status': {'key': 'properties.dataStatus', 'type': 'str'}, - 'data': {'key': 'properties.data', 'type': '[DataContainer]'}, - } - - def __init__( - self, - **kwargs - ): - super(VMInsightsOnboardingStatus, self).__init__(**kwargs) - self.resource_id = kwargs.get('resource_id', None) - self.onboarding_status = kwargs.get('onboarding_status', None) - self.data_status = kwargs.get('data_status', None) - self.data = kwargs.get('data', None) - - -class WorkspaceInfo(msrest.serialization.Model): - """Information about a Log Analytics Workspace. - - 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 - """ - - _validation = { - 'id': {'required': True}, - 'location': {'required': True}, - 'customer_id': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'customer_id': {'key': 'properties.customerId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkspaceInfo, self).__init__(**kwargs) - self.id = kwargs['id'] - self.location = kwargs['location'] - self.customer_id = kwargs['customer_id'] 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 d377f3d4a19c..c30e574ee7a6 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 6e32583e2c0c..b3c335135ef7 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 323b2fefa1b0..e49f0661d35e 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,22 +5,55 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_onboarding_status_request( + resource_uri: str, + **kwargs: Any +) -> 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 + ) class VMInsightsOperations(object): """VMInsightsOperations operations. @@ -44,12 +77,12 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get_onboarding_status( self, - resource_uri, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.VMInsightsOnboardingStatus" + resource_uri: str, + **kwargs: Any + ) -> "_models.VMInsightsOnboardingStatus": """Retrieves the VM Insights onboarding status for the specified resource or resource scope. :param resource_uri: The fully qualified Azure Resource manager identifier of the resource, or @@ -65,31 +98,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 +121,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 d82479510092..ec9090a57df0 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 bae7197d4361..104015108097 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 @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class MonitorManagementClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(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 +65,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 1195426a660a..ec859da410c4 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 e8cda37fc5de..6c955bb8086c 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,25 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import 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 - -class MonitorManagementClient(object): +class MonitorManagementClient: """Monitor Management Client. :ivar action_groups: ActionGroupsOperations operations @@ -35,49 +32,53 @@ 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] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + 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: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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 000000000000..74e48ecd07cf --- /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 000000000000..138f663c53a4 --- /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 cac9f5d10f8b..e5754a47ce68 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 96ce9b45c05b..4eba911f1c6e 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 14d8957671d3..1c02bc997da3 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 1c5b2606dd68..a91a75c74e1c 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 000000000000..74e48ecd07cf --- /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 809dc6eb6dc6..676c2e368db1 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 da5a7bec335f..d785c4ebe121 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/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/__init__.py index d2c6946d97e5..10b07dab50dc 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/__init__.py @@ -6,52 +6,29 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import ActionGroupList - from ._models_py3 import ActionGroupPatchBody - from ._models_py3 import ActionGroupResource - from ._models_py3 import ArmRoleReceiver - from ._models_py3 import AutomationRunbookReceiver - from ._models_py3 import AzureAppPushReceiver - from ._models_py3 import AzureFunctionReceiver - from ._models_py3 import AzureResource - from ._models_py3 import BaselineMetadata - from ._models_py3 import EmailReceiver - from ._models_py3 import EnableRequest - from ._models_py3 import ErrorResponse - from ._models_py3 import ItsmReceiver - from ._models_py3 import LogicAppReceiver - from ._models_py3 import MetricBaselinesResponse - from ._models_py3 import MetricSingleDimension - from ._models_py3 import SingleBaseline - from ._models_py3 import SingleMetricBaseline - from ._models_py3 import SmsReceiver - from ._models_py3 import TimeSeriesBaseline - from ._models_py3 import VoiceReceiver - from ._models_py3 import WebhookReceiver -except (SyntaxError, ImportError): - from ._models import ActionGroupList # type: ignore - from ._models import ActionGroupPatchBody # type: ignore - from ._models import ActionGroupResource # type: ignore - from ._models import ArmRoleReceiver # type: ignore - from ._models import AutomationRunbookReceiver # type: ignore - from ._models import AzureAppPushReceiver # type: ignore - from ._models import AzureFunctionReceiver # type: ignore - from ._models import AzureResource # type: ignore - from ._models import BaselineMetadata # type: ignore - from ._models import EmailReceiver # type: ignore - from ._models import EnableRequest # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import ItsmReceiver # type: ignore - from ._models import LogicAppReceiver # type: ignore - from ._models import MetricBaselinesResponse # type: ignore - from ._models import MetricSingleDimension # type: ignore - from ._models import SingleBaseline # type: ignore - from ._models import SingleMetricBaseline # type: ignore - from ._models import SmsReceiver # type: ignore - from ._models import TimeSeriesBaseline # type: ignore - from ._models import VoiceReceiver # type: ignore - from ._models import WebhookReceiver # type: ignore +from ._models_py3 import ActionGroupList +from ._models_py3 import ActionGroupPatchBody +from ._models_py3 import ActionGroupResource +from ._models_py3 import ArmRoleReceiver +from ._models_py3 import AutomationRunbookReceiver +from ._models_py3 import AzureAppPushReceiver +from ._models_py3 import AzureFunctionReceiver +from ._models_py3 import AzureResource +from ._models_py3 import BaselineMetadata +from ._models_py3 import EmailReceiver +from ._models_py3 import EnableRequest +from ._models_py3 import ErrorResponse +from ._models_py3 import ItsmReceiver +from ._models_py3 import LogicAppReceiver +from ._models_py3 import MetricBaselinesResponse +from ._models_py3 import MetricSingleDimension +from ._models_py3 import SingleBaseline +from ._models_py3 import SingleMetricBaseline +from ._models_py3 import SmsReceiver +from ._models_py3 import TimeSeriesBaseline +from ._models_py3 import VoiceReceiver +from ._models_py3 import WebhookReceiver + from ._monitor_management_client_enums import ( BaselineSensitivity, 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 deleted file mode 100644 index 2276db6bcae0..000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/_models.py +++ /dev/null @@ -1,894 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class 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 - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ActionGroupResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ActionGroupList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -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 - enabled, then none of its actions will be activated. - :type enabled: bool - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(ActionGroupPatchBody, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.enabled = kwargs.get('enabled', True) - - -class AzureResource(msrest.serialization.Model): - """An azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar kind: Azure resource kind. - :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] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'readonly': True}, - 'identity': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureResource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.kind = None - self.identity = None - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - - -class ActionGroupResource(AzureResource): - """An action group resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar kind: Azure resource kind. - :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 - 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: - list[~$(python-base-namespace).v2019_03_01.models.AzureAppPushReceiver] - :param automation_runbook_receivers: The list of AutomationRunbook receivers that are part of - this action group. - :type 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 - action group. - :type 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. - 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] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'readonly': True}, - 'identity': {'readonly': True}, - 'location': {'required': True}, - 'group_short_name': {'max_length': 12, 'min_length': 0}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'group_short_name': {'key': 'properties.groupShortName', 'type': 'str'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - 'email_receivers': {'key': 'properties.emailReceivers', 'type': '[EmailReceiver]'}, - 'sms_receivers': {'key': 'properties.smsReceivers', 'type': '[SmsReceiver]'}, - 'webhook_receivers': {'key': 'properties.webhookReceivers', 'type': '[WebhookReceiver]'}, - 'itsm_receivers': {'key': 'properties.itsmReceivers', 'type': '[ItsmReceiver]'}, - 'azure_app_push_receivers': {'key': 'properties.azureAppPushReceivers', 'type': '[AzureAppPushReceiver]'}, - 'automation_runbook_receivers': {'key': 'properties.automationRunbookReceivers', 'type': '[AutomationRunbookReceiver]'}, - 'voice_receivers': {'key': 'properties.voiceReceivers', 'type': '[VoiceReceiver]'}, - 'logic_app_receivers': {'key': 'properties.logicAppReceivers', 'type': '[LogicAppReceiver]'}, - 'azure_function_receivers': {'key': 'properties.azureFunctionReceivers', 'type': '[AzureFunctionReceiver]'}, - 'arm_role_receivers': {'key': 'properties.armRoleReceivers', 'type': '[ArmRoleReceiver]'}, - } - - def __init__( - self, - **kwargs - ): - super(ActionGroupResource, self).__init__(**kwargs) - self.group_short_name = kwargs.get('group_short_name', None) - self.enabled = kwargs.get('enabled', True) - self.email_receivers = kwargs.get('email_receivers', None) - self.sms_receivers = kwargs.get('sms_receivers', None) - self.webhook_receivers = kwargs.get('webhook_receivers', None) - self.itsm_receivers = kwargs.get('itsm_receivers', None) - self.azure_app_push_receivers = kwargs.get('azure_app_push_receivers', None) - self.automation_runbook_receivers = kwargs.get('automation_runbook_receivers', None) - self.voice_receivers = kwargs.get('voice_receivers', None) - self.logic_app_receivers = kwargs.get('logic_app_receivers', None) - self.azure_function_receivers = kwargs.get('azure_function_receivers', None) - self.arm_role_receivers = kwargs.get('arm_role_receivers', None) - - -class ArmRoleReceiver(msrest.serialization.Model): - """An arm role receiver. - - 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 - 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 - """ - - _validation = { - 'name': {'required': True}, - 'role_id': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'role_id': {'key': 'roleId', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(ArmRoleReceiver, self).__init__(**kwargs) - self.name = kwargs['name'] - self.role_id = kwargs['role_id'] - self.use_common_alert_schema = kwargs.get('use_common_alert_schema', False) - - -class AutomationRunbookReceiver(msrest.serialization.Model): - """The Azure Automation Runbook notification receiver. - - 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 - """ - - _validation = { - 'automation_account_id': {'required': True}, - 'runbook_name': {'required': True}, - 'webhook_resource_id': {'required': True}, - 'is_global_runbook': {'required': True}, - } - - _attribute_map = { - 'automation_account_id': {'key': 'automationAccountId', 'type': 'str'}, - 'runbook_name': {'key': 'runbookName', 'type': 'str'}, - 'webhook_resource_id': {'key': 'webhookResourceId', 'type': 'str'}, - 'is_global_runbook': {'key': 'isGlobalRunbook', 'type': 'bool'}, - 'name': {'key': 'name', 'type': 'str'}, - 'service_uri': {'key': 'serviceUri', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(AutomationRunbookReceiver, self).__init__(**kwargs) - self.automation_account_id = kwargs['automation_account_id'] - self.runbook_name = kwargs['runbook_name'] - self.webhook_resource_id = kwargs['webhook_resource_id'] - self.is_global_runbook = kwargs['is_global_runbook'] - self.name = kwargs.get('name', None) - self.service_uri = kwargs.get('service_uri', None) - self.use_common_alert_schema = kwargs.get('use_common_alert_schema', False) - - -class AzureAppPushReceiver(msrest.serialization.Model): - """The Azure mobile App push notification receiver. - - 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 - 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 - """ - - _validation = { - 'name': {'required': True}, - 'email_address': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'email_address': {'key': 'emailAddress', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureAppPushReceiver, self).__init__(**kwargs) - self.name = kwargs['name'] - self.email_address = kwargs['email_address'] - - -class AzureFunctionReceiver(msrest.serialization.Model): - """An azure function receiver. - - 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 - 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 - """ - - _validation = { - 'name': {'required': True}, - 'function_app_resource_id': {'required': True}, - 'function_name': {'required': True}, - 'http_trigger_url': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'function_app_resource_id': {'key': 'functionAppResourceId', 'type': 'str'}, - 'function_name': {'key': 'functionName', 'type': 'str'}, - 'http_trigger_url': {'key': 'httpTriggerUrl', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureFunctionReceiver, self).__init__(**kwargs) - self.name = kwargs['name'] - self.function_app_resource_id = kwargs['function_app_resource_id'] - self.function_name = kwargs['function_name'] - self.http_trigger_url = kwargs['http_trigger_url'] - self.use_common_alert_schema = kwargs.get('use_common_alert_schema', False) - - -class BaselineMetadata(msrest.serialization.Model): - """Represents a baseline metadata value. - - 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 - """ - - _validation = { - 'name': {'required': True}, - 'value': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(BaselineMetadata, self).__init__(**kwargs) - self.name = kwargs['name'] - self.value = kwargs['value'] - - -class EmailReceiver(msrest.serialization.Model): - """An email receiver. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param 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 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 - """ - - _validation = { - 'name': {'required': True}, - 'email_address': {'required': True}, - 'status': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'email_address': {'key': 'emailAddress', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, - 'status': {'key': 'status', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EmailReceiver, self).__init__(**kwargs) - self.name = kwargs['name'] - self.email_address = kwargs['email_address'] - self.use_common_alert_schema = kwargs.get('use_common_alert_schema', False) - self.status = None - - -class EnableRequest(msrest.serialization.Model): - """Describes a receiver that should be resubscribed. - - 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 - """ - - _validation = { - 'receiver_name': {'required': True}, - } - - _attribute_map = { - 'receiver_name': {'key': 'receiverName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EnableRequest, self).__init__(**kwargs) - self.receiver_name = kwargs['receiver_name'] - - -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 - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - - -class ItsmReceiver(msrest.serialization.Model): - """An Itsm receiver. - - 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 - 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 - in above workspace. - :type connection_id: str - :param 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 - values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. - :type region: str - """ - - _validation = { - 'name': {'required': True}, - 'workspace_id': {'required': True}, - 'connection_id': {'required': True}, - 'ticket_configuration': {'required': True}, - 'region': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'workspace_id': {'key': 'workspaceId', 'type': 'str'}, - 'connection_id': {'key': 'connectionId', 'type': 'str'}, - 'ticket_configuration': {'key': 'ticketConfiguration', 'type': 'str'}, - 'region': {'key': 'region', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ItsmReceiver, self).__init__(**kwargs) - self.name = kwargs['name'] - self.workspace_id = kwargs['workspace_id'] - self.connection_id = kwargs['connection_id'] - self.ticket_configuration = kwargs['ticket_configuration'] - self.region = kwargs['region'] - - -class LogicAppReceiver(msrest.serialization.Model): - """A logic app receiver. - - 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 - 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 - """ - - _validation = { - 'name': {'required': True}, - 'resource_id': {'required': True}, - 'callback_url': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'callback_url': {'key': 'callbackUrl', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(LogicAppReceiver, self).__init__(**kwargs) - self.name = kwargs['name'] - self.resource_id = kwargs['resource_id'] - self.callback_url = kwargs['callback_url'] - self.use_common_alert_schema = kwargs.get('use_common_alert_schema', False) - - -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] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SingleMetricBaseline]'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricBaselinesResponse, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class MetricSingleDimension(msrest.serialization.Model): - """The metric dimension name and value. - - 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 - """ - - _validation = { - 'name': {'required': True}, - 'value': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricSingleDimension, self).__init__(**kwargs) - self.name = kwargs['name'] - self.value = kwargs['value'] - - -class SingleBaseline(msrest.serialization.Model): - """The baseline values for a single sensitivity value. - - All required parameters must be populated in order to send to Azure. - - :param 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] - """ - - _validation = { - 'sensitivity': {'required': True}, - 'low_thresholds': {'required': True}, - 'high_thresholds': {'required': True}, - } - - _attribute_map = { - 'sensitivity': {'key': 'sensitivity', 'type': 'str'}, - 'low_thresholds': {'key': 'lowThresholds', 'type': '[float]'}, - 'high_thresholds': {'key': 'highThresholds', 'type': '[float]'}, - } - - def __init__( - self, - **kwargs - ): - super(SingleBaseline, self).__init__(**kwargs) - self.sensitivity = kwargs['sensitivity'] - self.low_thresholds = kwargs['low_thresholds'] - self.high_thresholds = kwargs['high_thresholds'] - - -class SingleMetricBaseline(msrest.serialization.Model): - """The baseline results of a single metric. - - 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 - 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] - """ - - _validation = { - 'id': {'required': True}, - 'type': {'required': True}, - 'name': {'required': True}, - 'timespan': {'required': True}, - 'interval': {'required': True}, - 'baselines': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'timespan': {'key': 'properties.timespan', 'type': 'str'}, - 'interval': {'key': 'properties.interval', 'type': 'duration'}, - 'namespace': {'key': 'properties.namespace', 'type': 'str'}, - 'baselines': {'key': 'properties.baselines', 'type': '[TimeSeriesBaseline]'}, - } - - def __init__( - self, - **kwargs - ): - super(SingleMetricBaseline, self).__init__(**kwargs) - self.id = kwargs['id'] - self.type = kwargs['type'] - self.name = kwargs['name'] - self.timespan = kwargs['timespan'] - self.interval = kwargs['interval'] - self.namespace = kwargs.get('namespace', None) - self.baselines = kwargs['baselines'] - - -class SmsReceiver(msrest.serialization.Model): - """An SMS receiver. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param 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 - :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 - """ - - _validation = { - 'name': {'required': True}, - 'country_code': {'required': True}, - 'phone_number': {'required': True}, - 'status': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'country_code': {'key': 'countryCode', 'type': 'str'}, - 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SmsReceiver, self).__init__(**kwargs) - self.name = kwargs['name'] - self.country_code = kwargs['country_code'] - self.phone_number = kwargs['phone_number'] - self.status = None - - -class TimeSeriesBaseline(msrest.serialization.Model): - """The baseline values for a single time series. - - 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] - """ - - _validation = { - 'aggregation': {'required': True}, - 'timestamps': {'required': True}, - 'data': {'required': True}, - } - - _attribute_map = { - 'aggregation': {'key': 'aggregation', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[MetricSingleDimension]'}, - 'timestamps': {'key': 'timestamps', 'type': '[iso-8601]'}, - 'data': {'key': 'data', 'type': '[SingleBaseline]'}, - 'metadata_values': {'key': 'metadataValues', 'type': '[BaselineMetadata]'}, - } - - def __init__( - self, - **kwargs - ): - super(TimeSeriesBaseline, self).__init__(**kwargs) - self.aggregation = kwargs['aggregation'] - self.dimensions = kwargs.get('dimensions', None) - self.timestamps = kwargs['timestamps'] - self.data = kwargs['data'] - self.metadata_values = kwargs.get('metadata_values', None) - - -class VoiceReceiver(msrest.serialization.Model): - """A voice receiver. - - 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 - """ - - _validation = { - 'name': {'required': True}, - 'country_code': {'required': True}, - 'phone_number': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'country_code': {'key': 'countryCode', 'type': 'str'}, - 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(VoiceReceiver, self).__init__(**kwargs) - self.name = kwargs['name'] - self.country_code = kwargs['country_code'] - self.phone_number = kwargs['phone_number'] - - -class WebhookReceiver(msrest.serialization.Model): - """A webhook receiver. - - 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 - 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 - """ - - _validation = { - 'name': {'required': True}, - 'service_uri': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'service_uri': {'key': 'serviceUri', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(WebhookReceiver, self).__init__(**kwargs) - self.name = kwargs['name'] - self.service_uri = kwargs['service_uri'] - self.use_common_alert_schema = kwargs.get('use_common_alert_schema', False) 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 fcf507eee081..2d8ad2bb5632 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 3c4ff02d458d..1bae2278d5d3 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 7be428a47714..6c31bafc5938 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,23 +5,292 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_or_update_request( + resource_group_name: str, + action_group_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + action_group_name: str, + subscription_id: str, + **kwargs: Any +) -> 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: str, + action_group_name: str, + subscription_id: str, + **kwargs: Any +) -> 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: str, + resource_group_name: str, + action_group_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_subscription_id_request( + subscription_id: str, + **kwargs: Any +) -> 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: str, + subscription_id: str, + **kwargs: Any +) -> 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: str, + action_group_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) class ActionGroupsOperations(object): """ActionGroupsOperations operations. @@ -45,17 +314,17 @@ 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 - action_group_name, # type: str - action_group, # type: "_models.ActionGroupResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.ActionGroupResource" + resource_group_name: str, + action_group_name: str, + action_group: "_models.ActionGroupResource", + **kwargs: Any + ) -> "_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 +340,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,18 +374,20 @@ 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 - action_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ActionGroupResource" + resource_group_name: str, + action_group_name: str, + **kwargs: Any + ) -> "_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 +401,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,18 +426,20 @@ 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 - action_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + action_group_name: str, + **kwargs: Any + ) -> 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,17 +477,18 @@ 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 - action_group_name, # type: str - action_group_patch, # type: "_models.ActionGroupPatchBody" - **kwargs # type: Any - ): - # type: (...) -> "_models.ActionGroupResource" + resource_group_name: str, + action_group_name: str, + action_group_patch: "_models.ActionGroupPatchBody", + **kwargs: Any + ) -> "_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 +504,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,18 +534,21 @@ 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 - ): - # type: (...) -> Iterable["_models.ActionGroupList"] + **kwargs: Any + ) -> Iterable["_models.ActionGroupList"]: """Get a list of all action groups 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 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 +556,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,30 +591,32 @@ 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 - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ActionGroupList"] + resource_group_name: str, + **kwargs: Any + ) -> 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 +624,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,29 +661,30 @@ 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 - action_group_name, # type: str - enable_request, # type: "_models.EnableRequest" - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + action_group_name: str, + enable_request: "_models.EnableRequest", + **kwargs: Any + ) -> None: """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 +700,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 d880d7505e7b..acdd6b3620b6 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,23 +6,81 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + resource_uri: str, + *, + metricnames: Optional[str] = None, + metricnamespace: Optional[str] = None, + timespan: Optional[str] = None, + interval: Optional[datetime.timedelta] = None, + aggregation: Optional[str] = None, + sensitivities: Optional[str] = None, + filter: Optional[str] = None, + result_type: Optional[Union[str, "_models.ResultType"]] = None, + **kwargs: Any +) -> HttpRequest: + 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 + ) class BaselinesOperations(object): """BaselinesOperations operations. @@ -46,20 +104,20 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_uri, # type: str - metricnames=None, # type: Optional[str] - metricnamespace=None, # type: Optional[str] - timespan=None, # type: Optional[str] - interval=None, # type: Optional[datetime.timedelta] - aggregation=None, # type: Optional[str] - sensitivities=None, # type: Optional[str] - filter=None, # type: Optional[str] - result_type=None, # type: Optional[Union[str, "_models.ResultType"]] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.MetricBaselinesResponse"] + resource_uri: str, + metricnames: Optional[str] = None, + metricnamespace: Optional[str] = None, + timespan: Optional[str] = None, + interval: Optional[datetime.timedelta] = None, + aggregation: Optional[str] = None, + sensitivities: Optional[str] = None, + filter: Optional[str] = None, + result_type: Optional[Union[str, "_models.ResultType"]] = None, + **kwargs: Any + ) -> Iterable["_models.MetricBaselinesResponse"]: """**Lists the metric baseline values for a resource**. :param resource_uri: The identifier of the resource. @@ -96,8 +154,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 +165,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 +216,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 d82479510092..ec9090a57df0 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 21e5e61b754a..fd3c7aceb873 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 @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class MonitorManagementClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(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 +65,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 5e2ddffbca2b..86800ff33772 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 aa90ea634327..07d73bf58d4a 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,24 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -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 . 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 import TokenCredential -class MonitorManagementClient(object): +class MonitorManagementClient: """Monitor Management Client. :ivar action_groups: ActionGroupsOperations operations @@ -32,47 +30,52 @@ 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] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + 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: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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 000000000000..74e48ecd07cf --- /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 000000000000..138f663c53a4 --- /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 cac9f5d10f8b..e5754a47ce68 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 96ce9b45c05b..4eba911f1c6e 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 95f4e81a04ba..bbcc96275adc 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 e23a7c650d22..49caf9f19a61 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 000000000000..74e48ecd07cf --- /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 2920b224b86a..8c4ea9623876 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/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/__init__.py index c88038080b95..74d7521ff191 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/__init__.py @@ -6,40 +6,23 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import ActionGroupList - from ._models_py3 import ActionGroupPatchBody - from ._models_py3 import ActionGroupResource - from ._models_py3 import ArmRoleReceiver - from ._models_py3 import AutomationRunbookReceiver - from ._models_py3 import AzureAppPushReceiver - from ._models_py3 import AzureFunctionReceiver - from ._models_py3 import AzureResource - from ._models_py3 import EmailReceiver - from ._models_py3 import EnableRequest - from ._models_py3 import ErrorResponse - from ._models_py3 import ItsmReceiver - from ._models_py3 import LogicAppReceiver - from ._models_py3 import SmsReceiver - from ._models_py3 import VoiceReceiver - from ._models_py3 import WebhookReceiver -except (SyntaxError, ImportError): - from ._models import ActionGroupList # type: ignore - from ._models import ActionGroupPatchBody # type: ignore - from ._models import ActionGroupResource # type: ignore - from ._models import ArmRoleReceiver # type: ignore - from ._models import AutomationRunbookReceiver # type: ignore - from ._models import AzureAppPushReceiver # type: ignore - from ._models import AzureFunctionReceiver # type: ignore - from ._models import AzureResource # type: ignore - from ._models import EmailReceiver # type: ignore - from ._models import EnableRequest # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import ItsmReceiver # type: ignore - from ._models import LogicAppReceiver # type: ignore - from ._models import SmsReceiver # type: ignore - from ._models import VoiceReceiver # type: ignore - from ._models import WebhookReceiver # type: ignore +from ._models_py3 import ActionGroupList +from ._models_py3 import ActionGroupPatchBody +from ._models_py3 import ActionGroupResource +from ._models_py3 import ArmRoleReceiver +from ._models_py3 import AutomationRunbookReceiver +from ._models_py3 import AzureAppPushReceiver +from ._models_py3 import AzureFunctionReceiver +from ._models_py3 import AzureResource +from ._models_py3 import EmailReceiver +from ._models_py3 import EnableRequest +from ._models_py3 import ErrorResponse +from ._models_py3 import ItsmReceiver +from ._models_py3 import LogicAppReceiver +from ._models_py3 import SmsReceiver +from ._models_py3 import VoiceReceiver +from ._models_py3 import WebhookReceiver + from ._monitor_management_client_enums import ( ReceiverStatus, 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 deleted file mode 100644 index a23a384c9d9c..000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/_models.py +++ /dev/null @@ -1,694 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class 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 - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ActionGroupResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ActionGroupList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -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 - enabled, then none of its actions will be activated. - :type enabled: bool - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(ActionGroupPatchBody, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.enabled = kwargs.get('enabled', True) - - -class AzureResource(msrest.serialization.Model): - """An azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar kind: Azure resource kind. - :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] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'readonly': True}, - 'identity': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureResource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.kind = None - self.identity = None - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - - -class ActionGroupResource(AzureResource): - """An action group resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar kind: Azure resource kind. - :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 - 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: - list[~$(python-base-namespace).v2019_06_01.models.AzureAppPushReceiver] - :param automation_runbook_receivers: The list of AutomationRunbook receivers that are part of - this action group. - :type 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 - action group. - :type 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. - 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] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'readonly': True}, - 'identity': {'readonly': True}, - 'location': {'required': True}, - 'group_short_name': {'max_length': 12, 'min_length': 0}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'group_short_name': {'key': 'properties.groupShortName', 'type': 'str'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - 'email_receivers': {'key': 'properties.emailReceivers', 'type': '[EmailReceiver]'}, - 'sms_receivers': {'key': 'properties.smsReceivers', 'type': '[SmsReceiver]'}, - 'webhook_receivers': {'key': 'properties.webhookReceivers', 'type': '[WebhookReceiver]'}, - 'itsm_receivers': {'key': 'properties.itsmReceivers', 'type': '[ItsmReceiver]'}, - 'azure_app_push_receivers': {'key': 'properties.azureAppPushReceivers', 'type': '[AzureAppPushReceiver]'}, - 'automation_runbook_receivers': {'key': 'properties.automationRunbookReceivers', 'type': '[AutomationRunbookReceiver]'}, - 'voice_receivers': {'key': 'properties.voiceReceivers', 'type': '[VoiceReceiver]'}, - 'logic_app_receivers': {'key': 'properties.logicAppReceivers', 'type': '[LogicAppReceiver]'}, - 'azure_function_receivers': {'key': 'properties.azureFunctionReceivers', 'type': '[AzureFunctionReceiver]'}, - 'arm_role_receivers': {'key': 'properties.armRoleReceivers', 'type': '[ArmRoleReceiver]'}, - } - - def __init__( - self, - **kwargs - ): - super(ActionGroupResource, self).__init__(**kwargs) - self.group_short_name = kwargs.get('group_short_name', None) - self.enabled = kwargs.get('enabled', True) - self.email_receivers = kwargs.get('email_receivers', None) - self.sms_receivers = kwargs.get('sms_receivers', None) - self.webhook_receivers = kwargs.get('webhook_receivers', None) - self.itsm_receivers = kwargs.get('itsm_receivers', None) - self.azure_app_push_receivers = kwargs.get('azure_app_push_receivers', None) - self.automation_runbook_receivers = kwargs.get('automation_runbook_receivers', None) - self.voice_receivers = kwargs.get('voice_receivers', None) - self.logic_app_receivers = kwargs.get('logic_app_receivers', None) - self.azure_function_receivers = kwargs.get('azure_function_receivers', None) - self.arm_role_receivers = kwargs.get('arm_role_receivers', None) - - -class ArmRoleReceiver(msrest.serialization.Model): - """An arm role receiver. - - 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 - 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 - """ - - _validation = { - 'name': {'required': True}, - 'role_id': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'role_id': {'key': 'roleId', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(ArmRoleReceiver, self).__init__(**kwargs) - self.name = kwargs['name'] - self.role_id = kwargs['role_id'] - self.use_common_alert_schema = kwargs.get('use_common_alert_schema', False) - - -class AutomationRunbookReceiver(msrest.serialization.Model): - """The Azure Automation Runbook notification receiver. - - 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 - """ - - _validation = { - 'automation_account_id': {'required': True}, - 'runbook_name': {'required': True}, - 'webhook_resource_id': {'required': True}, - 'is_global_runbook': {'required': True}, - } - - _attribute_map = { - 'automation_account_id': {'key': 'automationAccountId', 'type': 'str'}, - 'runbook_name': {'key': 'runbookName', 'type': 'str'}, - 'webhook_resource_id': {'key': 'webhookResourceId', 'type': 'str'}, - 'is_global_runbook': {'key': 'isGlobalRunbook', 'type': 'bool'}, - 'name': {'key': 'name', 'type': 'str'}, - 'service_uri': {'key': 'serviceUri', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(AutomationRunbookReceiver, self).__init__(**kwargs) - self.automation_account_id = kwargs['automation_account_id'] - self.runbook_name = kwargs['runbook_name'] - self.webhook_resource_id = kwargs['webhook_resource_id'] - self.is_global_runbook = kwargs['is_global_runbook'] - self.name = kwargs.get('name', None) - self.service_uri = kwargs.get('service_uri', None) - self.use_common_alert_schema = kwargs.get('use_common_alert_schema', False) - - -class AzureAppPushReceiver(msrest.serialization.Model): - """The Azure mobile App push notification receiver. - - 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 - 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 - """ - - _validation = { - 'name': {'required': True}, - 'email_address': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'email_address': {'key': 'emailAddress', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureAppPushReceiver, self).__init__(**kwargs) - self.name = kwargs['name'] - self.email_address = kwargs['email_address'] - - -class AzureFunctionReceiver(msrest.serialization.Model): - """An azure function receiver. - - 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 - 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 - """ - - _validation = { - 'name': {'required': True}, - 'function_app_resource_id': {'required': True}, - 'function_name': {'required': True}, - 'http_trigger_url': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'function_app_resource_id': {'key': 'functionAppResourceId', 'type': 'str'}, - 'function_name': {'key': 'functionName', 'type': 'str'}, - 'http_trigger_url': {'key': 'httpTriggerUrl', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureFunctionReceiver, self).__init__(**kwargs) - self.name = kwargs['name'] - self.function_app_resource_id = kwargs['function_app_resource_id'] - self.function_name = kwargs['function_name'] - self.http_trigger_url = kwargs['http_trigger_url'] - self.use_common_alert_schema = kwargs.get('use_common_alert_schema', False) - - -class EmailReceiver(msrest.serialization.Model): - """An email receiver. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param 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 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 - """ - - _validation = { - 'name': {'required': True}, - 'email_address': {'required': True}, - 'status': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'email_address': {'key': 'emailAddress', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, - 'status': {'key': 'status', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EmailReceiver, self).__init__(**kwargs) - self.name = kwargs['name'] - self.email_address = kwargs['email_address'] - self.use_common_alert_schema = kwargs.get('use_common_alert_schema', False) - self.status = None - - -class EnableRequest(msrest.serialization.Model): - """Describes a receiver that should be resubscribed. - - 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 - """ - - _validation = { - 'receiver_name': {'required': True}, - } - - _attribute_map = { - 'receiver_name': {'key': 'receiverName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EnableRequest, self).__init__(**kwargs) - self.receiver_name = kwargs['receiver_name'] - - -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 - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - - -class ItsmReceiver(msrest.serialization.Model): - """An Itsm receiver. - - 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 - 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 - in above workspace. - :type connection_id: str - :param 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 - values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. - :type region: str - """ - - _validation = { - 'name': {'required': True}, - 'workspace_id': {'required': True}, - 'connection_id': {'required': True}, - 'ticket_configuration': {'required': True}, - 'region': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'workspace_id': {'key': 'workspaceId', 'type': 'str'}, - 'connection_id': {'key': 'connectionId', 'type': 'str'}, - 'ticket_configuration': {'key': 'ticketConfiguration', 'type': 'str'}, - 'region': {'key': 'region', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ItsmReceiver, self).__init__(**kwargs) - self.name = kwargs['name'] - self.workspace_id = kwargs['workspace_id'] - self.connection_id = kwargs['connection_id'] - self.ticket_configuration = kwargs['ticket_configuration'] - self.region = kwargs['region'] - - -class LogicAppReceiver(msrest.serialization.Model): - """A logic app receiver. - - 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 - 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 - """ - - _validation = { - 'name': {'required': True}, - 'resource_id': {'required': True}, - 'callback_url': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'callback_url': {'key': 'callbackUrl', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(LogicAppReceiver, self).__init__(**kwargs) - self.name = kwargs['name'] - self.resource_id = kwargs['resource_id'] - self.callback_url = kwargs['callback_url'] - self.use_common_alert_schema = kwargs.get('use_common_alert_schema', False) - - -class SmsReceiver(msrest.serialization.Model): - """An SMS receiver. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param 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 - :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 - """ - - _validation = { - 'name': {'required': True}, - 'country_code': {'required': True}, - 'phone_number': {'required': True}, - 'status': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'country_code': {'key': 'countryCode', 'type': 'str'}, - 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SmsReceiver, self).__init__(**kwargs) - self.name = kwargs['name'] - self.country_code = kwargs['country_code'] - self.phone_number = kwargs['phone_number'] - self.status = None - - -class VoiceReceiver(msrest.serialization.Model): - """A voice receiver. - - 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 - """ - - _validation = { - 'name': {'required': True}, - 'country_code': {'required': True}, - 'phone_number': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'country_code': {'key': 'countryCode', 'type': 'str'}, - 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(VoiceReceiver, self).__init__(**kwargs) - self.name = kwargs['name'] - self.country_code = kwargs['country_code'] - self.phone_number = kwargs['phone_number'] - - -class WebhookReceiver(msrest.serialization.Model): - """A webhook receiver. - - 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 - 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 - """ - - _validation = { - 'name': {'required': True}, - 'service_uri': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'service_uri': {'key': 'serviceUri', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, - 'use_aad_auth': {'key': 'useAadAuth', 'type': 'bool'}, - 'object_id': {'key': 'objectId', 'type': 'str'}, - 'identifier_uri': {'key': 'identifierUri', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WebhookReceiver, self).__init__(**kwargs) - self.name = kwargs['name'] - self.service_uri = kwargs['service_uri'] - self.use_common_alert_schema = kwargs.get('use_common_alert_schema', False) - self.use_aad_auth = kwargs.get('use_aad_auth', False) - self.object_id = kwargs.get('object_id', None) - self.identifier_uri = kwargs.get('identifier_uri', None) - self.tenant_id = kwargs.get('tenant_id', None) 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 5d5c8528ce62..5e0a25f65ada 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 238df22ea2f0..5e8a759db49c 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 cc8b99ea162a..95eedacf8e7c 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,23 +5,292 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_or_update_request( + resource_group_name: str, + action_group_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + action_group_name: str, + subscription_id: str, + **kwargs: Any +) -> 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: str, + action_group_name: str, + subscription_id: str, + **kwargs: Any +) -> 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: str, + resource_group_name: str, + action_group_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_subscription_id_request( + subscription_id: str, + **kwargs: Any +) -> 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: str, + subscription_id: str, + **kwargs: Any +) -> 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: str, + action_group_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) class ActionGroupsOperations(object): """ActionGroupsOperations operations. @@ -45,17 +314,17 @@ 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 - action_group_name, # type: str - action_group, # type: "_models.ActionGroupResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.ActionGroupResource" + resource_group_name: str, + action_group_name: str, + action_group: "_models.ActionGroupResource", + **kwargs: Any + ) -> "_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 +340,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,18 +374,20 @@ 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 - action_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ActionGroupResource" + resource_group_name: str, + action_group_name: str, + **kwargs: Any + ) -> "_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 +401,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,18 +426,20 @@ 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 - action_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + action_group_name: str, + **kwargs: Any + ) -> 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,17 +477,18 @@ 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 - action_group_name, # type: str - action_group_patch, # type: "_models.ActionGroupPatchBody" - **kwargs # type: Any - ): - # type: (...) -> "_models.ActionGroupResource" + resource_group_name: str, + action_group_name: str, + action_group_patch: "_models.ActionGroupPatchBody", + **kwargs: Any + ) -> "_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 +504,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,18 +534,21 @@ 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 - ): - # type: (...) -> Iterable["_models.ActionGroupList"] + **kwargs: Any + ) -> Iterable["_models.ActionGroupList"]: """Get a list of all action groups 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 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 +556,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,30 +591,32 @@ 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 - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ActionGroupList"] + resource_group_name: str, + **kwargs: Any + ) -> 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 +624,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,29 +661,30 @@ 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 - action_group_name, # type: str - enable_request, # type: "_models.EnableRequest" - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + action_group_name: str, + enable_request: "_models.EnableRequest", + **kwargs: Any + ) -> None: """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 +700,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 d82479510092..ec9090a57df0 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 3dad54793336..ba079fc9b32a 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 @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class MonitorManagementClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(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 +65,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 fec9dc40f6cb..c1ab58204142 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 fed0b405d309..7ec772089c38 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,95 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import 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 - -class MonitorManagementClient(object): +class MonitorManagementClient: """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] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + 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: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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 000000000000..74e48ecd07cf --- /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 000000000000..138f663c53a4 --- /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 cac9f5d10f8b..e5754a47ce68 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 96ce9b45c05b..4eba911f1c6e 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 4579dfddfc72..26c8b9416b5d 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 1fce9050d8f0..33dce3625e85 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 000000000000..74e48ecd07cf --- /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 239eddf9047e..33fca8708f69 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 7f2fb9820728..4883f725b439 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 398fb3531b9f..722da8748b6b 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 577349ea983d..b7a1d087b441 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 1c9d4b02e026..e0e17418bd24 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/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/models/__init__.py index 7d6d0e43f7ca..420b31912035 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/models/__init__.py @@ -6,42 +6,24 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import AzureMonitorPrivateLinkScope - from ._models_py3 import AzureMonitorPrivateLinkScopeListResult - from ._models_py3 import ErrorAdditionalInfo - from ._models_py3 import ErrorResponse - from ._models_py3 import ErrorResponseCommon - from ._models_py3 import OperationStatus - from ._models_py3 import PrivateEndpointConnection - from ._models_py3 import PrivateEndpointConnectionListResult - from ._models_py3 import PrivateEndpointProperty - from ._models_py3 import PrivateLinkResource - from ._models_py3 import PrivateLinkResourceListResult - from ._models_py3 import PrivateLinkScopesResource - from ._models_py3 import PrivateLinkServiceConnectionStateProperty - from ._models_py3 import ProxyResource - from ._models_py3 import ScopedResource - from ._models_py3 import ScopedResourceListResult - from ._models_py3 import TagsResource -except (SyntaxError, ImportError): - from ._models import AzureMonitorPrivateLinkScope # type: ignore - from ._models import AzureMonitorPrivateLinkScopeListResult # type: ignore - from ._models import ErrorAdditionalInfo # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import ErrorResponseCommon # type: ignore - from ._models import OperationStatus # type: ignore - from ._models import PrivateEndpointConnection # type: ignore - from ._models import PrivateEndpointConnectionListResult # type: ignore - from ._models import PrivateEndpointProperty # type: ignore - from ._models import PrivateLinkResource # type: ignore - from ._models import PrivateLinkResourceListResult # type: ignore - from ._models import PrivateLinkScopesResource # type: ignore - from ._models import PrivateLinkServiceConnectionStateProperty # type: ignore - from ._models import ProxyResource # type: ignore - from ._models import ScopedResource # type: ignore - from ._models import ScopedResourceListResult # type: ignore - from ._models import TagsResource # type: ignore +from ._models_py3 import AzureMonitorPrivateLinkScope +from ._models_py3 import AzureMonitorPrivateLinkScopeListResult +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorResponse +from ._models_py3 import ErrorResponseCommon +from ._models_py3 import OperationStatus +from ._models_py3 import PrivateEndpointConnection +from ._models_py3 import PrivateEndpointConnectionListResult +from ._models_py3 import PrivateEndpointProperty +from ._models_py3 import PrivateLinkResource +from ._models_py3 import PrivateLinkResourceListResult +from ._models_py3 import PrivateLinkScopesResource +from ._models_py3 import PrivateLinkServiceConnectionStateProperty +from ._models_py3 import ProxyResource +from ._models_py3 import ScopedResource +from ._models_py3 import ScopedResourceListResult +from ._models_py3 import TagsResource + __all__ = [ 'AzureMonitorPrivateLinkScope', 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 deleted file mode 100644 index fbe1212940c5..000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/models/_models.py +++ /dev/null @@ -1,598 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import msrest.serialization - - -class PrivateLinkScopesResource(msrest.serialization.Model): - """An azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :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] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateLinkScopesResource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - - -class AzureMonitorPrivateLinkScope(PrivateLinkScopesResource): - """An Azure Monitor PrivateLinkScope definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :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 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. - :vartype provisioning_state: str - :ivar private_endpoint_connections: List of private endpoint connections. - :vartype private_endpoint_connections: - list[~$(python-base-namespace).v2019_10_17.models.PrivateEndpointConnection] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'private_endpoint_connections': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureMonitorPrivateLinkScope, self).__init__(**kwargs) - self.provisioning_state = None - self.private_endpoint_connections = None - - -class AzureMonitorPrivateLinkScopeListResult(msrest.serialization.Model): - """Describes the list of Azure Monitor PrivateLinkScope resources. - - 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 - too many PrivateLinkScopes where returned in the result set. - :type next_link: str - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[AzureMonitorPrivateLinkScope]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureMonitorPrivateLinkScopeListResult, self).__init__(**kwargs) - self.value = kwargs['value'] - self.next_link = kwargs.get('next_link', None) - - -class ErrorAdditionalInfo(msrest.serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: any - """ - - _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorAdditionalInfo, self).__init__(**kwargs) - self.type = None - self.info = None - - -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 - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - - -class ErrorResponseCommon(ErrorResponse): - """The resource management error response. - - 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 details: The error details. - :vartype details: list[~$(python-base-namespace).v2019_10_17.models.ErrorResponseCommon] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~$(python-base-namespace).v2019_10_17.models.ErrorAdditionalInfo] - """ - - _validation = { - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponseCommon]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponseCommon, self).__init__(**kwargs) - self.details = None - self.additional_info = None - - -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 - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'status': {'key': 'status', 'type': 'str'}, - 'error': {'key': 'error', 'type': 'ErrorResponseCommon'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationStatus, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.name = kwargs.get('name', None) - self.start_time = kwargs.get('start_time', None) - self.end_time = kwargs.get('end_time', None) - self.status = kwargs.get('status', None) - self.error = kwargs.get('error', None) - - -class ProxyResource(msrest.serialization.Model): - """An azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ProxyResource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class PrivateEndpointConnection(ProxyResource): - """A private endpoint connection. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :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 - connection. - :type 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 - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'private_endpoint': {'key': 'properties.privateEndpoint', 'type': 'PrivateEndpointProperty'}, - 'private_link_service_connection_state': {'key': 'properties.privateLinkServiceConnectionState', 'type': 'PrivateLinkServiceConnectionStateProperty'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - 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) - self.provisioning_state = None - - -class PrivateEndpointConnectionListResult(msrest.serialization.Model): - """A list of private endpoint connections. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~$(python-base-namespace).v2019_10_17.models.PrivateEndpointConnection] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateEndpointConnection]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class PrivateEndpointProperty(msrest.serialization.Model): - """Private endpoint which the connection belongs to. - - :param id: Resource id of the private endpoint. - :type id: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateEndpointProperty, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - - -class PrivateLinkResource(ProxyResource): - """A private link resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar group_id: The private link resource group id. - :vartype group_id: str - :ivar required_members: The private link resource required member names. - :vartype required_members: list[str] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'group_id': {'readonly': True}, - 'required_members': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'group_id': {'key': 'properties.groupId', 'type': 'str'}, - 'required_members': {'key': 'properties.requiredMembers', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateLinkResource, self).__init__(**kwargs) - self.group_id = None - self.required_members = None - - -class PrivateLinkResourceListResult(msrest.serialization.Model): - """A list of private link resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~$(python-base-namespace).v2019_10_17.models.PrivateLinkResource] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateLinkResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateLinkResourceListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class PrivateLinkServiceConnectionStateProperty(msrest.serialization.Model): - """State of the private endpoint connection. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param status: Required. The private link service connection status. - :type status: str - :param description: Required. The private link service connection description. - :type description: str - :ivar actions_required: The actions required for private link service connection. - :vartype actions_required: str - """ - - _validation = { - 'status': {'required': True}, - 'description': {'required': True}, - 'actions_required': {'readonly': True}, - } - - _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'actions_required': {'key': 'actionsRequired', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateLinkServiceConnectionStateProperty, self).__init__(**kwargs) - self.status = kwargs['status'] - self.description = kwargs['description'] - self.actions_required = None - - -class ScopedResource(ProxyResource): - """A private link scoped resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :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 provisioning_state: State of the private endpoint connection. - :vartype provisioning_state: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'linked_resource_id': {'key': 'properties.linkedResourceId', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ScopedResource, self).__init__(**kwargs) - self.linked_resource_id = kwargs.get('linked_resource_id', None) - self.provisioning_state = None - - -class ScopedResourceListResult(msrest.serialization.Model): - """A list of scoped resources in a private link scope. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of results. - :vartype value: list[~$(python-base-namespace).v2019_10_17.models.ScopedResource] - :ivar next_link: Link to retrieve next page of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ScopedResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ScopedResourceListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -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] - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - 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 a26b257a2327..58910cffafcd 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 0b05c290c9f0..564be0f4fcd0 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,25 +5,177 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.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 - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + subscription_id: str, + resource_group_name: str, + scope_name: str, + private_endpoint_connection_name: str, + **kwargs: Any +) -> 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: str, + resource_group_name: str, + scope_name: str, + private_endpoint_connection_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + scope_name: str, + private_endpoint_connection_name: str, + **kwargs: Any +) -> 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: str, + resource_group_name: str, + scope_name: str, + **kwargs: Any +) -> 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 + ) class PrivateEndpointConnectionsOperations(object): """PrivateEndpointConnectionsOperations operations. @@ -47,17 +199,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - scope_name, # type: str - private_endpoint_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PrivateEndpointConnection" + resource_group_name: str, + scope_name: str, + private_endpoint_connection_name: str, + **kwargs: Any + ) -> "_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 +225,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,49 +250,40 @@ 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 - scope_name, # type: str - private_endpoint_connection_name, # type: str - parameters, # type: "_models.PrivateEndpointConnection" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.PrivateEndpointConnection"] + resource_group_name: str, + scope_name: str, + private_endpoint_connection_name: str, + parameters: "_models.PrivateEndpointConnection", + **kwargs: Any + ) -> Optional["_models.PrivateEndpointConnection"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PrivateEndpointConnection"]] error_map = { 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,20 +299,22 @@ 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 - scope_name, # type: str - private_endpoint_connection_name, # type: str - parameters, # type: "_models.PrivateEndpointConnection" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.PrivateEndpointConnection"] + resource_group_name: str, + scope_name: str, + private_endpoint_connection_name: str, + parameters: "_models.PrivateEndpointConnection", + **kwargs: Any + ) -> 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 +324,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 +350,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,41 +376,33 @@ 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( self, - resource_group_name, # type: str - scope_name, # type: str - private_endpoint_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + scope_name: str, + private_endpoint_connection_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-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,17 +415,18 @@ 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 - scope_name, # type: str - private_endpoint_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + scope_name: str, + private_endpoint_connection_name: str, + **kwargs: Any + ) -> 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 +434,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 +459,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,24 +478,27 @@ 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 - scope_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PrivateEndpointConnectionListResult"] + resource_group_name: str, + scope_name: str, + **kwargs: Any + ) -> 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 +506,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 +550,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 669f69362ef8..d24fddbe4013 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,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. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_private_link_scope_request( + subscription_id: str, + resource_group_name: str, + scope_name: str, + **kwargs: Any +) -> 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: str, + resource_group_name: str, + scope_name: str, + group_name: str, + **kwargs: Any +) -> 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 + ) class PrivateLinkResourcesOperations(object): """PrivateLinkResourcesOperations operations. @@ -45,22 +119,24 @@ 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 - scope_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PrivateLinkResourceListResult"] + resource_group_name: str, + scope_name: str, + **kwargs: Any + ) -> 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 +144,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,22 +188,23 @@ 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 - scope_name, # type: str - group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PrivateLinkResource" + resource_group_name: str, + scope_name: str, + group_name: str, + **kwargs: Any + ) -> "_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 +220,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 +245,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 e2af92cf6529..10d19919d2a1 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,22 +5,59 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, 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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + async_operation_id: str, + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> 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 + ) class PrivateLinkScopeOperationStatusOperations(object): """PrivateLinkScopeOperationStatusOperations operations. @@ -44,19 +81,19 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - async_operation_id, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.OperationStatus" + async_operation_id: str, + resource_group_name: str, + **kwargs: Any + ) -> "_models.OperationStatus": """Get the status of an azure asynchronous operation associated with a private link scope operation. :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 +105,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') + + 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) - # 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 @@ -102,4 +129,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 1766c14357ae..29ef35a608df 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,25 +5,177 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.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 - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + subscription_id: str, + resource_group_name: str, + scope_name: str, + name: str, + **kwargs: Any +) -> 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: str, + resource_group_name: str, + scope_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + scope_name: str, + name: str, + **kwargs: Any +) -> 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: str, + resource_group_name: str, + scope_name: str, + **kwargs: Any +) -> 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 + ) class PrivateLinkScopedResourcesOperations(object): """PrivateLinkScopedResourcesOperations operations. @@ -47,17 +199,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - scope_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ScopedResource" + resource_group_name: str, + scope_name: str, + name: str, + **kwargs: Any + ) -> "_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 +225,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,49 +250,40 @@ 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 - scope_name, # type: str - name, # type: str - parameters, # type: "_models.ScopedResource" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ScopedResource"] + resource_group_name: str, + scope_name: str, + name: str, + parameters: "_models.ScopedResource", + **kwargs: Any + ) -> Optional["_models.ScopedResource"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ScopedResource"]] error_map = { 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,20 +302,22 @@ 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 - scope_name, # type: str - name, # type: str - parameters, # type: "_models.ScopedResource" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ScopedResource"] + resource_group_name: str, + scope_name: str, + name: str, + parameters: "_models.ScopedResource", + **kwargs: Any + ) -> 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 +327,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 +353,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,41 +379,33 @@ 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( self, - resource_group_name, # type: str - scope_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + scope_name: str, + name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-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,17 +418,18 @@ 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 - scope_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + scope_name: str, + name: str, + **kwargs: Any + ) -> 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 +437,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 +462,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,24 +481,27 @@ 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 - scope_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ScopedResourceListResult"] + resource_group_name: str, + scope_name: str, + **kwargs: Any + ) -> 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 +509,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 +553,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 814a9efd7183..1679732ffcae 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,25 +5,244 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.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 - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> 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: str, + subscription_id: str, + **kwargs: Any +) -> 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: str, + subscription_id: str, + scope_name: str, + **kwargs: Any +) -> 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: str, + subscription_id: str, + scope_name: str, + **kwargs: Any +) -> 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: str, + subscription_id: str, + scope_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_update_tags_request( + resource_group_name: str, + subscription_id: str, + scope_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) class PrivateLinkScopesOperations(object): """PrivateLinkScopesOperations operations. @@ -47,16 +266,18 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AzureMonitorPrivateLinkScopeListResult"] + **kwargs: Any + ) -> Iterable["_models.AzureMonitorPrivateLinkScopeListResult"]: """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 +285,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,24 +325,27 @@ 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 - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AzureMonitorPrivateLinkScopeListResult"] + resource_group_name: str, + **kwargs: Any + ) -> 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 +353,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 +395,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -187,35 +403,26 @@ def get_next(next_link=None): def _delete_initial( self, - resource_group_name, # type: str - scope_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + scope_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-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,30 +435,33 @@ 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 - scope_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + scope_name: str, + **kwargs: Any + ) -> 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 +475,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,18 +494,19 @@ 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 - scope_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AzureMonitorPrivateLinkScope" + resource_group_name: str, + scope_name: str, + **kwargs: Any + ) -> "_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 +520,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,26 +544,29 @@ 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 - scope_name, # type: str - azure_monitor_private_link_scope_payload, # type: "_models.AzureMonitorPrivateLinkScope" - **kwargs # type: Any - ): - # type: (...) -> "_models.AzureMonitorPrivateLinkScope" + resource_group_name: str, + scope_name: str, + azure_monitor_private_link_scope_payload: "_models.AzureMonitorPrivateLinkScope", + **kwargs: Any + ) -> "_models.AzureMonitorPrivateLinkScope": """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 +577,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,20 +610,22 @@ 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 - scope_name, # type: str - private_link_scope_tags, # type: "_models.TagsResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.AzureMonitorPrivateLinkScope" + resource_group_name: str, + scope_name: str, + private_link_scope_tags: "_models.TagsResource", + **kwargs: Any + ) -> "_models.AzureMonitorPrivateLinkScope": """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 +642,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 +671,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 d82479510092..ec9090a57df0 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 17ffb143fc7e..3976d687afde 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 @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class MonitorManagementClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(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 +65,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 2948f6d358e5..34885a43497c 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 4cdf02aa7cac..3c59bcc99068 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,81 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import 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 - -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.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] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + 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: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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 000000000000..74e48ecd07cf --- /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 000000000000..138f663c53a4 --- /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 cac9f5d10f8b..e5754a47ce68 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 96ce9b45c05b..4eba911f1c6e 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 77e781a7e219..2dc886a8a1f4 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 25ca1c442b6d..ea9134b6ffef 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 000000000000..74e48ecd07cf --- /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 9cbf0246fd81..d7bca3542c6d 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 29bce722e889..c08041431504 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/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/__init__.py index 9da80ac0fffc..fc90ea637b48 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/__init__.py @@ -6,56 +6,31 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import AzureMonitorMetricsDestination - from ._models_py3 import DataCollectionRule - from ._models_py3 import DataCollectionRuleAssociation - from ._models_py3 import DataCollectionRuleAssociationProxyOnlyResource - from ._models_py3 import DataCollectionRuleAssociationProxyOnlyResourceListResult - from ._models_py3 import DataCollectionRuleAssociationProxyOnlyResourceProperties - from ._models_py3 import DataCollectionRuleDataSources - from ._models_py3 import DataCollectionRuleDestinations - from ._models_py3 import DataCollectionRuleResource - from ._models_py3 import DataCollectionRuleResourceListResult - from ._models_py3 import DataCollectionRuleResourceProperties - from ._models_py3 import DataFlow - from ._models_py3 import DataSourcesSpec - from ._models_py3 import DestinationsSpec - from ._models_py3 import DestinationsSpecAzureMonitorMetrics - from ._models_py3 import ErrorAdditionalInfo - from ._models_py3 import ErrorDetail - from ._models_py3 import ErrorResponse - from ._models_py3 import ExtensionDataSource - from ._models_py3 import LogAnalyticsDestination - from ._models_py3 import PerfCounterDataSource - from ._models_py3 import ResourceForUpdate - from ._models_py3 import SyslogDataSource - from ._models_py3 import WindowsEventLogDataSource -except (SyntaxError, ImportError): - from ._models import AzureMonitorMetricsDestination # type: ignore - from ._models import DataCollectionRule # type: ignore - from ._models import DataCollectionRuleAssociation # type: ignore - from ._models import DataCollectionRuleAssociationProxyOnlyResource # type: ignore - from ._models import DataCollectionRuleAssociationProxyOnlyResourceListResult # type: ignore - from ._models import DataCollectionRuleAssociationProxyOnlyResourceProperties # type: ignore - from ._models import DataCollectionRuleDataSources # type: ignore - from ._models import DataCollectionRuleDestinations # type: ignore - from ._models import DataCollectionRuleResource # type: ignore - from ._models import DataCollectionRuleResourceListResult # type: ignore - from ._models import DataCollectionRuleResourceProperties # type: ignore - from ._models import DataFlow # type: ignore - from ._models import DataSourcesSpec # type: ignore - from ._models import DestinationsSpec # type: ignore - from ._models import DestinationsSpecAzureMonitorMetrics # type: ignore - from ._models import ErrorAdditionalInfo # type: ignore - from ._models import ErrorDetail # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import ExtensionDataSource # type: ignore - from ._models import LogAnalyticsDestination # type: ignore - from ._models import PerfCounterDataSource # type: ignore - from ._models import ResourceForUpdate # type: ignore - from ._models import SyslogDataSource # type: ignore - from ._models import WindowsEventLogDataSource # type: ignore +from ._models_py3 import AzureMonitorMetricsDestination +from ._models_py3 import DataCollectionRule +from ._models_py3 import DataCollectionRuleAssociation +from ._models_py3 import DataCollectionRuleAssociationProxyOnlyResource +from ._models_py3 import DataCollectionRuleAssociationProxyOnlyResourceListResult +from ._models_py3 import DataCollectionRuleAssociationProxyOnlyResourceProperties +from ._models_py3 import DataCollectionRuleDataSources +from ._models_py3 import DataCollectionRuleDestinations +from ._models_py3 import DataCollectionRuleResource +from ._models_py3 import DataCollectionRuleResourceListResult +from ._models_py3 import DataCollectionRuleResourceProperties +from ._models_py3 import DataFlow +from ._models_py3 import DataSourcesSpec +from ._models_py3 import DestinationsSpec +from ._models_py3 import DestinationsSpecAzureMonitorMetrics +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse +from ._models_py3 import ExtensionDataSource +from ._models_py3 import LogAnalyticsDestination +from ._models_py3 import PerfCounterDataSource +from ._models_py3 import ResourceForUpdate +from ._models_py3 import SyslogDataSource +from ._models_py3 import WindowsEventLogDataSource + from ._monitor_management_client_enums import ( KnownDataCollectionRuleAssociationProvisioningState, 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 deleted file mode 100644 index e5edb02c607c..000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/_models.py +++ /dev/null @@ -1,869 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class AzureMonitorMetricsDestination(msrest.serialization.Model): - """Azure Monitor Metrics destination. - - :param 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 - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureMonitorMetricsDestination, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - - -class DataCollectionRule(msrest.serialization.Model): - """Definition of what monitoring data to collect and where that data should be sent. - - 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 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. - 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).v2019_11_01_preview.models.DataCollectionRuleDataSources - :param destinations: The specification of destinations. - :type 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 provisioning_state: The resource provisioning state. Possible values include: "Creating", - "Updating", "Deleting", "Succeeded", "Failed". - :vartype provisioning_state: str or - ~$(python-base-namespace).v2019_11_01_preview.models.KnownDataCollectionRuleProvisioningState - """ - - _validation = { - 'immutable_id': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'immutable_id': {'key': 'immutableId', 'type': 'str'}, - 'data_sources': {'key': 'dataSources', 'type': 'DataCollectionRuleDataSources'}, - 'destinations': {'key': 'destinations', 'type': 'DataCollectionRuleDestinations'}, - 'data_flows': {'key': 'dataFlows', 'type': '[DataFlow]'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DataCollectionRule, self).__init__(**kwargs) - self.description = kwargs.get('description', None) - self.immutable_id = None - self.data_sources = kwargs.get('data_sources', None) - self.destinations = kwargs.get('destinations', None) - self.data_flows = kwargs.get('data_flows', None) - self.provisioning_state = None - - -class DataCollectionRuleAssociation(msrest.serialization.Model): - """Definition of association of a data collection rule with a monitored Azure resource. - - 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 - associated. - :type 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 - ~$(python-base-namespace).v2019_11_01_preview.models.KnownDataCollectionRuleAssociationProvisioningState - """ - - _validation = { - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'data_collection_rule_id': {'key': 'dataCollectionRuleId', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DataCollectionRuleAssociation, self).__init__(**kwargs) - self.description = kwargs.get('description', None) - self.data_collection_rule_id = kwargs.get('data_collection_rule_id', None) - self.provisioning_state = None - - -class DataCollectionRuleAssociationProxyOnlyResource(msrest.serialization.Model): - """Definition of generic ARM proxy resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified ID of the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :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 - associated. - :type 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 - ~$(python-base-namespace).v2019_11_01_preview.models.KnownDataCollectionRuleAssociationProvisioningState - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'data_collection_rule_id': {'key': 'properties.dataCollectionRuleId', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DataCollectionRuleAssociationProxyOnlyResource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.etag = None - self.description = kwargs.get('description', None) - self.data_collection_rule_id = kwargs.get('data_collection_rule_id', None) - self.provisioning_state = None - - -class DataCollectionRuleAssociationProxyOnlyResourceListResult(msrest.serialization.Model): - """A pageable list of resources. - - 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).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[DataCollectionRuleAssociationProxyOnlyResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DataCollectionRuleAssociationProxyOnlyResourceListResult, self).__init__(**kwargs) - self.value = kwargs['value'] - self.next_link = kwargs.get('next_link', None) - - -class DataCollectionRuleAssociationProxyOnlyResourceProperties(DataCollectionRuleAssociation): - """Resource properties. - - 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 - associated. - :type 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 - ~$(python-base-namespace).v2019_11_01_preview.models.KnownDataCollectionRuleAssociationProvisioningState - """ - - _validation = { - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'data_collection_rule_id': {'key': 'dataCollectionRuleId', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - 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: - 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: - 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: - list[~$(python-base-namespace).v2019_11_01_preview.models.ExtensionDataSource] - """ - - _attribute_map = { - 'performance_counters': {'key': 'performanceCounters', 'type': '[PerfCounterDataSource]'}, - 'windows_event_logs': {'key': 'windowsEventLogs', 'type': '[WindowsEventLogDataSource]'}, - 'syslog': {'key': 'syslog', 'type': '[SyslogDataSource]'}, - 'extensions': {'key': 'extensions', 'type': '[ExtensionDataSource]'}, - } - - def __init__( - self, - **kwargs - ): - super(DataSourcesSpec, self).__init__(**kwargs) - self.performance_counters = kwargs.get('performance_counters', None) - self.windows_event_logs = kwargs.get('windows_event_logs', None) - self.syslog = kwargs.get('syslog', None) - self.extensions = kwargs.get('extensions', None) - - -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: - 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: - 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: - list[~$(python-base-namespace).v2019_11_01_preview.models.ExtensionDataSource] - """ - - _attribute_map = { - 'performance_counters': {'key': 'performanceCounters', 'type': '[PerfCounterDataSource]'}, - 'windows_event_logs': {'key': 'windowsEventLogs', 'type': '[WindowsEventLogDataSource]'}, - 'syslog': {'key': 'syslog', 'type': '[SyslogDataSource]'}, - 'extensions': {'key': 'extensions', 'type': '[ExtensionDataSource]'}, - } - - def __init__( - self, - **kwargs - ): - 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).v2019_11_01_preview.models.LogAnalyticsDestination] - :param azure_monitor_metrics: Azure Monitor Metrics destination. - :type azure_monitor_metrics: - ~$(python-base-namespace).v2019_11_01_preview.models.DestinationsSpecAzureMonitorMetrics - """ - - _attribute_map = { - 'log_analytics': {'key': 'logAnalytics', 'type': '[LogAnalyticsDestination]'}, - 'azure_monitor_metrics': {'key': 'azureMonitorMetrics', 'type': 'DestinationsSpecAzureMonitorMetrics'}, - } - - def __init__( - self, - **kwargs - ): - super(DestinationsSpec, self).__init__(**kwargs) - self.log_analytics = kwargs.get('log_analytics', None) - self.azure_monitor_metrics = kwargs.get('azure_monitor_metrics', None) - - -class DataCollectionRuleDestinations(DestinationsSpec): - """The specification of destinations. - - :param log_analytics: List of Log Analytics destinations. - :type log_analytics: - list[~$(python-base-namespace).v2019_11_01_preview.models.LogAnalyticsDestination] - :param azure_monitor_metrics: Azure Monitor Metrics destination. - :type azure_monitor_metrics: - ~$(python-base-namespace).v2019_11_01_preview.models.DestinationsSpecAzureMonitorMetrics - """ - - _attribute_map = { - 'log_analytics': {'key': 'logAnalytics', 'type': '[LogAnalyticsDestination]'}, - 'azure_monitor_metrics': {'key': 'azureMonitorMetrics', 'type': 'DestinationsSpecAzureMonitorMetrics'}, - } - - def __init__( - self, - **kwargs - ): - super(DataCollectionRuleDestinations, self).__init__(**kwargs) - - -class DataCollectionRuleResource(msrest.serialization.Model): - """Definition of ARM tracked top level resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param 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 - ~$(python-base-namespace).v2019_11_01_preview.models.KnownDataCollectionRuleResourceKind - :ivar id: Fully qualified ID of the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :ivar etag: Resource entity tag (ETag). - :vartype etag: str - :param description: Description of the data collection rule. - :type 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. - 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).v2019_11_01_preview.models.DataCollectionRuleDataSources - :param destinations: The specification of destinations. - :type 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 provisioning_state: The resource provisioning state. Possible values include: "Creating", - "Updating", "Deleting", "Succeeded", "Failed". - :vartype provisioning_state: str or - ~$(python-base-namespace).v2019_11_01_preview.models.KnownDataCollectionRuleProvisioningState - """ - - _validation = { - 'location': {'required': True}, - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'immutable_id': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'immutable_id': {'key': 'properties.immutableId', 'type': 'str'}, - 'data_sources': {'key': 'properties.dataSources', 'type': 'DataCollectionRuleDataSources'}, - 'destinations': {'key': 'properties.destinations', 'type': 'DataCollectionRuleDestinations'}, - 'data_flows': {'key': 'properties.dataFlows', 'type': '[DataFlow]'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DataCollectionRuleResource, self).__init__(**kwargs) - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - self.kind = kwargs.get('kind', None) - self.id = None - self.name = None - self.type = None - self.etag = None - self.description = kwargs.get('description', None) - self.immutable_id = None - self.data_sources = kwargs.get('data_sources', None) - self.destinations = kwargs.get('destinations', None) - self.data_flows = kwargs.get('data_flows', None) - self.provisioning_state = None - - -class DataCollectionRuleResourceListResult(msrest.serialization.Model): - """A pageable list of resources. - - 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).v2019_11_01_preview.models.DataCollectionRuleResource] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[DataCollectionRuleResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DataCollectionRuleResourceListResult, self).__init__(**kwargs) - self.value = kwargs['value'] - self.next_link = kwargs.get('next_link', None) - - -class DataCollectionRuleResourceProperties(DataCollectionRule): - """Resource properties. - - 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 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. - 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).v2019_11_01_preview.models.DataCollectionRuleDataSources - :param destinations: The specification of destinations. - :type 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 provisioning_state: The resource provisioning state. Possible values include: "Creating", - "Updating", "Deleting", "Succeeded", "Failed". - :vartype provisioning_state: str or - ~$(python-base-namespace).v2019_11_01_preview.models.KnownDataCollectionRuleProvisioningState - """ - - _validation = { - 'immutable_id': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'immutable_id': {'key': 'immutableId', 'type': 'str'}, - 'data_sources': {'key': 'dataSources', 'type': 'DataCollectionRuleDataSources'}, - 'destinations': {'key': 'destinations', 'type': 'DataCollectionRuleDestinations'}, - 'data_flows': {'key': 'dataFlows', 'type': '[DataFlow]'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - 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 - ~$(python-base-namespace).v2019_11_01_preview.models.KnownDataFlowStreams] - :param destinations: List of destinations for this data flow. - :type destinations: list[str] - """ - - _attribute_map = { - 'streams': {'key': 'streams', 'type': '[str]'}, - 'destinations': {'key': 'destinations', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(DataFlow, self).__init__(**kwargs) - self.streams = kwargs.get('streams', None) - self.destinations = kwargs.get('destinations', None) - - -class DestinationsSpecAzureMonitorMetrics(AzureMonitorMetricsDestination): - """Azure Monitor Metrics destination. - - :param 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 - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DestinationsSpecAzureMonitorMetrics, self).__init__(**kwargs) - - -class ErrorAdditionalInfo(msrest.serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: any - """ - - _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorAdditionalInfo, self).__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(msrest.serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~$(python-base-namespace).v2019_11_01_preview.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~$(python-base-namespace).v2019_11_01_preview.models.ErrorAdditionalInfo] - """ - - _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorDetail]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorDetail, self).__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -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 - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDetail'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class ExtensionDataSource(msrest.serialization.Model): - """Definition of which data will be collected from a separate VM extension that integrates with the Azure Monitor Agent. -Collected from either Windows and Linux machines, depending on which extension is defined. - - 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. - 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 - ~$(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 - 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. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :type name: str - """ - - _validation = { - 'extension_name': {'required': True}, - } - - _attribute_map = { - 'streams': {'key': 'streams', 'type': '[str]'}, - 'extension_name': {'key': 'extensionName', 'type': 'str'}, - 'extension_settings': {'key': 'extensionSettings', 'type': 'object'}, - 'input_data_sources': {'key': 'inputDataSources', 'type': '[str]'}, - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ExtensionDataSource, self).__init__(**kwargs) - self.streams = kwargs.get('streams', None) - self.extension_name = kwargs['extension_name'] - self.extension_settings = kwargs.get('extension_settings', None) - self.input_data_sources = kwargs.get('input_data_sources', None) - self.name = kwargs.get('name', None) - - -class LogAnalyticsDestination(msrest.serialization.Model): - """Log Analytics destination. - - 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_id: The Customer ID of the Log Analytics workspace. - :vartype workspace_id: str - :param 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 - """ - - _validation = { - 'workspace_id': {'readonly': True}, - } - - _attribute_map = { - 'workspace_resource_id': {'key': 'workspaceResourceId', 'type': 'str'}, - 'workspace_id': {'key': 'workspaceId', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LogAnalyticsDestination, self).__init__(**kwargs) - self.workspace_resource_id = kwargs.get('workspace_resource_id', None) - self.workspace_id = None - self.name = kwargs.get('name', None) - - -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. - 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 - ~$(python-base-namespace).v2019_11_01_preview.models.KnownPerfCounterDataSourceStreams] - :param 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 - 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. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :type name: str - """ - - _attribute_map = { - 'streams': {'key': 'streams', 'type': '[str]'}, - 'sampling_frequency_in_seconds': {'key': 'samplingFrequencyInSeconds', 'type': 'int'}, - 'counter_specifiers': {'key': 'counterSpecifiers', 'type': '[str]'}, - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PerfCounterDataSource, self).__init__(**kwargs) - self.streams = kwargs.get('streams', None) - self.sampling_frequency_in_seconds = kwargs.get('sampling_frequency_in_seconds', None) - self.counter_specifiers = kwargs.get('counter_specifiers', None) - self.name = kwargs.get('name', None) - - -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] - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceForUpdate, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - - -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. - 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 - ~$(python-base-namespace).v2019_11_01_preview.models.KnownSyslogDataSourceStreams] - :param facility_names: The list of facility names. - :type 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 - ~$(python-base-namespace).v2019_11_01_preview.models.KnownSyslogDataSourceLogLevels] - :param 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 - """ - - _attribute_map = { - 'streams': {'key': 'streams', 'type': '[str]'}, - 'facility_names': {'key': 'facilityNames', 'type': '[str]'}, - 'log_levels': {'key': 'logLevels', 'type': '[str]'}, - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SyslogDataSource, self).__init__(**kwargs) - self.streams = kwargs.get('streams', None) - self.facility_names = kwargs.get('facility_names', None) - self.log_levels = kwargs.get('log_levels', None) - self.name = kwargs.get('name', None) - - -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. - 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 - ~$(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. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :type name: str - """ - - _attribute_map = { - 'streams': {'key': 'streams', 'type': '[str]'}, - 'x_path_queries': {'key': 'xPathQueries', 'type': '[str]'}, - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WindowsEventLogDataSource, self).__init__(**kwargs) - self.streams = kwargs.get('streams', None) - self.x_path_queries = kwargs.get('x_path_queries', None) - self.name = kwargs.get('name', 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 44aff14895f6..7a0a0f36f511 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 251ddeea0a23..fe34d7947fb3 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 f7feadebaa83..2a0854de768a 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,23 +5,200 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_resource_request( + resource_uri: str, + **kwargs: Any +) -> 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: str, + resource_group_name: str, + data_collection_rule_name: str, + **kwargs: Any +) -> 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: str, + association_name: str, + **kwargs: Any +) -> 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: str, + association_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_uri: str, + association_name: str, + **kwargs: Any +) -> 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 + ) class DataCollectionRuleAssociationsOperations(object): """DataCollectionRuleAssociationsOperations operations. @@ -45,12 +222,12 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource( self, - resource_uri, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DataCollectionRuleAssociationProxyOnlyResourceListResult"] + resource_uri: str, + **kwargs: Any + ) -> Iterable["_models.DataCollectionRuleAssociationProxyOnlyResourceListResult"]: """Lists associations for the specified resource. Lists associations for the specified resource. @@ -58,8 +235,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 +246,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,24 +281,25 @@ 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 - data_collection_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DataCollectionRuleAssociationProxyOnlyResourceListResult"] + resource_group_name: str, + data_collection_rule_name: str, + **kwargs: Any + ) -> Iterable["_models.DataCollectionRuleAssociationProxyOnlyResourceListResult"]: """Lists associations for the specified data collection rule. Lists associations for the specified data collection rule. @@ -135,8 +310,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 +321,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,24 +360,25 @@ 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 - association_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DataCollectionRuleAssociationProxyOnlyResource" + resource_uri: str, + association_name: str, + **kwargs: Any + ) -> "_models.DataCollectionRuleAssociationProxyOnlyResource": """Returns the specified association. Returns the specified association. @@ -214,7 +389,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 +398,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,16 +422,18 @@ 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 - association_name, # type: str - body=None, # type: Optional["_models.DataCollectionRuleAssociationProxyOnlyResource"] - **kwargs # type: Any - ): - # type: (...) -> "_models.DataCollectionRuleAssociationProxyOnlyResource" + resource_uri: str, + association_name: str, + body: Optional["_models.DataCollectionRuleAssociationProxyOnlyResource"] = None, + **kwargs: Any + ) -> "_models.DataCollectionRuleAssociationProxyOnlyResource": """Creates or updates an association. Creates or updates an association. @@ -275,10 +443,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 +456,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,15 +492,17 @@ 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 - association_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_uri: str, + association_name: str, + **kwargs: Any + ) -> None: """Deletes an association. Deletes an association. @@ -359,35 +521,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 c7a2fca7f84d..e7390a164176 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,23 +5,248 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> 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: str, + **kwargs: Any +) -> 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: str, + resource_group_name: str, + data_collection_rule_name: str, + **kwargs: Any +) -> 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: str, + resource_group_name: str, + data_collection_rule_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + subscription_id: str, + resource_group_name: str, + data_collection_rule_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + data_collection_rule_name: str, + **kwargs: Any +) -> 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 + ) class DataCollectionRulesOperations(object): """DataCollectionRulesOperations operations. @@ -45,12 +270,12 @@ 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 - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DataCollectionRuleResourceListResult"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.DataCollectionRuleResourceListResult"]: """Lists all data collection rules in the specified resource group. Lists all data collection rules in the specified resource group. @@ -58,8 +283,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 +294,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,29 +331,32 @@ 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 - ): - # type: (...) -> Iterable["_models.DataCollectionRuleResourceListResult"] + **kwargs: Any + ) -> Iterable["_models.DataCollectionRuleResourceListResult"]: """Lists all data collection rules in the specified 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 +364,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,24 +399,25 @@ 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 - data_collection_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DataCollectionRuleResource" + resource_group_name: str, + data_collection_rule_name: str, + **kwargs: Any + ) -> "_models.DataCollectionRuleResource": """Returns the specified data collection rule. Returns the specified data collection rule. @@ -215,33 +437,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,16 +462,18 @@ 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 - data_collection_rule_name, # type: str - body=None, # type: Optional["_models.DataCollectionRuleResource"] - **kwargs # type: Any - ): - # type: (...) -> "_models.DataCollectionRuleResource" + resource_group_name: str, + data_collection_rule_name: str, + body: Optional["_models.DataCollectionRuleResource"] = None, + **kwargs: Any + ) -> "_models.DataCollectionRuleResource": """Creates or updates a data collection rule. Creates or updates a data collection rule. @@ -281,41 +495,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,16 +532,18 @@ 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 - data_collection_rule_name, # type: str - body=None, # type: Optional["_models.ResourceForUpdate"] - **kwargs # type: Any - ): - # type: (...) -> "_models.DataCollectionRuleResource" + resource_group_name: str, + data_collection_rule_name: str, + body: Optional["_models.ResourceForUpdate"] = None, + **kwargs: Any + ) -> "_models.DataCollectionRuleResource": """Updates part of a data collection rule. Updates part of a data collection rule. @@ -359,41 +565,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,15 +598,17 @@ 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 - data_collection_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + data_collection_rule_name: str, + **kwargs: Any + ) -> None: """Deletes a data collection rule. Deletes a data collection rule. @@ -430,36 +628,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 d82479510092..ec9090a57df0 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 0c4c839c6751..a3b6df71aadb 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 @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -33,13 +31,12 @@ class MonitorManagementClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + **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" @@ -62,4 +59,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 724484160644..378468ef8a93 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 35801d7fac26..c96780028635 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,75 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -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 . 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 import TokenCredential -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.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] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MonitorManagementClientConfiguration(credential, **kwargs) + credential: "TokenCredential", + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + 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: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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 000000000000..74e48ecd07cf --- /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 000000000000..138f663c53a4 --- /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 cac9f5d10f8b..e5754a47ce68 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 96ce9b45c05b..4eba911f1c6e 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 91dce6198f59..cdef221ece0b 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 1b9308541bdf..8c3c52b5455b 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 000000000000..74e48ecd07cf --- /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 2ff71bcf89fb..921396e02fe2 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/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/models/__init__.py index b5d8c1b8e24d..51d05c1a18a8 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/models/__init__.py @@ -6,18 +6,12 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import ErrorResponse - from ._models_py3 import ManagementGroupDiagnosticSettingsResource - from ._models_py3 import ManagementGroupDiagnosticSettingsResourceCollection - from ._models_py3 import ManagementGroupLogSettings - from ._models_py3 import ManagementGroupProxyOnlyResource -except (SyntaxError, ImportError): - from ._models import ErrorResponse # type: ignore - from ._models import ManagementGroupDiagnosticSettingsResource # type: ignore - from ._models import ManagementGroupDiagnosticSettingsResourceCollection # type: ignore - from ._models import ManagementGroupLogSettings # type: ignore - from ._models import ManagementGroupProxyOnlyResource # type: ignore +from ._models_py3 import ErrorResponse +from ._models_py3 import ManagementGroupDiagnosticSettingsResource +from ._models_py3 import ManagementGroupDiagnosticSettingsResourceCollection +from ._models_py3 import ManagementGroupLogSettings +from ._models_py3 import ManagementGroupProxyOnlyResource + __all__ = [ 'ErrorResponse', 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 deleted file mode 100644 index 5715644ceb01..000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/models/_models.py +++ /dev/null @@ -1,188 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class 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 - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - - -class ManagementGroupProxyOnlyResource(msrest.serialization.Model): - """A proxy only azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :param location: Location of the resource. - :type location: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagementGroupProxyOnlyResource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = kwargs.get('location', None) - - -class ManagementGroupDiagnosticSettingsResource(ManagementGroupProxyOnlyResource): - """The management group diagnostic setting resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :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 - 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 - 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 - will be selected. - :type event_hub_name: str - :param logs: The list of logs settings. - :type 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 - like to send Diagnostic Logs. Example: - /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2. - :type workspace_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'storage_account_id': {'key': 'properties.storageAccountId', 'type': 'str'}, - 'service_bus_rule_id': {'key': 'properties.serviceBusRuleId', 'type': 'str'}, - 'event_hub_authorization_rule_id': {'key': 'properties.eventHubAuthorizationRuleId', 'type': 'str'}, - 'event_hub_name': {'key': 'properties.eventHubName', 'type': 'str'}, - 'logs': {'key': 'properties.logs', 'type': '[ManagementGroupLogSettings]'}, - 'workspace_id': {'key': 'properties.workspaceId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - 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) - self.event_hub_authorization_rule_id = kwargs.get('event_hub_authorization_rule_id', None) - self.event_hub_name = kwargs.get('event_hub_name', None) - self.logs = kwargs.get('logs', None) - self.workspace_id = kwargs.get('workspace_id', None) - - -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: - list[~$(python-base-namespace).v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ManagementGroupDiagnosticSettingsResource]'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagementGroupDiagnosticSettingsResourceCollection, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class ManagementGroupLogSettings(msrest.serialization.Model): - """Part of Management Group diagnostic setting. Specifies the settings for a particular log. - - 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 - type this setting is applied to. - :type category: str - :param enabled: Required. a value indicating whether this log is enabled. - :type enabled: bool - """ - - _validation = { - 'category': {'required': True}, - 'enabled': {'required': True}, - } - - _attribute_map = { - 'category': {'key': 'category', 'type': 'str'}, - 'enabled': {'key': 'enabled', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - 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 64fb6dadc29a..e53b3a61d86c 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 d15bed802560..9c127025109b 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,23 +5,165 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + management_group_id: str, + name: str, + **kwargs: Any +) -> 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: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + management_group_id: str, + name: str, + **kwargs: Any +) -> 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: str, + **kwargs: Any +) -> 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 + ) class ManagementGroupDiagnosticSettingsOperations(object): """ManagementGroupDiagnosticSettingsOperations operations. @@ -45,13 +187,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - management_group_id, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ManagementGroupDiagnosticSettingsResource" + management_group_id: str, + name: str, + **kwargs: Any + ) -> "_models.ManagementGroupDiagnosticSettingsResource": """Gets the active management group diagnostic settings for the specified resource. :param management_group_id: The management group id. @@ -60,7 +202,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 +211,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,16 +235,18 @@ 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 - name, # type: str - parameters, # type: "_models.ManagementGroupDiagnosticSettingsResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.ManagementGroupDiagnosticSettingsResource" + management_group_id: str, + name: str, + parameters: "_models.ManagementGroupDiagnosticSettingsResource", + **kwargs: Any + ) -> "_models.ManagementGroupDiagnosticSettingsResource": """Creates or updates management group diagnostic settings for the specified resource. :param management_group_id: The management group id. @@ -119,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).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 +267,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,15 +296,17 @@ 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 - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + management_group_id: str, + name: str, + **kwargs: Any + ) -> None: """Deletes existing management group diagnostic settings for the specified resource. :param management_group_id: The management group id. @@ -194,32 +323,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,19 +346,22 @@ 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 - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ManagementGroupDiagnosticSettingsResourceCollection"] + management_group_id: str, + **kwargs: Any + ) -> Iterable["_models.ManagementGroupDiagnosticSettingsResourceCollection"]: """Gets the active management group diagnostic settings list for the specified management group. :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 +369,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 +404,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 d82479510092..ec9090a57df0 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 1f601e6a8306..5e7e4b72cc0a 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 @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class MonitorManagementClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(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 +65,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 a556e8b454f6..0518924e3fa3 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 f16bbdb9ca83..fa5afc6020a9 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,77 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -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 . 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 import TokenCredential -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.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] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + 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: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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 000000000000..74e48ecd07cf --- /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 000000000000..138f663c53a4 --- /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 cac9f5d10f8b..e5754a47ce68 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 96ce9b45c05b..4eba911f1c6e 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 b4b6605c0d04..9542d1ff846f 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 bac946198254..62e082f8affd 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 000000000000..74e48ecd07cf --- /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 77eccbaf2c5d..8e128c253a04 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/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/__init__.py index 4856ee24980c..5c06ceb743ef 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/__init__.py @@ -6,34 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import Action - from ._models_py3 import Condition - from ._models_py3 import ConditionFailingPeriods - from ._models_py3 import Dimension - from ._models_py3 import ErrorAdditionalInfo - from ._models_py3 import ErrorContract - from ._models_py3 import ErrorResponse - from ._models_py3 import Resource - from ._models_py3 import ScheduledQueryRuleCriteria - from ._models_py3 import ScheduledQueryRuleResource - from ._models_py3 import ScheduledQueryRuleResourceCollection - from ._models_py3 import ScheduledQueryRuleResourcePatch - from ._models_py3 import TrackedResource -except (SyntaxError, ImportError): - from ._models import Action # type: ignore - from ._models import Condition # type: ignore - from ._models import ConditionFailingPeriods # type: ignore - from ._models import Dimension # type: ignore - from ._models import ErrorAdditionalInfo # type: ignore - from ._models import ErrorContract # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import Resource # type: ignore - from ._models import ScheduledQueryRuleCriteria # type: ignore - from ._models import ScheduledQueryRuleResource # type: ignore - from ._models import ScheduledQueryRuleResourceCollection # type: ignore - from ._models import ScheduledQueryRuleResourcePatch # type: ignore - from ._models import TrackedResource # type: ignore +from ._models_py3 import Action +from ._models_py3 import Condition +from ._models_py3 import ConditionFailingPeriods +from ._models_py3 import Dimension +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorContract +from ._models_py3 import ErrorResponse +from ._models_py3 import Resource +from ._models_py3 import ScheduledQueryRuleCriteria +from ._models_py3 import ScheduledQueryRuleResource +from ._models_py3 import ScheduledQueryRuleResourceCollection +from ._models_py3 import ScheduledQueryRuleResourcePatch +from ._models_py3 import TrackedResource + from ._monitor_management_client_enums import ( AlertSeverity, 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 deleted file mode 100644 index bc0dc2510e61..000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/_models.py +++ /dev/null @@ -1,589 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class 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] - """ - - _attribute_map = { - 'action_group_id': {'key': 'actionGroupId', 'type': 'str'}, - 'web_hook_properties': {'key': 'webHookProperties', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - 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) - - -class Condition(msrest.serialization.Model): - """A condition of the scheduled query rule. - - 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", - "Average", "Minimum", "Maximum", "Total". - :type 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", - "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 - time window required to raise an alert. - :type failing_periods: - ~$(python-base-namespace).v2020_05_01_preview.models.ConditionFailingPeriods - """ - - _validation = { - 'time_aggregation': {'required': True}, - 'operator': {'required': True}, - 'threshold': {'required': True}, - } - - _attribute_map = { - 'query': {'key': 'query', 'type': 'str'}, - 'time_aggregation': {'key': 'timeAggregation', 'type': 'str'}, - 'metric_measure_column': {'key': 'metricMeasureColumn', 'type': 'str'}, - 'resource_id_column': {'key': 'resourceIdColumn', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[Dimension]'}, - 'operator': {'key': 'operator', 'type': 'str'}, - 'threshold': {'key': 'threshold', 'type': 'float'}, - 'failing_periods': {'key': 'failingPeriods', 'type': 'ConditionFailingPeriods'}, - } - - def __init__( - self, - **kwargs - ): - super(Condition, self).__init__(**kwargs) - self.query = kwargs.get('query', None) - self.time_aggregation = kwargs['time_aggregation'] - self.metric_measure_column = kwargs.get('metric_measure_column', None) - self.resource_id_column = kwargs.get('resource_id_column', None) - self.dimensions = kwargs.get('dimensions', None) - self.operator = kwargs['operator'] - self.threshold = kwargs['threshold'] - self.failing_periods = kwargs.get('failing_periods', None) - - -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 - smaller or equal to numberOfEvaluationPeriods. Default value is 1. - :type min_failing_periods_to_alert: long - """ - - _attribute_map = { - 'number_of_evaluation_periods': {'key': 'numberOfEvaluationPeriods', 'type': 'long'}, - 'min_failing_periods_to_alert': {'key': 'minFailingPeriodsToAlert', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - 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) - - -class Dimension(msrest.serialization.Model): - """Dimension splitting and filtering definition. - - 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", - "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] - """ - - _validation = { - 'name': {'required': True}, - 'operator': {'required': True}, - 'values': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'operator': {'key': 'operator', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(Dimension, self).__init__(**kwargs) - self.name = kwargs['name'] - self.operator = kwargs['operator'] - self.values = kwargs['values'] - - -class ErrorAdditionalInfo(msrest.serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: any - """ - - _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorAdditionalInfo, self).__init__(**kwargs) - self.type = None - self.info = None - - -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 - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponse'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorContract, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -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.). - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~$(python-base-namespace).v2020_05_01_preview.models.ErrorResponse] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~$(python-base-namespace).v2020_05_01_preview.models.ErrorAdditionalInfo] - """ - - _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponse]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class Resource(msrest.serialization.Model): - """Common fields that are returned in the response for all Azure Resource Manager resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -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] - """ - - _attribute_map = { - 'all_of': {'key': 'allOf', 'type': '[Condition]'}, - } - - def __init__( - self, - **kwargs - ): - super(ScheduledQueryRuleCriteria, self).__init__(**kwargs) - self.all_of = kwargs.get('all_of', None) - - -class TrackedResource(Resource): - """The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :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 - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TrackedResource, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.location = kwargs['location'] - - -class ScheduledQueryRuleResource(TrackedResource): - """The scheduled query rule resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :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 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. - :vartype kind: str - :ivar etag: The etag field is *not* required. If it is provided in the response body, it must - also be provided as a header per the normal etag convention. Entity tags are used for - comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in - the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range - (section 14.27) header fields. - :vartype etag: 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 - 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 - 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 - 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 - 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 - 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 - 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 - 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] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'kind': {'readonly': True}, - 'etag': {'readonly': True}, - 'created_with_api_version': {'readonly': True}, - 'is_legacy_log_analytics_rule': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'created_with_api_version': {'key': 'properties.createdWithApiVersion', 'type': 'str'}, - 'is_legacy_log_analytics_rule': {'key': 'properties.isLegacyLogAnalyticsRule', 'type': 'bool'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'severity': {'key': 'properties.severity', 'type': 'float'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - 'scopes': {'key': 'properties.scopes', 'type': '[str]'}, - 'evaluation_frequency': {'key': 'properties.evaluationFrequency', 'type': 'duration'}, - 'window_size': {'key': 'properties.windowSize', 'type': 'duration'}, - 'override_query_time_range': {'key': 'properties.overrideQueryTimeRange', 'type': 'duration'}, - 'target_resource_types': {'key': 'properties.targetResourceTypes', 'type': '[str]'}, - 'criteria': {'key': 'properties.criteria', 'type': 'ScheduledQueryRuleCriteria'}, - 'mute_actions_duration': {'key': 'properties.muteActionsDuration', 'type': 'duration'}, - 'actions': {'key': 'properties.actions', 'type': '[Action]'}, - } - - def __init__( - self, - **kwargs - ): - super(ScheduledQueryRuleResource, self).__init__(**kwargs) - self.kind = None - self.etag = None - self.created_with_api_version = None - self.is_legacy_log_analytics_rule = None - self.description = kwargs.get('description', None) - self.display_name = kwargs.get('display_name', None) - self.severity = kwargs.get('severity', None) - self.enabled = kwargs.get('enabled', None) - self.scopes = kwargs.get('scopes', None) - self.evaluation_frequency = kwargs.get('evaluation_frequency', None) - self.window_size = kwargs.get('window_size', None) - self.override_query_time_range = kwargs.get('override_query_time_range', None) - self.target_resource_types = kwargs.get('target_resource_types', None) - self.criteria = kwargs.get('criteria', None) - self.mute_actions_duration = kwargs.get('mute_actions_duration', None) - self.actions = kwargs.get('actions', None) - - -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: - list[~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResource] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ScheduledQueryRuleResource]'}, - } - - def __init__( - self, - **kwargs - ): - super(ScheduledQueryRuleResourceCollection, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class ScheduledQueryRuleResourcePatch(msrest.serialization.Model): - """The scheduled query rule resource for patch operations. - - 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 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 - 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 - 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 - 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 - 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 - 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 - 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 - 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] - """ - - _validation = { - 'created_with_api_version': {'readonly': True}, - 'is_legacy_log_analytics_rule': {'readonly': True}, - } - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'created_with_api_version': {'key': 'properties.createdWithApiVersion', 'type': 'str'}, - 'is_legacy_log_analytics_rule': {'key': 'properties.isLegacyLogAnalyticsRule', 'type': 'bool'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'severity': {'key': 'properties.severity', 'type': 'float'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - 'scopes': {'key': 'properties.scopes', 'type': '[str]'}, - 'evaluation_frequency': {'key': 'properties.evaluationFrequency', 'type': 'duration'}, - 'window_size': {'key': 'properties.windowSize', 'type': 'duration'}, - 'override_query_time_range': {'key': 'properties.overrideQueryTimeRange', 'type': 'duration'}, - 'target_resource_types': {'key': 'properties.targetResourceTypes', 'type': '[str]'}, - 'criteria': {'key': 'properties.criteria', 'type': 'ScheduledQueryRuleCriteria'}, - 'mute_actions_duration': {'key': 'properties.muteActionsDuration', 'type': 'duration'}, - 'actions': {'key': 'properties.actions', 'type': '[Action]'}, - } - - def __init__( - self, - **kwargs - ): - super(ScheduledQueryRuleResourcePatch, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.created_with_api_version = None - self.is_legacy_log_analytics_rule = None - self.description = kwargs.get('description', None) - self.display_name = kwargs.get('display_name', None) - self.severity = kwargs.get('severity', None) - self.enabled = kwargs.get('enabled', None) - self.scopes = kwargs.get('scopes', None) - self.evaluation_frequency = kwargs.get('evaluation_frequency', None) - self.window_size = kwargs.get('window_size', None) - self.override_query_time_range = kwargs.get('override_query_time_range', None) - self.target_resource_types = kwargs.get('target_resource_types', None) - self.criteria = kwargs.get('criteria', None) - self.mute_actions_duration = kwargs.get('mute_actions_duration', None) - self.actions = kwargs.get('actions', 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 1525426b24ea..76b08a05a895 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 824ade35f9c6..da2f1e015f96 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 155ebb742176..3da1f29e37d6 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,23 +5,248 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "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: str, + resource_group_name: str, + **kwargs: Any +) -> 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: str, + resource_group_name: str, + rule_name: str, + **kwargs: Any +) -> 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: str, + resource_group_name: str, + rule_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + subscription_id: str, + resource_group_name: str, + rule_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + rule_name: str, + **kwargs: Any +) -> 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 + ) class ScheduledQueryRulesOperations(object): """ScheduledQueryRulesOperations operations. @@ -45,16 +270,18 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_subscription( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ScheduledQueryRuleResourceCollection"] + **kwargs: Any + ) -> Iterable["_models.ScheduledQueryRuleResourceCollection"]: """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 +289,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,30 +324,33 @@ 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 - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ScheduledQueryRuleResourceCollection"] + resource_group_name: str, + **kwargs: Any + ) -> 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 +358,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,27 +395,28 @@ 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 - rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ScheduledQueryRuleResource" + resource_group_name: str, + rule_name: str, + **kwargs: Any + ) -> "_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 +430,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,24 +455,27 @@ 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 - rule_name, # type: str - parameters, # type: "_models.ScheduledQueryRuleResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.ScheduledQueryRuleResource" + resource_group_name: str, + rule_name: str, + parameters: "_models.ScheduledQueryRuleResource", + **kwargs: Any + ) -> "_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 +486,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,24 +520,27 @@ 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 - rule_name, # type: str - parameters, # type: "_models.ScheduledQueryRuleResourcePatch" - **kwargs # type: Any - ): - # type: (...) -> "_models.ScheduledQueryRuleResource" + resource_group_name: str, + rule_name: str, + parameters: "_models.ScheduledQueryRuleResourcePatch", + **kwargs: Any + ) -> "_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 +551,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,18 +581,20 @@ 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 - rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + rule_name: str, + **kwargs: Any + ) -> 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 +608,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 d82479510092..ec9090a57df0 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 28d48e6791d0..14af96233033 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 @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class MonitorManagementClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(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 +65,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 29a3b208a966..f1fae9dab958 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 b1daa9d88de5..694355cab028 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,77 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -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 . 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 import TokenCredential -class MonitorManagementClient(object): +class MonitorManagementClient: """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] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + 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: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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 000000000000..74e48ecd07cf --- /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 000000000000..138f663c53a4 --- /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 cac9f5d10f8b..e5754a47ce68 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 96ce9b45c05b..4eba911f1c6e 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 968ee446dd68..d463a021089f 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 ec3d4d50df64..6f8d6651909b 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 000000000000..74e48ecd07cf --- /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 ecb6e1f12579..08ed28f3b920 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/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/__init__.py index e937f3d3fe5a..d89d7755c60e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/__init__.py @@ -6,28 +6,17 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import ActionGroup - from ._models_py3 import ActionList - from ._models_py3 import ActivityLogAlertResource - from ._models_py3 import AlertRuleAllOfCondition - from ._models_py3 import AlertRuleAnyOfOrLeafCondition - from ._models_py3 import AlertRuleLeafCondition - from ._models_py3 import AlertRuleList - from ._models_py3 import AlertRulePatchObject - from ._models_py3 import AzureResource - from ._models_py3 import ErrorResponse -except (SyntaxError, ImportError): - from ._models import ActionGroup # type: ignore - from ._models import ActionList # type: ignore - from ._models import ActivityLogAlertResource # type: ignore - from ._models import AlertRuleAllOfCondition # type: ignore - from ._models import AlertRuleAnyOfOrLeafCondition # type: ignore - from ._models import AlertRuleLeafCondition # type: ignore - from ._models import AlertRuleList # type: ignore - from ._models import AlertRulePatchObject # type: ignore - from ._models import AzureResource # type: ignore - from ._models import ErrorResponse # type: ignore +from ._models_py3 import ActionGroup +from ._models_py3 import ActionList +from ._models_py3 import ActivityLogAlertResource +from ._models_py3 import AlertRuleAllOfCondition +from ._models_py3 import AlertRuleAnyOfOrLeafCondition +from ._models_py3 import AlertRuleLeafCondition +from ._models_py3 import AlertRuleList +from ._models_py3 import AlertRulePatchObject +from ._models_py3 import AzureResource +from ._models_py3 import ErrorResponse + __all__ = [ 'ActionGroup', 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 deleted file mode 100644 index 419f5583f36f..000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/_models.py +++ /dev/null @@ -1,344 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class ActionGroup(msrest.serialization.Model): - """A pointer to an Azure Action Group. - - All required parameters must be populated in order to send to Azure. - - :param action_group_id: Required. The resource ID of the Action Group. This cannot be null or - empty. - :type action_group_id: str - :param webhook_properties: the dictionary of custom properties to include with the post - operation. These data are appended to the webhook payload. - :type webhook_properties: dict[str, str] - """ - - _validation = { - 'action_group_id': {'required': True}, - } - - _attribute_map = { - 'action_group_id': {'key': 'actionGroupId', 'type': 'str'}, - 'webhook_properties': {'key': 'webhookProperties', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(ActionGroup, self).__init__(**kwargs) - self.action_group_id = kwargs['action_group_id'] - self.webhook_properties = kwargs.get('webhook_properties', None) - - -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] - """ - - _attribute_map = { - 'action_groups': {'key': 'actionGroups', 'type': '[ActionGroup]'}, - } - - def __init__( - self, - **kwargs - ): - super(ActionList, self).__init__(**kwargs) - self.action_groups = kwargs.get('action_groups', None) - - -class AzureResource(msrest.serialization.Model): - """An Azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The resource Id. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param location: The location of the resource. Since Azure Activity Log Alerts is a global - service, the location of the rules should always be 'global'. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureResource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = kwargs.get('location', "global") - self.tags = kwargs.get('tags', None) - - -class ActivityLogAlertResource(AzureResource): - """An Activity Log Alert rule resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The resource Id. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :param location: The location of the resource. Since Azure Activity Log Alerts is a global - service, the location of the rules should always be 'global'. - :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 - 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 - 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 - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'scopes': {'key': 'properties.scopes', 'type': '[str]'}, - 'condition': {'key': 'properties.condition', 'type': 'AlertRuleAllOfCondition'}, - 'actions': {'key': 'properties.actions', 'type': 'ActionList'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ActivityLogAlertResource, self).__init__(**kwargs) - self.scopes = kwargs.get('scopes', None) - self.condition = kwargs.get('condition', None) - self.actions = kwargs.get('actions', None) - self.enabled = kwargs.get('enabled', True) - self.description = kwargs.get('description', None) - - -class AlertRuleAllOfCondition(msrest.serialization.Model): - """An Activity Log Alert rule condition that is met when all its member conditions are met. - - All required parameters must be populated in order to send to Azure. - - :param all_of: Required. The list of Activity Log Alert rule conditions. - :type all_of: list[~$(python-base-namespace).v2020_10_01.models.AlertRuleAnyOfOrLeafCondition] - """ - - _validation = { - 'all_of': {'required': True}, - } - - _attribute_map = { - 'all_of': {'key': 'allOf', 'type': '[AlertRuleAnyOfOrLeafCondition]'}, - } - - def __init__( - self, - **kwargs - ): - super(AlertRuleAllOfCondition, self).__init__(**kwargs) - self.all_of = kwargs['all_of'] - - -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. - The possible values for this field are (case-insensitive): 'resourceId', 'category', 'caller', - 'level', 'operationName', 'resourceGroup', 'resourceProvider', 'status', 'subStatus', - 'resourceType', or anything beginning with 'properties'. - :type field: str - :param equals: The value of the event's field will be compared to this value (case-insensitive) - to determine if the condition is met. - :type equals: str - :param contains_any: The value of the event's field will be compared to the values in this - array (case-insensitive) to determine if the condition is met. - :type contains_any: list[str] - """ - - _attribute_map = { - 'field': {'key': 'field', 'type': 'str'}, - 'equals': {'key': 'equals', 'type': 'str'}, - 'contains_any': {'key': 'containsAny', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(AlertRuleLeafCondition, self).__init__(**kwargs) - self.field = kwargs.get('field', None) - self.equals = kwargs.get('equals', None) - self.contains_any = kwargs.get('contains_any', None) - - -class AlertRuleAnyOfOrLeafCondition(AlertRuleLeafCondition): - """An Activity Log Alert rule condition that is met when all its member conditions are met. -Each condition can be of one of the following types: -**Important**\ : Each type has its unique subset of properties. Properties from different types CANNOT exist in one condition. - - -* **Leaf Condition -** must contain 'field' and either 'equals' or 'containsAny'. - *Please note, 'anyOf' should **not** be set in a Leaf Condition.* - - * **AnyOf Condition -** must contain **only** 'anyOf' (which is an array of Leaf Conditions). - *Please note, 'field', 'equals' and 'containsAny' should **not** be set in an AnyOf Condition.*. - - :param field: The name of the Activity Log event's field that this condition will examine. - The possible values for this field are (case-insensitive): 'resourceId', 'category', 'caller', - 'level', 'operationName', 'resourceGroup', 'resourceProvider', 'status', 'subStatus', - 'resourceType', or anything beginning with 'properties'. - :type field: str - :param equals: The value of the event's field will be compared to this value (case-insensitive) - to determine if the condition is met. - :type equals: str - :param contains_any: The value of the event's field will be compared to the values in this - array (case-insensitive) to determine if the condition is met. - :type contains_any: list[str] - :param any_of: An Activity Log Alert rule condition that is met when at least one of its member - leaf conditions are met. - :type any_of: list[~$(python-base-namespace).v2020_10_01.models.AlertRuleLeafCondition] - """ - - _attribute_map = { - 'field': {'key': 'field', 'type': 'str'}, - 'equals': {'key': 'equals', 'type': 'str'}, - 'contains_any': {'key': 'containsAny', 'type': '[str]'}, - 'any_of': {'key': 'anyOf', 'type': '[AlertRuleLeafCondition]'}, - } - - def __init__( - self, - **kwargs - ): - super(AlertRuleAnyOfOrLeafCondition, self).__init__(**kwargs) - self.any_of = kwargs.get('any_of', None) - - -class 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 - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ActivityLogAlertResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AlertRuleList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -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 - Alert rule is not enabled, then none of its actions will be activated. - :type enabled: bool - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(AlertRulePatchObject, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.enabled = kwargs.get('enabled', True) - - -class ErrorResponse(msrest.serialization.Model): - """The error response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message indicating why the operation failed. - :vartype message: str - """ - - _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.code = None - self.message = None 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 f6a14450917f..f1101062bcca 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 19e1ae46f59c..fc2181da2fc5 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,23 +5,248 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + activity_log_alert_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + activity_log_alert_name: str, + **kwargs: Any +) -> 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: str, + resource_group_name: str, + activity_log_alert_name: str, + **kwargs: Any +) -> 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: str, + resource_group_name: str, + activity_log_alert_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_subscription_id_request( + subscription_id: str, + **kwargs: Any +) -> 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: str, + resource_group_name: str, + **kwargs: Any +) -> 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 + ) class ActivityLogAlertsOperations(object): """ActivityLogAlertsOperations operations. @@ -45,14 +270,14 @@ 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 - activity_log_alert_name, # type: str - activity_log_alert_rule, # type: "_models.ActivityLogAlertResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.ActivityLogAlertResource" + resource_group_name: str, + activity_log_alert_name: str, + activity_log_alert_rule: "_models.ActivityLogAlertResource", + **kwargs: Any + ) -> "_models.ActivityLogAlertResource": """Create a new Activity Log Alert rule or update an existing one. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -60,7 +285,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 +297,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] + + _json = self._serialize.body(activity_log_alert_rule, 'ActivityLogAlertResource') - # 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, + 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,15 +331,17 @@ 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 - activity_log_alert_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ActivityLogAlertResource" + resource_group_name: str, + activity_log_alert_name: str, + **kwargs: Any + ) -> "_models.ActivityLogAlertResource": """Get an Activity Log Alert rule. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -140,33 +358,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,15 +383,17 @@ 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 - activity_log_alert_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + activity_log_alert_name: str, + **kwargs: Any + ) -> None: """Delete an Activity Log Alert rule. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -200,33 +410,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,14 +434,15 @@ 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 - activity_log_alert_name, # type: str - activity_log_alert_rule_patch, # type: "_models.AlertRulePatchObject" - **kwargs # type: Any - ): - # type: (...) -> "_models.ActivityLogAlertResource" + resource_group_name: str, + activity_log_alert_name: str, + activity_log_alert_rule_patch: "_models.AlertRulePatchObject", + **kwargs: Any + ) -> "_models.ActivityLogAlertResource": """Updates 'tags' and 'enabled' fields in an existing Alert rule. This method is used to update the Alert rule tags, and to enable or disable the Alert rule. To update other fields use CreateOrUpdate operation. @@ -251,7 +452,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 +464,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,18 +494,21 @@ 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 - ): - # type: (...) -> Iterable["_models.AlertRuleList"] + **kwargs: Any + ) -> Iterable["_models.AlertRuleList"]: """Get a list of all Activity Log Alert rules in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either 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 +516,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,30 +551,32 @@ 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 - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AlertRuleList"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.AlertRuleList"]: """Get a list of all Activity Log Alert rules in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :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 +584,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 +621,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 d82479510092..ec9090a57df0 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 6c2b6a6fe818..030a5ba894ea 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 @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class MonitorManagementClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(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 +65,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 257eaf0e018b..b089e37d50b5 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 c28a4128d4c6..84dc1ddcca18 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,85 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import 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 - -class MonitorManagementClient(object): +class MonitorManagementClient: """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] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + 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: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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 000000000000..74e48ecd07cf --- /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 000000000000..138f663c53a4 --- /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 cac9f5d10f8b..e5754a47ce68 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 96ce9b45c05b..4eba911f1c6e 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 cb6cdeab6de8..457603f1e001 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 a18ea946eba9..cc25115a9967 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 000000000000..74e48ecd07cf --- /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 40fd39f48a97..dc284b81446b 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 8cf71334c09e..3492b8a74d5d 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 9affad029e76..f888346fcd12 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/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/__init__.py index 7a45f54ae725..1884e0dca0c1 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/__init__.py @@ -6,84 +6,45 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import AzureMonitorMetricsDestination - from ._models_py3 import ConfigurationAccessEndpointSpec - from ._models_py3 import DataCollectionEndpoint - from ._models_py3 import DataCollectionEndpointConfigurationAccess - from ._models_py3 import DataCollectionEndpointLogsIngestion - from ._models_py3 import DataCollectionEndpointNetworkAcls - from ._models_py3 import DataCollectionEndpointResource - from ._models_py3 import DataCollectionEndpointResourceListResult - from ._models_py3 import DataCollectionEndpointResourceProperties - from ._models_py3 import DataCollectionEndpointResourceSystemData - from ._models_py3 import DataCollectionRule - from ._models_py3 import DataCollectionRuleAssociation - from ._models_py3 import DataCollectionRuleAssociationProxyOnlyResource - from ._models_py3 import DataCollectionRuleAssociationProxyOnlyResourceListResult - from ._models_py3 import DataCollectionRuleAssociationProxyOnlyResourceProperties - from ._models_py3 import DataCollectionRuleAssociationProxyOnlyResourceSystemData - from ._models_py3 import DataCollectionRuleDataSources - from ._models_py3 import DataCollectionRuleDestinations - from ._models_py3 import DataCollectionRuleResource - from ._models_py3 import DataCollectionRuleResourceListResult - from ._models_py3 import DataCollectionRuleResourceProperties - from ._models_py3 import DataCollectionRuleResourceSystemData - from ._models_py3 import DataFlow - from ._models_py3 import DataSourcesSpec - from ._models_py3 import DestinationsSpec - from ._models_py3 import DestinationsSpecAzureMonitorMetrics - from ._models_py3 import ErrorAdditionalInfo - from ._models_py3 import ErrorDetail - from ._models_py3 import ErrorResponseCommonV2 - from ._models_py3 import ExtensionDataSource - from ._models_py3 import LogAnalyticsDestination - from ._models_py3 import LogsIngestionEndpointSpec - from ._models_py3 import NetworkRuleSet - from ._models_py3 import PerfCounterDataSource - from ._models_py3 import ResourceForUpdate - from ._models_py3 import SyslogDataSource - from ._models_py3 import SystemData - from ._models_py3 import WindowsEventLogDataSource -except (SyntaxError, ImportError): - from ._models import AzureMonitorMetricsDestination # type: ignore - from ._models import ConfigurationAccessEndpointSpec # type: ignore - from ._models import DataCollectionEndpoint # type: ignore - from ._models import DataCollectionEndpointConfigurationAccess # type: ignore - from ._models import DataCollectionEndpointLogsIngestion # type: ignore - from ._models import DataCollectionEndpointNetworkAcls # type: ignore - from ._models import DataCollectionEndpointResource # type: ignore - from ._models import DataCollectionEndpointResourceListResult # type: ignore - from ._models import DataCollectionEndpointResourceProperties # type: ignore - from ._models import DataCollectionEndpointResourceSystemData # type: ignore - from ._models import DataCollectionRule # type: ignore - from ._models import DataCollectionRuleAssociation # type: ignore - from ._models import DataCollectionRuleAssociationProxyOnlyResource # type: ignore - from ._models import DataCollectionRuleAssociationProxyOnlyResourceListResult # type: ignore - from ._models import DataCollectionRuleAssociationProxyOnlyResourceProperties # type: ignore - from ._models import DataCollectionRuleAssociationProxyOnlyResourceSystemData # type: ignore - from ._models import DataCollectionRuleDataSources # type: ignore - from ._models import DataCollectionRuleDestinations # type: ignore - from ._models import DataCollectionRuleResource # type: ignore - from ._models import DataCollectionRuleResourceListResult # type: ignore - from ._models import DataCollectionRuleResourceProperties # type: ignore - from ._models import DataCollectionRuleResourceSystemData # type: ignore - from ._models import DataFlow # type: ignore - from ._models import DataSourcesSpec # type: ignore - from ._models import DestinationsSpec # type: ignore - from ._models import DestinationsSpecAzureMonitorMetrics # type: ignore - from ._models import ErrorAdditionalInfo # type: ignore - from ._models import ErrorDetail # type: ignore - from ._models import ErrorResponseCommonV2 # type: ignore - from ._models import ExtensionDataSource # type: ignore - from ._models import LogAnalyticsDestination # type: ignore - from ._models import LogsIngestionEndpointSpec # type: ignore - from ._models import NetworkRuleSet # type: ignore - from ._models import PerfCounterDataSource # type: ignore - from ._models import ResourceForUpdate # type: ignore - from ._models import SyslogDataSource # type: ignore - from ._models import SystemData # type: ignore - from ._models import WindowsEventLogDataSource # type: ignore +from ._models_py3 import AzureMonitorMetricsDestination +from ._models_py3 import ConfigurationAccessEndpointSpec +from ._models_py3 import DataCollectionEndpoint +from ._models_py3 import DataCollectionEndpointConfigurationAccess +from ._models_py3 import DataCollectionEndpointLogsIngestion +from ._models_py3 import DataCollectionEndpointNetworkAcls +from ._models_py3 import DataCollectionEndpointResource +from ._models_py3 import DataCollectionEndpointResourceListResult +from ._models_py3 import DataCollectionEndpointResourceProperties +from ._models_py3 import DataCollectionEndpointResourceSystemData +from ._models_py3 import DataCollectionRule +from ._models_py3 import DataCollectionRuleAssociation +from ._models_py3 import DataCollectionRuleAssociationProxyOnlyResource +from ._models_py3 import DataCollectionRuleAssociationProxyOnlyResourceListResult +from ._models_py3 import DataCollectionRuleAssociationProxyOnlyResourceProperties +from ._models_py3 import DataCollectionRuleAssociationProxyOnlyResourceSystemData +from ._models_py3 import DataCollectionRuleDataSources +from ._models_py3 import DataCollectionRuleDestinations +from ._models_py3 import DataCollectionRuleResource +from ._models_py3 import DataCollectionRuleResourceListResult +from ._models_py3 import DataCollectionRuleResourceProperties +from ._models_py3 import DataCollectionRuleResourceSystemData +from ._models_py3 import DataFlow +from ._models_py3 import DataSourcesSpec +from ._models_py3 import DestinationsSpec +from ._models_py3 import DestinationsSpecAzureMonitorMetrics +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponseCommonV2 +from ._models_py3 import ExtensionDataSource +from ._models_py3 import LogAnalyticsDestination +from ._models_py3 import LogsIngestionEndpointSpec +from ._models_py3 import NetworkRuleSet +from ._models_py3 import PerfCounterDataSource +from ._models_py3 import ResourceForUpdate +from ._models_py3 import SyslogDataSource +from ._models_py3 import SystemData +from ._models_py3 import WindowsEventLogDataSource + from ._monitor_management_client_enums import ( CreatedByType, 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 deleted file mode 100644 index ebdaea572762..000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/_models.py +++ /dev/null @@ -1,1386 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class AzureMonitorMetricsDestination(msrest.serialization.Model): - """Azure Monitor Metrics destination. - - :param 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 - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureMonitorMetricsDestination, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - - -class ConfigurationAccessEndpointSpec(msrest.serialization.Model): - """Definition of the endpoint used for accessing configuration. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar endpoint: The endpoint. This property is READ-ONLY. - :vartype endpoint: str - """ - - _validation = { - 'endpoint': {'readonly': True}, - } - - _attribute_map = { - 'endpoint': {'key': 'endpoint', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ConfigurationAccessEndpointSpec, self).__init__(**kwargs) - self.endpoint = None - - -class DataCollectionEndpoint(msrest.serialization.Model): - """Definition of data collection endpoint. - - 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 - is READ-ONLY. - :type immutable_id: str - :param configuration_access: The endpoint used by agents to access their configuration. - :type configuration_access: - ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointConfigurationAccess - :param logs_ingestion: The endpoint used by clients to ingest logs. - :type logs_ingestion: - ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointLogsIngestion - :param network_acls: Network access control rules for the endpoints. - :type 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". - :vartype provisioning_state: str or - ~$(python-base-namespace).v2021_04_01.models.KnownDataCollectionEndpointProvisioningState - """ - - _validation = { - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'immutable_id': {'key': 'immutableId', 'type': 'str'}, - 'configuration_access': {'key': 'configurationAccess', 'type': 'DataCollectionEndpointConfigurationAccess'}, - 'logs_ingestion': {'key': 'logsIngestion', 'type': 'DataCollectionEndpointLogsIngestion'}, - 'network_acls': {'key': 'networkAcls', 'type': 'DataCollectionEndpointNetworkAcls'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DataCollectionEndpoint, self).__init__(**kwargs) - self.description = kwargs.get('description', None) - self.immutable_id = kwargs.get('immutable_id', None) - self.configuration_access = kwargs.get('configuration_access', None) - self.logs_ingestion = kwargs.get('logs_ingestion', None) - self.network_acls = kwargs.get('network_acls', None) - self.provisioning_state = None - - -class DataCollectionEndpointConfigurationAccess(ConfigurationAccessEndpointSpec): - """The endpoint used by agents to access their configuration. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar endpoint: The endpoint. This property is READ-ONLY. - :vartype endpoint: str - """ - - _validation = { - 'endpoint': {'readonly': True}, - } - - _attribute_map = { - 'endpoint': {'key': 'endpoint', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DataCollectionEndpointConfigurationAccess, self).__init__(**kwargs) - - -class LogsIngestionEndpointSpec(msrest.serialization.Model): - """Definition of the endpoint used for ingesting logs. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar endpoint: The endpoint. This property is READ-ONLY. - :vartype endpoint: str - """ - - _validation = { - 'endpoint': {'readonly': True}, - } - - _attribute_map = { - 'endpoint': {'key': 'endpoint', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LogsIngestionEndpointSpec, self).__init__(**kwargs) - self.endpoint = None - - -class DataCollectionEndpointLogsIngestion(LogsIngestionEndpointSpec): - """The endpoint used by clients to ingest logs. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar endpoint: The endpoint. This property is READ-ONLY. - :vartype endpoint: str - """ - - _validation = { - 'endpoint': {'readonly': True}, - } - - _attribute_map = { - 'endpoint': {'key': 'endpoint', 'type': 'str'}, - } - - 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 - internet to the endpoints are allowed. Possible values include: "Enabled", "Disabled". - :type public_network_access: str or - ~$(python-base-namespace).v2021_04_01.models.KnownPublicNetworkAccessOptions - """ - - _attribute_map = { - 'public_network_access': {'key': 'publicNetworkAccess', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkRuleSet, self).__init__(**kwargs) - self.public_network_access = kwargs.get('public_network_access', None) - - -class DataCollectionEndpointNetworkAcls(NetworkRuleSet): - """Network access control rules for the endpoints. - - :param 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 - ~$(python-base-namespace).v2021_04_01.models.KnownPublicNetworkAccessOptions - """ - - _attribute_map = { - 'public_network_access': {'key': 'publicNetworkAccess', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DataCollectionEndpointNetworkAcls, self).__init__(**kwargs) - - -class DataCollectionEndpointResource(msrest.serialization.Model): - """Definition of ARM tracked top level resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param 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 - ~$(python-base-namespace).v2021_04_01.models.KnownDataCollectionEndpointResourceKind - :ivar id: Fully qualified ID of the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :ivar etag: Resource entity tag (ETag). - :vartype etag: str - :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 - is READ-ONLY. - :type immutable_id: str - :param configuration_access: The endpoint used by agents to access their configuration. - :type configuration_access: - ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointConfigurationAccess - :param logs_ingestion: The endpoint used by clients to ingest logs. - :type logs_ingestion: - ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointLogsIngestion - :param network_acls: Network access control rules for the endpoints. - :type 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". - :vartype provisioning_state: str or - ~$(python-base-namespace).v2021_04_01.models.KnownDataCollectionEndpointProvisioningState - """ - - _validation = { - 'location': {'required': True}, - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'DataCollectionEndpointResourceSystemData'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'immutable_id': {'key': 'properties.immutableId', 'type': 'str'}, - 'configuration_access': {'key': 'properties.configurationAccess', 'type': 'DataCollectionEndpointConfigurationAccess'}, - 'logs_ingestion': {'key': 'properties.logsIngestion', 'type': 'DataCollectionEndpointLogsIngestion'}, - 'network_acls': {'key': 'properties.networkAcls', 'type': 'DataCollectionEndpointNetworkAcls'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DataCollectionEndpointResource, self).__init__(**kwargs) - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - self.kind = kwargs.get('kind', None) - self.id = None - self.name = None - self.type = None - self.etag = None - self.system_data = None - self.description = kwargs.get('description', None) - self.immutable_id = kwargs.get('immutable_id', None) - self.configuration_access = kwargs.get('configuration_access', None) - self.logs_ingestion = kwargs.get('logs_ingestion', None) - self.network_acls = kwargs.get('network_acls', None) - self.provisioning_state = None - - -class DataCollectionEndpointResourceListResult(msrest.serialization.Model): - """A pageable list of resources. - - 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 - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[DataCollectionEndpointResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DataCollectionEndpointResourceListResult, self).__init__(**kwargs) - self.value = kwargs['value'] - self.next_link = kwargs.get('next_link', None) - - -class DataCollectionEndpointResourceProperties(DataCollectionEndpoint): - """Resource properties. - - 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 - is READ-ONLY. - :type immutable_id: str - :param configuration_access: The endpoint used by agents to access their configuration. - :type configuration_access: - ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointConfigurationAccess - :param logs_ingestion: The endpoint used by clients to ingest logs. - :type logs_ingestion: - ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointLogsIngestion - :param network_acls: Network access control rules for the endpoints. - :type 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". - :vartype provisioning_state: str or - ~$(python-base-namespace).v2021_04_01.models.KnownDataCollectionEndpointProvisioningState - """ - - _validation = { - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'immutable_id': {'key': 'immutableId', 'type': 'str'}, - 'configuration_access': {'key': 'configurationAccess', 'type': 'DataCollectionEndpointConfigurationAccess'}, - 'logs_ingestion': {'key': 'logsIngestion', 'type': 'DataCollectionEndpointLogsIngestion'}, - 'network_acls': {'key': 'networkAcls', 'type': 'DataCollectionEndpointNetworkAcls'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - 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 - 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 - """ - - _attribute_map = { - 'created_by': {'key': 'createdBy', 'type': 'str'}, - 'created_by_type': {'key': 'createdByType', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(SystemData, self).__init__(**kwargs) - self.created_by = kwargs.get('created_by', None) - self.created_by_type = kwargs.get('created_by_type', None) - self.created_at = kwargs.get('created_at', None) - self.last_modified_by = kwargs.get('last_modified_by', None) - self.last_modified_by_type = kwargs.get('last_modified_by_type', None) - self.last_modified_at = kwargs.get('last_modified_at', None) - - -class 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 - 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 - """ - - _attribute_map = { - 'created_by': {'key': 'createdBy', 'type': 'str'}, - 'created_by_type': {'key': 'createdByType', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(DataCollectionEndpointResourceSystemData, self).__init__(**kwargs) - - -class DataCollectionRule(msrest.serialization.Model): - """Definition of what monitoring data to collect and where that data should be sent. - - 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 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. - 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] - :ivar provisioning_state: The resource provisioning state. Possible values include: "Creating", - "Updating", "Deleting", "Succeeded", "Failed". - :vartype provisioning_state: str or - ~$(python-base-namespace).v2021_04_01.models.KnownDataCollectionRuleProvisioningState - """ - - _validation = { - 'immutable_id': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'immutable_id': {'key': 'immutableId', 'type': 'str'}, - 'data_sources': {'key': 'dataSources', 'type': 'DataCollectionRuleDataSources'}, - 'destinations': {'key': 'destinations', 'type': 'DataCollectionRuleDestinations'}, - 'data_flows': {'key': 'dataFlows', 'type': '[DataFlow]'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DataCollectionRule, self).__init__(**kwargs) - self.description = kwargs.get('description', None) - self.immutable_id = None - self.data_sources = kwargs.get('data_sources', None) - self.destinations = kwargs.get('destinations', None) - self.data_flows = kwargs.get('data_flows', None) - self.provisioning_state = None - - -class DataCollectionRuleAssociation(msrest.serialization.Model): - """Definition of association of a data collection rule with a monitored Azure resource. - - 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 - associated. - :type data_collection_rule_id: str - :param data_collection_endpoint_id: The resource ID of the data collection endpoint that is to - be associated. - :type 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 - ~$(python-base-namespace).v2021_04_01.models.KnownDataCollectionRuleAssociationProvisioningState - """ - - _validation = { - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'data_collection_rule_id': {'key': 'dataCollectionRuleId', 'type': 'str'}, - 'data_collection_endpoint_id': {'key': 'dataCollectionEndpointId', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DataCollectionRuleAssociation, self).__init__(**kwargs) - self.description = kwargs.get('description', None) - self.data_collection_rule_id = kwargs.get('data_collection_rule_id', None) - self.data_collection_endpoint_id = kwargs.get('data_collection_endpoint_id', None) - self.provisioning_state = None - - -class DataCollectionRuleAssociationProxyOnlyResource(msrest.serialization.Model): - """Definition of generic ARM proxy resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified ID of the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :ivar etag: Resource entity tag (ETag). - :vartype etag: str - :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 - associated. - :type data_collection_rule_id: str - :param data_collection_endpoint_id: The resource ID of the data collection endpoint that is to - be associated. - :type 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 - ~$(python-base-namespace).v2021_04_01.models.KnownDataCollectionRuleAssociationProvisioningState - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'DataCollectionRuleAssociationProxyOnlyResourceSystemData'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'data_collection_rule_id': {'key': 'properties.dataCollectionRuleId', 'type': 'str'}, - 'data_collection_endpoint_id': {'key': 'properties.dataCollectionEndpointId', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DataCollectionRuleAssociationProxyOnlyResource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.etag = None - self.system_data = None - self.description = kwargs.get('description', None) - self.data_collection_rule_id = kwargs.get('data_collection_rule_id', None) - self.data_collection_endpoint_id = kwargs.get('data_collection_endpoint_id', None) - self.provisioning_state = None - - -class DataCollectionRuleAssociationProxyOnlyResourceListResult(msrest.serialization.Model): - """A pageable list of resources. - - 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.DataCollectionRuleAssociationProxyOnlyResource] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[DataCollectionRuleAssociationProxyOnlyResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DataCollectionRuleAssociationProxyOnlyResourceListResult, self).__init__(**kwargs) - self.value = kwargs['value'] - self.next_link = kwargs.get('next_link', None) - - -class DataCollectionRuleAssociationProxyOnlyResourceProperties(DataCollectionRuleAssociation): - """Resource properties. - - 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 - associated. - :type data_collection_rule_id: str - :param data_collection_endpoint_id: The resource ID of the data collection endpoint that is to - be associated. - :type 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 - ~$(python-base-namespace).v2021_04_01.models.KnownDataCollectionRuleAssociationProvisioningState - """ - - _validation = { - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'data_collection_rule_id': {'key': 'dataCollectionRuleId', 'type': 'str'}, - 'data_collection_endpoint_id': {'key': 'dataCollectionEndpointId', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - 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 - 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 - """ - - _attribute_map = { - 'created_by': {'key': 'createdBy', 'type': 'str'}, - 'created_by_type': {'key': 'createdByType', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - 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: - 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: - 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] - """ - - _attribute_map = { - 'performance_counters': {'key': 'performanceCounters', 'type': '[PerfCounterDataSource]'}, - 'windows_event_logs': {'key': 'windowsEventLogs', 'type': '[WindowsEventLogDataSource]'}, - 'syslog': {'key': 'syslog', 'type': '[SyslogDataSource]'}, - 'extensions': {'key': 'extensions', 'type': '[ExtensionDataSource]'}, - } - - def __init__( - self, - **kwargs - ): - super(DataSourcesSpec, self).__init__(**kwargs) - self.performance_counters = kwargs.get('performance_counters', None) - self.windows_event_logs = kwargs.get('windows_event_logs', None) - self.syslog = kwargs.get('syslog', None) - self.extensions = kwargs.get('extensions', None) - - -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: - 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: - 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] - """ - - _attribute_map = { - 'performance_counters': {'key': 'performanceCounters', 'type': '[PerfCounterDataSource]'}, - 'windows_event_logs': {'key': 'windowsEventLogs', 'type': '[WindowsEventLogDataSource]'}, - 'syslog': {'key': 'syslog', 'type': '[SyslogDataSource]'}, - 'extensions': {'key': 'extensions', 'type': '[ExtensionDataSource]'}, - } - - def __init__( - self, - **kwargs - ): - 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: - ~$(python-base-namespace).v2021_04_01.models.DestinationsSpecAzureMonitorMetrics - """ - - _attribute_map = { - 'log_analytics': {'key': 'logAnalytics', 'type': '[LogAnalyticsDestination]'}, - 'azure_monitor_metrics': {'key': 'azureMonitorMetrics', 'type': 'DestinationsSpecAzureMonitorMetrics'}, - } - - def __init__( - self, - **kwargs - ): - super(DestinationsSpec, self).__init__(**kwargs) - self.log_analytics = kwargs.get('log_analytics', None) - self.azure_monitor_metrics = kwargs.get('azure_monitor_metrics', None) - - -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: - ~$(python-base-namespace).v2021_04_01.models.DestinationsSpecAzureMonitorMetrics - """ - - _attribute_map = { - 'log_analytics': {'key': 'logAnalytics', 'type': '[LogAnalyticsDestination]'}, - 'azure_monitor_metrics': {'key': 'azureMonitorMetrics', 'type': 'DestinationsSpecAzureMonitorMetrics'}, - } - - def __init__( - self, - **kwargs - ): - super(DataCollectionRuleDestinations, self).__init__(**kwargs) - - -class DataCollectionRuleResource(msrest.serialization.Model): - """Definition of ARM tracked top level resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param 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 - ~$(python-base-namespace).v2021_04_01.models.KnownDataCollectionRuleResourceKind - :ivar id: Fully qualified ID of the resource. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str - :ivar etag: Resource entity tag (ETag). - :vartype etag: str - :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 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. - 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] - :ivar provisioning_state: The resource provisioning state. Possible values include: "Creating", - "Updating", "Deleting", "Succeeded", "Failed". - :vartype provisioning_state: str or - ~$(python-base-namespace).v2021_04_01.models.KnownDataCollectionRuleProvisioningState - """ - - _validation = { - 'location': {'required': True}, - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'system_data': {'readonly': True}, - 'immutable_id': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'DataCollectionRuleResourceSystemData'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'immutable_id': {'key': 'properties.immutableId', 'type': 'str'}, - 'data_sources': {'key': 'properties.dataSources', 'type': 'DataCollectionRuleDataSources'}, - 'destinations': {'key': 'properties.destinations', 'type': 'DataCollectionRuleDestinations'}, - 'data_flows': {'key': 'properties.dataFlows', 'type': '[DataFlow]'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DataCollectionRuleResource, self).__init__(**kwargs) - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - self.kind = kwargs.get('kind', None) - self.id = None - self.name = None - self.type = None - self.etag = None - self.system_data = None - self.description = kwargs.get('description', None) - self.immutable_id = None - self.data_sources = kwargs.get('data_sources', None) - self.destinations = kwargs.get('destinations', None) - self.data_flows = kwargs.get('data_flows', None) - self.provisioning_state = None - - -class DataCollectionRuleResourceListResult(msrest.serialization.Model): - """A pageable list of resources. - - 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 - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[DataCollectionRuleResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DataCollectionRuleResourceListResult, self).__init__(**kwargs) - self.value = kwargs['value'] - self.next_link = kwargs.get('next_link', None) - - -class DataCollectionRuleResourceProperties(DataCollectionRule): - """Resource properties. - - 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 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. - 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] - :ivar provisioning_state: The resource provisioning state. Possible values include: "Creating", - "Updating", "Deleting", "Succeeded", "Failed". - :vartype provisioning_state: str or - ~$(python-base-namespace).v2021_04_01.models.KnownDataCollectionRuleProvisioningState - """ - - _validation = { - 'immutable_id': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'immutable_id': {'key': 'immutableId', 'type': 'str'}, - 'data_sources': {'key': 'dataSources', 'type': 'DataCollectionRuleDataSources'}, - 'destinations': {'key': 'destinations', 'type': 'DataCollectionRuleDestinations'}, - 'data_flows': {'key': 'dataFlows', 'type': '[DataFlow]'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - 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 - 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 - """ - - _attribute_map = { - 'created_by': {'key': 'createdBy', 'type': 'str'}, - 'created_by_type': {'key': 'createdByType', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - 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] - """ - - _attribute_map = { - 'streams': {'key': 'streams', 'type': '[str]'}, - 'destinations': {'key': 'destinations', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(DataFlow, self).__init__(**kwargs) - self.streams = kwargs.get('streams', None) - self.destinations = kwargs.get('destinations', None) - - -class DestinationsSpecAzureMonitorMetrics(AzureMonitorMetricsDestination): - """Azure Monitor Metrics destination. - - :param 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 - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DestinationsSpecAzureMonitorMetrics, self).__init__(**kwargs) - - -class ErrorAdditionalInfo(msrest.serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: any - """ - - _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorAdditionalInfo, self).__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(msrest.serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~$(python-base-namespace).v2021_04_01.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~$(python-base-namespace).v2021_04_01.models.ErrorAdditionalInfo] - """ - - _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorDetail]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorDetail, self).__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -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 - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDetail'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponseCommonV2, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class ExtensionDataSource(msrest.serialization.Model): - """Definition of which data will be collected from a separate VM extension that integrates with the Azure Monitor Agent. -Collected from either Windows and Linux machines, depending on which extension is defined. - - 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. - 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 - ~$(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 - 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. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :type name: str - """ - - _validation = { - 'extension_name': {'required': True}, - } - - _attribute_map = { - 'streams': {'key': 'streams', 'type': '[str]'}, - 'extension_name': {'key': 'extensionName', 'type': 'str'}, - 'extension_settings': {'key': 'extensionSettings', 'type': 'object'}, - 'input_data_sources': {'key': 'inputDataSources', 'type': '[str]'}, - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ExtensionDataSource, self).__init__(**kwargs) - self.streams = kwargs.get('streams', None) - self.extension_name = kwargs['extension_name'] - self.extension_settings = kwargs.get('extension_settings', None) - self.input_data_sources = kwargs.get('input_data_sources', None) - self.name = kwargs.get('name', None) - - -class LogAnalyticsDestination(msrest.serialization.Model): - """Log Analytics destination. - - 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_id: The Customer ID of the Log Analytics workspace. - :vartype workspace_id: str - :param 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 - """ - - _validation = { - 'workspace_id': {'readonly': True}, - } - - _attribute_map = { - 'workspace_resource_id': {'key': 'workspaceResourceId', 'type': 'str'}, - 'workspace_id': {'key': 'workspaceId', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LogAnalyticsDestination, self).__init__(**kwargs) - self.workspace_resource_id = kwargs.get('workspace_resource_id', None) - self.workspace_id = None - self.name = kwargs.get('name', None) - - -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. - 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 - ~$(python-base-namespace).v2021_04_01.models.KnownPerfCounterDataSourceStreams] - :param 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 - 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. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :type name: str - """ - - _attribute_map = { - 'streams': {'key': 'streams', 'type': '[str]'}, - 'sampling_frequency_in_seconds': {'key': 'samplingFrequencyInSeconds', 'type': 'int'}, - 'counter_specifiers': {'key': 'counterSpecifiers', 'type': '[str]'}, - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PerfCounterDataSource, self).__init__(**kwargs) - self.streams = kwargs.get('streams', None) - self.sampling_frequency_in_seconds = kwargs.get('sampling_frequency_in_seconds', None) - self.counter_specifiers = kwargs.get('counter_specifiers', None) - self.name = kwargs.get('name', None) - - -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] - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceForUpdate, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - - -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. - 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 - ~$(python-base-namespace).v2021_04_01.models.KnownSyslogDataSourceStreams] - :param facility_names: The list of facility names. - :type 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 - ~$(python-base-namespace).v2021_04_01.models.KnownSyslogDataSourceLogLevels] - :param 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 - """ - - _attribute_map = { - 'streams': {'key': 'streams', 'type': '[str]'}, - 'facility_names': {'key': 'facilityNames', 'type': '[str]'}, - 'log_levels': {'key': 'logLevels', 'type': '[str]'}, - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SyslogDataSource, self).__init__(**kwargs) - self.streams = kwargs.get('streams', None) - self.facility_names = kwargs.get('facility_names', None) - self.log_levels = kwargs.get('log_levels', None) - self.name = kwargs.get('name', None) - - -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. - 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 - ~$(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. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :type name: str - """ - - _attribute_map = { - 'streams': {'key': 'streams', 'type': '[str]'}, - 'x_path_queries': {'key': 'xPathQueries', 'type': '[str]'}, - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WindowsEventLogDataSource, self).__init__(**kwargs) - self.streams = kwargs.get('streams', None) - self.x_path_queries = kwargs.get('x_path_queries', None) - self.name = kwargs.get('name', 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 b0edf7f37ce6..5fbd1e570899 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 9617f5f9e1e3..297a4c1f0059 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 623b4484c48f..e08e17d35616 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,23 +5,248 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> 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: str, + **kwargs: Any +) -> 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: str, + resource_group_name: str, + data_collection_endpoint_name: str, + **kwargs: Any +) -> 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: str, + resource_group_name: str, + data_collection_endpoint_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + subscription_id: str, + resource_group_name: str, + data_collection_endpoint_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + data_collection_endpoint_name: str, + **kwargs: Any +) -> 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 + ) class DataCollectionEndpointsOperations(object): """DataCollectionEndpointsOperations operations. @@ -45,12 +270,12 @@ 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 - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DataCollectionEndpointResourceListResult"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.DataCollectionEndpointResourceListResult"]: """Lists all data collection endpoints in the specified resource group. Lists all data collection endpoints in the specified resource group. @@ -58,8 +283,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 +294,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,29 +331,32 @@ 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 - ): - # type: (...) -> Iterable["_models.DataCollectionEndpointResourceListResult"] + **kwargs: Any + ) -> Iterable["_models.DataCollectionEndpointResourceListResult"]: """Lists all data collection endpoints in the specified 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 +364,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,24 +399,25 @@ 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 - data_collection_endpoint_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DataCollectionEndpointResource" + resource_group_name: str, + data_collection_endpoint_name: str, + **kwargs: Any + ) -> "_models.DataCollectionEndpointResource": """Returns the specified data collection endpoint. Returns the specified data collection endpoint. @@ -215,33 +437,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,16 +462,18 @@ 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 - data_collection_endpoint_name, # type: str - body=None, # type: Optional["_models.DataCollectionEndpointResource"] - **kwargs # type: Any - ): - # type: (...) -> "_models.DataCollectionEndpointResource" + resource_group_name: str, + data_collection_endpoint_name: str, + body: Optional["_models.DataCollectionEndpointResource"] = None, + **kwargs: Any + ) -> "_models.DataCollectionEndpointResource": """Creates or updates a data collection endpoint. Creates or updates a data collection endpoint. @@ -281,41 +495,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,16 +532,18 @@ 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 - data_collection_endpoint_name, # type: str - body=None, # type: Optional["_models.ResourceForUpdate"] - **kwargs # type: Any - ): - # type: (...) -> "_models.DataCollectionEndpointResource" + resource_group_name: str, + data_collection_endpoint_name: str, + body: Optional["_models.ResourceForUpdate"] = None, + **kwargs: Any + ) -> "_models.DataCollectionEndpointResource": """Updates part of a data collection endpoint. Updates part of a data collection endpoint. @@ -359,41 +565,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,15 +598,17 @@ 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 - data_collection_endpoint_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + data_collection_endpoint_name: str, + **kwargs: Any + ) -> None: """Deletes a data collection endpoint. Deletes a data collection endpoint. @@ -430,36 +628,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 9f6b43e857d1..9f0103c4e7f2 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,23 +5,200 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_resource_request( + resource_uri: str, + **kwargs: Any +) -> 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: str, + resource_group_name: str, + data_collection_rule_name: str, + **kwargs: Any +) -> 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: str, + association_name: str, + **kwargs: Any +) -> 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: str, + association_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_uri: str, + association_name: str, + **kwargs: Any +) -> 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 + ) class DataCollectionRuleAssociationsOperations(object): """DataCollectionRuleAssociationsOperations operations. @@ -45,12 +222,12 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource( self, - resource_uri, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DataCollectionRuleAssociationProxyOnlyResourceListResult"] + resource_uri: str, + **kwargs: Any + ) -> Iterable["_models.DataCollectionRuleAssociationProxyOnlyResourceListResult"]: """Lists associations for the specified resource. Lists associations for the specified resource. @@ -58,8 +235,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 +246,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,24 +281,25 @@ 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 - data_collection_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DataCollectionRuleAssociationProxyOnlyResourceListResult"] + resource_group_name: str, + data_collection_rule_name: str, + **kwargs: Any + ) -> Iterable["_models.DataCollectionRuleAssociationProxyOnlyResourceListResult"]: """Lists associations for the specified data collection rule. Lists associations for the specified data collection rule. @@ -135,8 +310,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 +321,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,24 +360,25 @@ 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 - association_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DataCollectionRuleAssociationProxyOnlyResource" + resource_uri: str, + association_name: str, + **kwargs: Any + ) -> "_models.DataCollectionRuleAssociationProxyOnlyResource": """Returns the specified association. Returns the specified association. @@ -214,7 +389,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 +398,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,16 +422,18 @@ 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 - association_name, # type: str - body=None, # type: Optional["_models.DataCollectionRuleAssociationProxyOnlyResource"] - **kwargs # type: Any - ): - # type: (...) -> "_models.DataCollectionRuleAssociationProxyOnlyResource" + resource_uri: str, + association_name: str, + body: Optional["_models.DataCollectionRuleAssociationProxyOnlyResource"] = None, + **kwargs: Any + ) -> "_models.DataCollectionRuleAssociationProxyOnlyResource": """Creates or updates an association. Creates or updates an association. @@ -275,10 +443,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 +456,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,15 +492,17 @@ 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 - association_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_uri: str, + association_name: str, + **kwargs: Any + ) -> None: """Deletes an association. Deletes an association. @@ -359,35 +521,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 287d2a231834..f9ee7485f273 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,23 +5,248 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> 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: str, + **kwargs: Any +) -> 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: str, + resource_group_name: str, + data_collection_rule_name: str, + **kwargs: Any +) -> 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: str, + resource_group_name: str, + data_collection_rule_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-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, + json=json, + content=content, + **kwargs + ) + + +def build_update_request( + subscription_id: str, + resource_group_name: str, + data_collection_rule_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-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, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + data_collection_rule_name: str, + **kwargs: Any +) -> 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 + ) class DataCollectionRulesOperations(object): """DataCollectionRulesOperations operations. @@ -45,12 +270,12 @@ 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 - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DataCollectionRuleResourceListResult"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.DataCollectionRuleResourceListResult"]: """Lists all data collection rules in the specified resource group. Lists all data collection rules in the specified resource group. @@ -58,8 +283,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 +294,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,29 +331,32 @@ 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 - ): - # type: (...) -> Iterable["_models.DataCollectionRuleResourceListResult"] + **kwargs: Any + ) -> Iterable["_models.DataCollectionRuleResourceListResult"]: """Lists all data collection rules in the specified 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 +364,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,24 +399,25 @@ 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 - data_collection_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DataCollectionRuleResource" + resource_group_name: str, + data_collection_rule_name: str, + **kwargs: Any + ) -> "_models.DataCollectionRuleResource": """Returns the specified data collection rule. Returns the specified data collection rule. @@ -215,33 +437,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,16 +462,18 @@ 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 - data_collection_rule_name, # type: str - body=None, # type: Optional["_models.DataCollectionRuleResource"] - **kwargs # type: Any - ): - # type: (...) -> "_models.DataCollectionRuleResource" + resource_group_name: str, + data_collection_rule_name: str, + body: Optional["_models.DataCollectionRuleResource"] = None, + **kwargs: Any + ) -> "_models.DataCollectionRuleResource": """Creates or updates a data collection rule. Creates or updates a data collection rule. @@ -281,41 +495,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,16 +532,18 @@ 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 - data_collection_rule_name, # type: str - body=None, # type: Optional["_models.ResourceForUpdate"] - **kwargs # type: Any - ): - # type: (...) -> "_models.DataCollectionRuleResource" + resource_group_name: str, + data_collection_rule_name: str, + body: Optional["_models.ResourceForUpdate"] = None, + **kwargs: Any + ) -> "_models.DataCollectionRuleResource": """Updates part of a data collection rule. Updates part of a data collection rule. @@ -359,41 +565,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,15 +598,17 @@ 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 - data_collection_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + data_collection_rule_name: str, + **kwargs: Any + ) -> None: """Deletes a data collection rule. Deletes a data collection rule. @@ -430,36 +628,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 d82479510092..ec9090a57df0 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 8c42b5473012..daa1eaa37dbe 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 @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class MonitorManagementClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(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 +65,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 2b64e6cd360c..3feeaec00b53 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 f8a24f027f31..519c5ba60fc2 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,98 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import 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 - -class MonitorManagementClient(object): +class MonitorManagementClient: """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] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + 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: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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 000000000000..74e48ecd07cf --- /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 000000000000..138f663c53a4 --- /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 cac9f5d10f8b..e5754a47ce68 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 96ce9b45c05b..4eba911f1c6e 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 af72dcd13a9f..7da2da751912 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 44fb006c737e..1024edbc3147 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 000000000000..74e48ecd07cf --- /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 18416b0517d6..7aa783a2f713 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 aa9858884eae..2caa5d0120dd 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 1c0867bbab31..3d65ad45bfed 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 0d3a2f487cb7..bcbdf0107658 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 55732a9aee1c..a3ad60180b57 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 303455c75d84..8dff60bc58a4 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/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/__init__.py index 4427b0d0f385..660f669f65c3 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/__init__.py @@ -6,80 +6,43 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import AutoscaleErrorResponse - from ._models_py3 import AutoscaleErrorResponseError - from ._models_py3 import AutoscaleNotification - from ._models_py3 import AutoscaleProfile - from ._models_py3 import AutoscaleSettingResource - from ._models_py3 import AutoscaleSettingResourceCollection - from ._models_py3 import AutoscaleSettingResourcePatch - from ._models_py3 import DiagnosticSettingsCategoryResource - from ._models_py3 import DiagnosticSettingsCategoryResourceCollection - from ._models_py3 import DiagnosticSettingsResource - from ._models_py3 import DiagnosticSettingsResourceCollection - from ._models_py3 import EmailNotification - from ._models_py3 import ErrorResponse - from ._models_py3 import LogSettings - from ._models_py3 import ManagementGroupDiagnosticSettingsResource - from ._models_py3 import ManagementGroupDiagnosticSettingsResourceCollection - from ._models_py3 import ManagementGroupLogSettings - from ._models_py3 import MetricSettings - from ._models_py3 import MetricTrigger - from ._models_py3 import PredictiveAutoscalePolicy - from ._models_py3 import PredictiveResponse - from ._models_py3 import PredictiveValue - from ._models_py3 import Recurrence - from ._models_py3 import RecurrentSchedule - from ._models_py3 import Resource - from ._models_py3 import RetentionPolicy - from ._models_py3 import ScaleAction - from ._models_py3 import ScaleCapacity - from ._models_py3 import ScaleRule - from ._models_py3 import ScaleRuleMetricDimension - from ._models_py3 import SubscriptionDiagnosticSettingsResource - from ._models_py3 import SubscriptionDiagnosticSettingsResourceCollection - from ._models_py3 import SubscriptionLogSettings - from ._models_py3 import SystemData - from ._models_py3 import TimeWindow - from ._models_py3 import WebhookNotification -except (SyntaxError, ImportError): - from ._models import AutoscaleErrorResponse # type: ignore - from ._models import AutoscaleErrorResponseError # type: ignore - from ._models import AutoscaleNotification # type: ignore - from ._models import AutoscaleProfile # type: ignore - from ._models import AutoscaleSettingResource # type: ignore - from ._models import AutoscaleSettingResourceCollection # type: ignore - from ._models import AutoscaleSettingResourcePatch # type: ignore - from ._models import DiagnosticSettingsCategoryResource # type: ignore - from ._models import DiagnosticSettingsCategoryResourceCollection # type: ignore - from ._models import DiagnosticSettingsResource # type: ignore - from ._models import DiagnosticSettingsResourceCollection # type: ignore - from ._models import EmailNotification # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import LogSettings # type: ignore - from ._models import ManagementGroupDiagnosticSettingsResource # type: ignore - from ._models import ManagementGroupDiagnosticSettingsResourceCollection # type: ignore - from ._models import ManagementGroupLogSettings # type: ignore - from ._models import MetricSettings # type: ignore - from ._models import MetricTrigger # type: ignore - from ._models import PredictiveAutoscalePolicy # type: ignore - from ._models import PredictiveResponse # type: ignore - from ._models import PredictiveValue # type: ignore - from ._models import Recurrence # type: ignore - from ._models import RecurrentSchedule # type: ignore - from ._models import Resource # type: ignore - from ._models import RetentionPolicy # type: ignore - from ._models import ScaleAction # type: ignore - from ._models import ScaleCapacity # type: ignore - from ._models import ScaleRule # type: ignore - from ._models import ScaleRuleMetricDimension # type: ignore - from ._models import SubscriptionDiagnosticSettingsResource # type: ignore - from ._models import SubscriptionDiagnosticSettingsResourceCollection # type: ignore - from ._models import SubscriptionLogSettings # type: ignore - from ._models import SystemData # type: ignore - from ._models import TimeWindow # type: ignore - from ._models import WebhookNotification # type: ignore +from ._models_py3 import AutoscaleErrorResponse +from ._models_py3 import AutoscaleErrorResponseError +from ._models_py3 import AutoscaleNotification +from ._models_py3 import AutoscaleProfile +from ._models_py3 import AutoscaleSettingResource +from ._models_py3 import AutoscaleSettingResourceCollection +from ._models_py3 import AutoscaleSettingResourcePatch +from ._models_py3 import DiagnosticSettingsCategoryResource +from ._models_py3 import DiagnosticSettingsCategoryResourceCollection +from ._models_py3 import DiagnosticSettingsResource +from ._models_py3 import DiagnosticSettingsResourceCollection +from ._models_py3 import EmailNotification +from ._models_py3 import ErrorResponse +from ._models_py3 import LogSettings +from ._models_py3 import ManagementGroupDiagnosticSettingsResource +from ._models_py3 import ManagementGroupDiagnosticSettingsResourceCollection +from ._models_py3 import ManagementGroupLogSettings +from ._models_py3 import MetricSettings +from ._models_py3 import MetricTrigger +from ._models_py3 import PredictiveAutoscalePolicy +from ._models_py3 import PredictiveResponse +from ._models_py3 import PredictiveValue +from ._models_py3 import Recurrence +from ._models_py3 import RecurrentSchedule +from ._models_py3 import Resource +from ._models_py3 import RetentionPolicy +from ._models_py3 import ScaleAction +from ._models_py3 import ScaleCapacity +from ._models_py3 import ScaleRule +from ._models_py3 import ScaleRuleMetricDimension +from ._models_py3 import SubscriptionDiagnosticSettingsResource +from ._models_py3 import SubscriptionDiagnosticSettingsResourceCollection +from ._models_py3 import SubscriptionLogSettings +from ._models_py3 import SystemData +from ._models_py3 import TimeWindow +from ._models_py3 import WebhookNotification + from ._monitor_management_client_enums import ( CategoryType, 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 deleted file mode 100644 index 080976daeeff..000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/_models.py +++ /dev/null @@ -1,1535 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class AutoscaleErrorResponse(msrest.serialization.Model): - """Describes the format of Error response. - - 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 system_data: The system metadata related to the response. - :vartype system_data: ~$(python-base-namespace).v2021_05_01_preview.models.SystemData - """ - - _validation = { - 'system_data': {'readonly': True}, - } - - _attribute_map = { - 'error': {'key': 'error', 'type': 'AutoscaleErrorResponseError'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - } - - def __init__( - self, - **kwargs - ): - super(AutoscaleErrorResponse, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - self.system_data = None - - -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 - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AutoscaleErrorResponseError, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - self.target = kwargs.get('target', None) - self.details = kwargs.get('details', None) - - -class AutoscaleNotification(msrest.serialization.Model): - """Autoscale notification. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar 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] - """ - - _validation = { - 'operation': {'required': True, 'constant': True}, - } - - _attribute_map = { - 'operation': {'key': 'operation', 'type': 'str'}, - 'email': {'key': 'email', 'type': 'EmailNotification'}, - 'webhooks': {'key': 'webhooks', 'type': '[WebhookNotification]'}, - } - - operation = "Scale" - - def __init__( - self, - **kwargs - ): - super(AutoscaleNotification, self).__init__(**kwargs) - self.email = kwargs.get('email', None) - self.webhooks = kwargs.get('webhooks', None) - - -class AutoscaleProfile(msrest.serialization.Model): - """Autoscale profile. - - 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 - 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 - """ - - _validation = { - 'name': {'required': True}, - 'capacity': {'required': True}, - 'rules': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'ScaleCapacity'}, - 'rules': {'key': 'rules', 'type': '[ScaleRule]'}, - 'fixed_date': {'key': 'fixedDate', 'type': 'TimeWindow'}, - 'recurrence': {'key': 'recurrence', 'type': 'Recurrence'}, - } - - def __init__( - self, - **kwargs - ): - super(AutoscaleProfile, self).__init__(**kwargs) - self.name = kwargs['name'] - self.capacity = kwargs['capacity'] - self.rules = kwargs['rules'] - self.fixed_date = kwargs.get('fixed_date', None) - self.recurrence = kwargs.get('recurrence', None) - - -class AutoscaleSettingResource(msrest.serialization.Model): - """The autoscale setting resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :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. - 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] - :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 - 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: - list[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleNotification] - :param 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: - ~$(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 - should be added to. - :type target_resource_uri: str - :param target_resource_location: the location of the resource that the autoscale setting should - be added to. - :type target_resource_location: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'profiles': {'required': True, 'max_items': 20, 'min_items': 0}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'profiles': {'key': 'properties.profiles', 'type': '[AutoscaleProfile]'}, - 'notifications': {'key': 'properties.notifications', 'type': '[AutoscaleNotification]'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - 'predictive_autoscale_policy': {'key': 'properties.predictiveAutoscalePolicy', 'type': 'PredictiveAutoscalePolicy'}, - 'name_properties_name': {'key': 'properties.name', 'type': 'str'}, - 'target_resource_uri': {'key': 'properties.targetResourceUri', 'type': 'str'}, - 'target_resource_location': {'key': 'properties.targetResourceLocation', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AutoscaleSettingResource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - self.system_data = None - self.profiles = kwargs['profiles'] - self.notifications = kwargs.get('notifications', None) - self.enabled = kwargs.get('enabled', True) - self.predictive_autoscale_policy = kwargs.get('predictive_autoscale_policy', None) - self.name_properties_name = kwargs.get('name_properties_name', None) - self.target_resource_uri = kwargs.get('target_resource_uri', None) - self.target_resource_location = kwargs.get('target_resource_location', None) - - -class AutoscaleSettingResourceCollection(msrest.serialization.Model): - """Represents a collection of autoscale setting resources. - - 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).v2021_05_01_preview.models.AutoscaleSettingResource] - :param next_link: URL to get the next set of results. - :type next_link: str - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[AutoscaleSettingResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AutoscaleSettingResourceCollection, self).__init__(**kwargs) - self.value = kwargs['value'] - self.next_link = kwargs.get('next_link', None) - - -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 - 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: - list[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleNotification] - :param 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: - ~$(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 - should be added to. - :type target_resource_uri: str - :param target_resource_location: the location of the resource that the autoscale setting should - be added to. - :type target_resource_location: str - """ - - _validation = { - 'profiles': {'max_items': 20, 'min_items': 0}, - } - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'profiles': {'key': 'properties.profiles', 'type': '[AutoscaleProfile]'}, - 'notifications': {'key': 'properties.notifications', 'type': '[AutoscaleNotification]'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - 'predictive_autoscale_policy': {'key': 'properties.predictiveAutoscalePolicy', 'type': 'PredictiveAutoscalePolicy'}, - 'name': {'key': 'properties.name', 'type': 'str'}, - 'target_resource_uri': {'key': 'properties.targetResourceUri', 'type': 'str'}, - 'target_resource_location': {'key': 'properties.targetResourceLocation', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AutoscaleSettingResourcePatch, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.profiles = kwargs.get('profiles', None) - self.notifications = kwargs.get('notifications', None) - self.enabled = kwargs.get('enabled', True) - self.predictive_autoscale_policy = kwargs.get('predictive_autoscale_policy', None) - self.name = kwargs.get('name', None) - self.target_resource_uri = kwargs.get('target_resource_uri', None) - self.target_resource_location = kwargs.get('target_resource_location', None) - - -class Resource(msrest.serialization.Model): - """Common fields that are returned in the response for all Azure Resource Manager resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class DiagnosticSettingsCategoryResource(Resource): - """The diagnostic settings category resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :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: - "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] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'category_type': {'key': 'properties.categoryType', 'type': 'str'}, - 'category_groups': {'key': 'properties.categoryGroups', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(DiagnosticSettingsCategoryResource, self).__init__(**kwargs) - self.system_data = None - self.category_type = kwargs.get('category_type', None) - self.category_groups = kwargs.get('category_groups', None) - - -class DiagnosticSettingsCategoryResourceCollection(msrest.serialization.Model): - """Represents a collection of diagnostic setting category resources. - - :param value: The collection of diagnostic settings category resources. - :type value: - list[~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsCategoryResource] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[DiagnosticSettingsCategoryResource]'}, - } - - def __init__( - self, - **kwargs - ): - super(DiagnosticSettingsCategoryResourceCollection, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class DiagnosticSettingsResource(Resource): - """The diagnostic setting resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :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 - 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 - 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 - 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 - 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 - 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 - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'storage_account_id': {'key': 'properties.storageAccountId', 'type': 'str'}, - 'service_bus_rule_id': {'key': 'properties.serviceBusRuleId', 'type': 'str'}, - 'event_hub_authorization_rule_id': {'key': 'properties.eventHubAuthorizationRuleId', 'type': 'str'}, - 'event_hub_name': {'key': 'properties.eventHubName', 'type': 'str'}, - 'metrics': {'key': 'properties.metrics', 'type': '[MetricSettings]'}, - 'logs': {'key': 'properties.logs', 'type': '[LogSettings]'}, - 'workspace_id': {'key': 'properties.workspaceId', 'type': 'str'}, - 'marketplace_partner_id': {'key': 'properties.marketplacePartnerId', 'type': 'str'}, - 'log_analytics_destination_type': {'key': 'properties.logAnalyticsDestinationType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DiagnosticSettingsResource, self).__init__(**kwargs) - self.system_data = None - self.storage_account_id = kwargs.get('storage_account_id', None) - self.service_bus_rule_id = kwargs.get('service_bus_rule_id', None) - self.event_hub_authorization_rule_id = kwargs.get('event_hub_authorization_rule_id', None) - self.event_hub_name = kwargs.get('event_hub_name', None) - self.metrics = kwargs.get('metrics', None) - self.logs = kwargs.get('logs', None) - self.workspace_id = kwargs.get('workspace_id', None) - self.marketplace_partner_id = kwargs.get('marketplace_partner_id', None) - self.log_analytics_destination_type = kwargs.get('log_analytics_destination_type', None) - - -class DiagnosticSettingsResourceCollection(msrest.serialization.Model): - """Represents a collection of alert rule resources. - - :param value: The collection of diagnostic settings resources;. - :type value: - list[~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsResource] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[DiagnosticSettingsResource]'}, - } - - def __init__( - self, - **kwargs - ): - super(DiagnosticSettingsResourceCollection, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class EmailNotification(msrest.serialization.Model): - """Email notification of an autoscale event. - - :param 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 - 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 - this attribute will be ignored. - :type custom_emails: list[str] - """ - - _attribute_map = { - 'send_to_subscription_administrator': {'key': 'sendToSubscriptionAdministrator', 'type': 'bool'}, - 'send_to_subscription_co_administrators': {'key': 'sendToSubscriptionCoAdministrators', 'type': 'bool'}, - 'custom_emails': {'key': 'customEmails', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - 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) - self.custom_emails = kwargs.get('custom_emails', None) - - -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 - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - - -class LogSettings(msrest.serialization.Model): - """Part of MultiTenantDiagnosticSettings. Specifies the settings for a particular log. - - 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 - 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 - 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 - """ - - _validation = { - 'enabled': {'required': True}, - } - - _attribute_map = { - 'category': {'key': 'category', 'type': 'str'}, - 'category_group': {'key': 'categoryGroup', 'type': 'str'}, - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'retention_policy': {'key': 'retentionPolicy', 'type': 'RetentionPolicy'}, - } - - def __init__( - self, - **kwargs - ): - super(LogSettings, self).__init__(**kwargs) - self.category = kwargs.get('category', None) - self.category_group = kwargs.get('category_group', None) - self.enabled = kwargs['enabled'] - self.retention_policy = kwargs.get('retention_policy', None) - - -class ManagementGroupDiagnosticSettingsResource(Resource): - """The management group diagnostic setting resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :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 - 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 - 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 - 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.ManagementGroupLogSettings] - :param 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 - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'storage_account_id': {'key': 'properties.storageAccountId', 'type': 'str'}, - 'service_bus_rule_id': {'key': 'properties.serviceBusRuleId', 'type': 'str'}, - 'event_hub_authorization_rule_id': {'key': 'properties.eventHubAuthorizationRuleId', 'type': 'str'}, - 'event_hub_name': {'key': 'properties.eventHubName', 'type': 'str'}, - 'logs': {'key': 'properties.logs', 'type': '[ManagementGroupLogSettings]'}, - 'workspace_id': {'key': 'properties.workspaceId', 'type': 'str'}, - 'marketplace_partner_id': {'key': 'properties.marketplacePartnerId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagementGroupDiagnosticSettingsResource, self).__init__(**kwargs) - self.system_data = None - self.storage_account_id = kwargs.get('storage_account_id', None) - self.service_bus_rule_id = kwargs.get('service_bus_rule_id', None) - self.event_hub_authorization_rule_id = kwargs.get('event_hub_authorization_rule_id', None) - self.event_hub_name = kwargs.get('event_hub_name', None) - self.logs = kwargs.get('logs', None) - self.workspace_id = kwargs.get('workspace_id', None) - self.marketplace_partner_id = kwargs.get('marketplace_partner_id', None) - - -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: - list[~$(python-base-namespace).v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ManagementGroupDiagnosticSettingsResource]'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagementGroupDiagnosticSettingsResourceCollection, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class ManagementGroupLogSettings(msrest.serialization.Model): - """Part of Management Group diagnostic setting. Specifies the settings for a particular log. - - 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 - setting is applied to. - :type category: str - :param 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 - """ - - _validation = { - 'enabled': {'required': True}, - } - - _attribute_map = { - 'category': {'key': 'category', 'type': 'str'}, - 'category_group': {'key': 'categoryGroup', 'type': 'str'}, - 'enabled': {'key': 'enabled', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagementGroupLogSettings, self).__init__(**kwargs) - self.category = kwargs.get('category', None) - self.category_group = kwargs.get('category_group', None) - self.enabled = kwargs['enabled'] - - -class MetricSettings(msrest.serialization.Model): - """Part of MultiTenantDiagnosticSettings. Specifies the settings for a particular metric. - - 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 - 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 - """ - - _validation = { - 'enabled': {'required': True}, - } - - _attribute_map = { - 'time_grain': {'key': 'timeGrain', 'type': 'duration'}, - 'category': {'key': 'category', 'type': 'str'}, - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'retention_policy': {'key': 'retentionPolicy', 'type': 'RetentionPolicy'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricSettings, self).__init__(**kwargs) - self.time_grain = kwargs.get('time_grain', None) - self.category = kwargs.get('category', None) - self.enabled = kwargs['enabled'] - self.retention_policy = kwargs.get('retention_policy', None) - - -class MetricTrigger(msrest.serialization.Model): - """The trigger that results in a scaling action. - - 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 - 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 - are combined. Possible values include: "Average", "Min", "Max", "Sum", "Count". - :type 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 - 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 - 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).v2021_05_01_preview.models.TimeAggregationType - :param 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).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: - [{"DimensionName":"AppName","Operator":"Equals","Values":["App1"]},{"DimensionName":"Deployment","Operator":"Equals","Values":["default"]}]. - :type 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 - """ - - _validation = { - 'metric_name': {'required': True}, - 'metric_resource_uri': {'required': True}, - 'time_grain': {'required': True}, - 'statistic': {'required': True}, - 'time_window': {'required': True}, - 'time_aggregation': {'required': True}, - 'operator': {'required': True}, - 'threshold': {'required': True}, - } - - _attribute_map = { - 'metric_name': {'key': 'metricName', 'type': 'str'}, - 'metric_namespace': {'key': 'metricNamespace', 'type': 'str'}, - 'metric_resource_uri': {'key': 'metricResourceUri', 'type': 'str'}, - 'metric_resource_location': {'key': 'metricResourceLocation', 'type': 'str'}, - 'time_grain': {'key': 'timeGrain', 'type': 'duration'}, - 'statistic': {'key': 'statistic', 'type': 'str'}, - 'time_window': {'key': 'timeWindow', 'type': 'duration'}, - 'time_aggregation': {'key': 'timeAggregation', 'type': 'str'}, - 'operator': {'key': 'operator', 'type': 'str'}, - 'threshold': {'key': 'threshold', 'type': 'float'}, - 'dimensions': {'key': 'dimensions', 'type': '[ScaleRuleMetricDimension]'}, - 'divide_per_instance': {'key': 'dividePerInstance', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricTrigger, self).__init__(**kwargs) - self.metric_name = kwargs['metric_name'] - self.metric_namespace = kwargs.get('metric_namespace', None) - self.metric_resource_uri = kwargs['metric_resource_uri'] - self.metric_resource_location = kwargs.get('metric_resource_location', None) - self.time_grain = kwargs['time_grain'] - self.statistic = kwargs['statistic'] - self.time_window = kwargs['time_window'] - self.time_aggregation = kwargs['time_aggregation'] - self.operator = kwargs['operator'] - self.threshold = kwargs['threshold'] - self.dimensions = kwargs.get('dimensions', None) - self.divide_per_instance = kwargs.get('divide_per_instance', None) - - -class PredictiveAutoscalePolicy(msrest.serialization.Model): - """The parameters for enabling predictive autoscale. - - 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 - ~$(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 - advance. It must be between 1 minute and 60 minutes in ISO 8601 format. - :type scale_look_ahead_time: ~datetime.timedelta - """ - - _validation = { - 'scale_mode': {'required': True}, - } - - _attribute_map = { - 'scale_mode': {'key': 'scaleMode', 'type': 'str'}, - 'scale_look_ahead_time': {'key': 'scaleLookAheadTime', 'type': 'duration'}, - } - - def __init__( - self, - **kwargs - ): - super(PredictiveAutoscalePolicy, self).__init__(**kwargs) - self.scale_mode = kwargs['scale_mode'] - self.scale_look_ahead_time = kwargs.get('scale_look_ahead_time', None) - - -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 - 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] - """ - - _attribute_map = { - 'timespan': {'key': 'timespan', 'type': 'str'}, - 'interval': {'key': 'interval', 'type': 'duration'}, - 'metric_name': {'key': 'metricName', 'type': 'str'}, - 'target_resource_id': {'key': 'targetResourceId', 'type': 'str'}, - 'data': {'key': 'data', 'type': '[PredictiveValue]'}, - } - - def __init__( - self, - **kwargs - ): - super(PredictiveResponse, self).__init__(**kwargs) - self.timespan = kwargs.get('timespan', None) - self.interval = kwargs.get('interval', None) - self.metric_name = kwargs.get('metric_name', None) - self.target_resource_id = kwargs.get('target_resource_id', None) - self.data = kwargs.get('data', None) - - -class PredictiveValue(msrest.serialization.Model): - """Represents a predictive metric value in the given bucket. - - 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 - """ - - _validation = { - 'time_stamp': {'required': True}, - 'value': {'required': True}, - } - - _attribute_map = { - 'time_stamp': {'key': 'timeStamp', 'type': 'iso-8601'}, - 'value': {'key': 'value', 'type': 'float'}, - } - - def __init__( - self, - **kwargs - ): - super(PredictiveValue, self).__init__(**kwargs) - self.time_stamp = kwargs['time_stamp'] - self.value = kwargs['value'] - - -class Recurrence(msrest.serialization.Model): - """The repeating times at which this profile begins. This element is not used if the FixedDate element is used. - - 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 - 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).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 - """ - - _validation = { - 'frequency': {'required': True}, - 'schedule': {'required': True}, - } - - _attribute_map = { - 'frequency': {'key': 'frequency', 'type': 'str'}, - 'schedule': {'key': 'schedule', 'type': 'RecurrentSchedule'}, - } - - def __init__( - self, - **kwargs - ): - super(Recurrence, self).__init__(**kwargs) - self.frequency = kwargs['frequency'] - self.schedule = kwargs['schedule'] - - -class RecurrentSchedule(msrest.serialization.Model): - """The scheduling constraints for when the profile begins. - - 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 - 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. - :type time_zone: str - :param 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] - """ - - _validation = { - 'time_zone': {'required': True}, - 'days': {'required': True}, - 'hours': {'required': True}, - 'minutes': {'required': True}, - } - - _attribute_map = { - 'time_zone': {'key': 'timeZone', 'type': 'str'}, - 'days': {'key': 'days', 'type': '[str]'}, - 'hours': {'key': 'hours', 'type': '[int]'}, - 'minutes': {'key': 'minutes', 'type': '[int]'}, - } - - def __init__( - self, - **kwargs - ): - super(RecurrentSchedule, self).__init__(**kwargs) - self.time_zone = kwargs['time_zone'] - self.days = kwargs['days'] - self.hours = kwargs['hours'] - self.minutes = kwargs['minutes'] - - -class RetentionPolicy(msrest.serialization.Model): - """Specifies the retention policy for the log. - - 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 - the events indefinitely. - :type days: int - """ - - _validation = { - 'enabled': {'required': True}, - 'days': {'required': True, 'minimum': 0}, - } - - _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'days': {'key': 'days', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(RetentionPolicy, self).__init__(**kwargs) - self.enabled = kwargs['enabled'] - self.days = kwargs['days'] - - -class ScaleAction(msrest.serialization.Model): - """The parameters for the scaling action. - - All required parameters must be populated in order to send to Azure. - - :param 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 - 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 - 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 - action occurs. It must be between 1 week and 1 minute in ISO 8601 format. - :type cooldown: ~datetime.timedelta - """ - - _validation = { - 'direction': {'required': True}, - 'type': {'required': True}, - 'cooldown': {'required': True}, - } - - _attribute_map = { - 'direction': {'key': 'direction', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'cooldown': {'key': 'cooldown', 'type': 'duration'}, - } - - def __init__( - self, - **kwargs - ): - super(ScaleAction, self).__init__(**kwargs) - self.direction = kwargs['direction'] - self.type = kwargs['type'] - self.value = kwargs.get('value', "1") - self.cooldown = kwargs['cooldown'] - - -class ScaleCapacity(msrest.serialization.Model): - """The number of instances that can be used during this profile. - - 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 - 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 - for evaluation. The default is only used if the current instance count is lower than the - default. - :type default: str - """ - - _validation = { - 'minimum': {'required': True}, - 'maximum': {'required': True}, - 'default': {'required': True}, - } - - _attribute_map = { - 'minimum': {'key': 'minimum', 'type': 'str'}, - 'maximum': {'key': 'maximum', 'type': 'str'}, - 'default': {'key': 'default', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ScaleCapacity, self).__init__(**kwargs) - self.minimum = kwargs['minimum'] - self.maximum = kwargs['maximum'] - self.default = kwargs['default'] - - -class ScaleRule(msrest.serialization.Model): - """A rule that provide the triggers and parameters for the scaling action. - - 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 - """ - - _validation = { - 'metric_trigger': {'required': True}, - 'scale_action': {'required': True}, - } - - _attribute_map = { - 'metric_trigger': {'key': 'metricTrigger', 'type': 'MetricTrigger'}, - 'scale_action': {'key': 'scaleAction', 'type': 'ScaleAction'}, - } - - def __init__( - self, - **kwargs - ): - super(ScaleRule, self).__init__(**kwargs) - self.metric_trigger = kwargs['metric_trigger'] - self.scale_action = kwargs['scale_action'] - - -class ScaleRuleMetricDimension(msrest.serialization.Model): - """Specifies an auto scale rule metric dimension. - - 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. - '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 - ~$(python-base-namespace).v2021_05_01_preview.models.ScaleRuleMetricDimensionOperationType - :param values: Required. list of dimension values. For example: ["App1","App2"]. - :type values: list[str] - """ - - _validation = { - 'dimension_name': {'required': True}, - 'operator': {'required': True}, - 'values': {'required': True}, - } - - _attribute_map = { - 'dimension_name': {'key': 'DimensionName', 'type': 'str'}, - 'operator': {'key': 'Operator', 'type': 'str'}, - 'values': {'key': 'Values', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(ScaleRuleMetricDimension, self).__init__(**kwargs) - self.dimension_name = kwargs['dimension_name'] - self.operator = kwargs['operator'] - self.values = kwargs['values'] - - -class SubscriptionDiagnosticSettingsResource(Resource): - """The subscription diagnostic setting resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :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 - 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 - 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 - 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 - 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 - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'storage_account_id': {'key': 'properties.storageAccountId', 'type': 'str'}, - 'service_bus_rule_id': {'key': 'properties.serviceBusRuleId', 'type': 'str'}, - 'event_hub_authorization_rule_id': {'key': 'properties.eventHubAuthorizationRuleId', 'type': 'str'}, - 'event_hub_name': {'key': 'properties.eventHubName', 'type': 'str'}, - 'logs': {'key': 'properties.logs', 'type': '[SubscriptionLogSettings]'}, - 'workspace_id': {'key': 'properties.workspaceId', 'type': 'str'}, - 'marketplace_partner_id': {'key': 'properties.marketplacePartnerId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SubscriptionDiagnosticSettingsResource, self).__init__(**kwargs) - self.system_data = None - self.storage_account_id = kwargs.get('storage_account_id', None) - self.service_bus_rule_id = kwargs.get('service_bus_rule_id', None) - self.event_hub_authorization_rule_id = kwargs.get('event_hub_authorization_rule_id', None) - self.event_hub_name = kwargs.get('event_hub_name', None) - self.logs = kwargs.get('logs', None) - self.workspace_id = kwargs.get('workspace_id', None) - self.marketplace_partner_id = kwargs.get('marketplace_partner_id', None) - - -class SubscriptionDiagnosticSettingsResourceCollection(msrest.serialization.Model): - """Represents a collection of subscription diagnostic settings resources. - - :param value: The collection of subscription diagnostic settings resources. - :type value: - list[~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SubscriptionDiagnosticSettingsResource]'}, - } - - def __init__( - self, - **kwargs - ): - super(SubscriptionDiagnosticSettingsResourceCollection, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class SubscriptionLogSettings(msrest.serialization.Model): - """Part of Subscription diagnostic setting. Specifies the settings for a particular log. - - 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 - this setting is applied to. - :type category_group: str - :param enabled: Required. a value indicating whether this log is enabled. - :type enabled: bool - """ - - _validation = { - 'enabled': {'required': True}, - } - - _attribute_map = { - 'category': {'key': 'category', 'type': 'str'}, - 'category_group': {'key': 'categoryGroup', 'type': 'str'}, - 'enabled': {'key': 'enabled', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(SubscriptionLogSettings, self).__init__(**kwargs) - self.category = kwargs.get('category', None) - self.category_group = kwargs.get('category_group', None) - self.enabled = kwargs['enabled'] - - -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_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 - values include: "User", "Application", "ManagedIdentity", "Key". - :type 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 - """ - - _attribute_map = { - 'created_by': {'key': 'createdBy', 'type': 'str'}, - 'created_by_type': {'key': 'createdByType', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(SystemData, self).__init__(**kwargs) - self.created_by = kwargs.get('created_by', None) - self.created_by_type = kwargs.get('created_by_type', None) - self.created_at = kwargs.get('created_at', None) - self.last_modified_by = kwargs.get('last_modified_by', None) - self.last_modified_by_type = kwargs.get('last_modified_by_type', None) - self.last_modified_at = kwargs.get('last_modified_at', None) - - -class TimeWindow(msrest.serialization.Model): - """A specific date-time for the profile. - - 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 - 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. - :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 - """ - - _validation = { - 'start': {'required': True}, - 'end': {'required': True}, - } - - _attribute_map = { - 'time_zone': {'key': 'timeZone', 'type': 'str'}, - 'start': {'key': 'start', 'type': 'iso-8601'}, - 'end': {'key': 'end', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(TimeWindow, self).__init__(**kwargs) - self.time_zone = kwargs.get('time_zone', None) - self.start = kwargs['start'] - self.end = kwargs['end'] - - -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] - """ - - _attribute_map = { - 'service_uri': {'key': 'serviceUri', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - 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 f2757e2b62c8..d0019c4e672d 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 e8d9429aee04..53feb41eb5e4 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 2eb639b31c07..20f822ebc850 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,23 +5,248 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> 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: str, + autoscale_setting_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + autoscale_setting_name: str, + subscription_id: str, + **kwargs: Any +) -> 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: str, + autoscale_setting_name: str, + subscription_id: str, + **kwargs: Any +) -> 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: str, + resource_group_name: str, + autoscale_setting_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> 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 + ) class AutoscaleSettingsOperations(object): """AutoscaleSettingsOperations operations. @@ -45,19 +270,21 @@ 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 - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AutoscaleSettingResourceCollection"] + resource_group_name: str, + **kwargs: Any + ) -> 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 +292,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,28 +329,29 @@ 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 - autoscale_setting_name, # type: str - parameters, # type: "_models.AutoscaleSettingResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.AutoscaleSettingResource" + resource_group_name: str, + autoscale_setting_name: str, + parameters: "_models.AutoscaleSettingResource", + **kwargs: Any + ) -> "_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 +367,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] - # 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, 'AutoscaleSettingResource') + + 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,18 +401,20 @@ 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 - autoscale_setting_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + autoscale_setting_name: str, + **kwargs: Any + ) -> 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 +428,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,16 +452,17 @@ 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 - autoscale_setting_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AutoscaleSettingResource" + resource_group_name: str, + autoscale_setting_name: str, + **kwargs: Any + ) -> "_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 +476,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,25 +501,28 @@ 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 - autoscale_setting_name, # type: str - autoscale_setting_resource, # type: "_models.AutoscaleSettingResourcePatch" - **kwargs # type: Any - ): - # type: (...) -> "_models.AutoscaleSettingResource" + resource_group_name: str, + autoscale_setting_name: str, + autoscale_setting_resource: "_models.AutoscaleSettingResourcePatch", + **kwargs: Any + ) -> "_models.AutoscaleSettingResource": """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 +533,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,18 +563,22 @@ 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 - ): - # type: (...) -> Iterable["_models.AutoscaleSettingResourceCollection"] + **kwargs: Any + ) -> Iterable["_models.AutoscaleSettingResourceCollection"]: """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 +586,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 +621,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 d6954cacf344..ffd2e9c2338f 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,23 +5,89 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_uri: str, + name: str, + **kwargs: Any +) -> 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: str, + **kwargs: Any +) -> 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 + ) class DiagnosticSettingsCategoryOperations(object): """DiagnosticSettingsCategoryOperations operations. @@ -45,13 +111,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_uri, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DiagnosticSettingsCategoryResource" + resource_uri: str, + name: str, + **kwargs: Any + ) -> "_models.DiagnosticSettingsCategoryResource": """Gets the diagnostic settings category for the specified resource. :param resource_uri: The identifier of the resource. @@ -68,32 +134,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,21 +158,25 @@ 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 - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DiagnosticSettingsCategoryResourceCollection"] + resource_uri: str, + **kwargs: Any + ) -> Iterable["_models.DiagnosticSettingsCategoryResourceCollection"]: """Lists the diagnostic settings categories for the specified 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 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 +184,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 +219,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 ba435b4c6207..999327ae2c82 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,23 +5,165 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_uri: str, + name: str, + **kwargs: Any +) -> 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: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_uri: str, + name: str, + **kwargs: Any +) -> 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: str, + **kwargs: Any +) -> 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 + ) class DiagnosticSettingsOperations(object): """DiagnosticSettingsOperations operations. @@ -45,13 +187,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_uri, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DiagnosticSettingsResource" + resource_uri: str, + name: str, + **kwargs: Any + ) -> "_models.DiagnosticSettingsResource": """Gets the active diagnostic settings for the specified resource. :param resource_uri: The identifier of the resource. @@ -68,32 +210,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,16 +234,18 @@ 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 - name, # type: str - parameters, # type: "_models.DiagnosticSettingsResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.DiagnosticSettingsResource" + resource_uri: str, + name: str, + parameters: "_models.DiagnosticSettingsResource", + **kwargs: Any + ) -> "_models.DiagnosticSettingsResource": """Creates or updates diagnostic settings for the specified resource. :param resource_uri: The identifier of the resource. @@ -119,7 +253,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 +265,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,15 +294,17 @@ 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 - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_uri: str, + name: str, + **kwargs: Any + ) -> None: """Deletes existing diagnostic settings for the specified resource. :param resource_uri: The identifier of the resource. @@ -194,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 = { - '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,19 +344,22 @@ def delete( delete.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}'} # type: ignore + + @distributed_trace def list( self, - resource_uri, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DiagnosticSettingsResourceCollection"] + resource_uri: str, + **kwargs: Any + ) -> Iterable["_models.DiagnosticSettingsResourceCollection"]: """Gets the active diagnostic settings list for the specified 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 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 +367,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 +402,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 4c8c36923707..20ca8defd85f 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,23 +5,165 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + management_group_id: str, + name: str, + **kwargs: Any +) -> 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: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + management_group_id: str, + name: str, + **kwargs: Any +) -> 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: str, + **kwargs: Any +) -> 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 + ) class ManagementGroupDiagnosticSettingsOperations(object): """ManagementGroupDiagnosticSettingsOperations operations. @@ -45,13 +187,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - management_group_id, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ManagementGroupDiagnosticSettingsResource" + management_group_id: str, + name: str, + **kwargs: Any + ) -> "_models.ManagementGroupDiagnosticSettingsResource": """Gets the active management group diagnostic settings for the specified resource. :param management_group_id: The management group id. @@ -60,7 +202,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 +211,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,16 +235,18 @@ 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 - name, # type: str - parameters, # type: "_models.ManagementGroupDiagnosticSettingsResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.ManagementGroupDiagnosticSettingsResource" + management_group_id: str, + name: str, + parameters: "_models.ManagementGroupDiagnosticSettingsResource", + **kwargs: Any + ) -> "_models.ManagementGroupDiagnosticSettingsResource": """Creates or updates management group diagnostic settings for the specified resource. :param management_group_id: The management group id. @@ -119,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.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 +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 = { - '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,15 +296,17 @@ 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 - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + management_group_id: str, + name: str, + **kwargs: Any + ) -> None: """Deletes existing management group diagnostic settings for the specified resource. :param management_group_id: The management group id. @@ -194,32 +323,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,19 +346,22 @@ 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 - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ManagementGroupDiagnosticSettingsResourceCollection"] + management_group_id: str, + **kwargs: Any + ) -> Iterable["_models.ManagementGroupDiagnosticSettingsResourceCollection"]: """Gets the active management group diagnostic settings list for the specified management group. :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 +369,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 +404,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 423b5f59072a..67ae8f3a043c 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,22 +6,70 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime -from typing import TYPE_CHECKING +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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + subscription_id: str, + resource_group_name: str, + autoscale_setting_name: str, + *, + timespan: str, + interval: datetime.timedelta, + metric_namespace: str, + metric_name: str, + aggregation: str, + **kwargs: Any +) -> 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}/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 + ) class PredictiveMetricOperations(object): """PredictiveMetricOperations operations. @@ -45,21 +93,21 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - autoscale_setting_name, # type: str - timespan, # type: str - interval, # type: datetime.timedelta - metric_namespace, # type: str - metric_name, # type: str - aggregation, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PredictiveResponse" + resource_group_name: str, + autoscale_setting_name: str, + timespan: str, + interval: datetime.timedelta, + metric_namespace: str, + metric_name: str, + aggregation: str, + **kwargs: Any + ) -> "_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 +134,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 +164,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 dbb63fa1f3fe..d69b8767906d 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,23 +5,165 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + subscription_id: str, + name: str, + **kwargs: Any +) -> 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: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + name: str, + **kwargs: Any +) -> 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: str, + **kwargs: Any +) -> 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 + ) class SubscriptionDiagnosticSettingsOperations(object): """SubscriptionDiagnosticSettingsOperations operations. @@ -45,19 +187,20 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SubscriptionDiagnosticSettingsResource" + name: str, + **kwargs: Any + ) -> "_models.SubscriptionDiagnosticSettingsResource": """Gets the active subscription diagnostic settings for the specified resource. :param name: The name of the diagnostic setting. :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 +208,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,24 +232,28 @@ 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 - parameters, # type: "_models.SubscriptionDiagnosticSettingsResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.SubscriptionDiagnosticSettingsResource" + name: str, + parameters: "_models.SubscriptionDiagnosticSettingsResource", + **kwargs: Any + ) -> "_models.SubscriptionDiagnosticSettingsResource": """Creates or updates subscription diagnostic settings for the specified resource. :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 +261,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,14 +290,16 @@ 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 - **kwargs # type: Any - ): - # type: (...) -> None + name: str, + **kwargs: Any + ) -> None: """Deletes existing subscription diagnostic settings for the specified resource. :param name: The name of the diagnostic setting. @@ -185,32 +314,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,16 +337,19 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}'} # type: ignore + + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SubscriptionDiagnosticSettingsResourceCollection"] + **kwargs: Any + ) -> Iterable["_models.SubscriptionDiagnosticSettingsResourceCollection"]: """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 +357,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 +392,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 d82479510092..ec9090a57df0 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 f742fdfb40ed..51092e492216 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 @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class MonitorManagementClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(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 +65,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 ac502baf335c..935381fe6e10 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 68961c58818a..2c252c063fa9 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,24 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -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 . 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 import TokenCredential -class MonitorManagementClient(object): +class MonitorManagementClient: """Monitor Management Client. :ivar action_groups: ActionGroupsOperations operations @@ -32,48 +30,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 - :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] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + 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: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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 000000000000..74e48ecd07cf --- /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 000000000000..138f663c53a4 --- /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 cac9f5d10f8b..e5754a47ce68 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 96ce9b45c05b..4eba911f1c6e 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 97e0adedc21d..2ae420e15518 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 baf79082f016..d852f15ba63d 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 000000000000..74e48ecd07cf --- /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 10a31edf786f..769a807cdbc8 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/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/__init__.py index 4a0e0892d57a..01dd730f69d1 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/__init__.py @@ -6,52 +6,29 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import ActionDetail - from ._models_py3 import ActionGroupList - from ._models_py3 import ActionGroupPatchBody - from ._models_py3 import ActionGroupResource - from ._models_py3 import ArmRoleReceiver - from ._models_py3 import AutomationRunbookReceiver - from ._models_py3 import AzureAppPushReceiver - from ._models_py3 import AzureFunctionReceiver - from ._models_py3 import AzureResource - from ._models_py3 import Context - from ._models_py3 import EmailReceiver - from ._models_py3 import EnableRequest - from ._models_py3 import ErrorResponse - from ._models_py3 import EventHubReceiver - from ._models_py3 import ItsmReceiver - from ._models_py3 import LogicAppReceiver - from ._models_py3 import NotificationRequestBody - from ._models_py3 import SmsReceiver - from ._models_py3 import TestNotificationDetailsResponse - from ._models_py3 import TestNotificationResponse - from ._models_py3 import VoiceReceiver - from ._models_py3 import WebhookReceiver -except (SyntaxError, ImportError): - from ._models import ActionDetail # type: ignore - from ._models import ActionGroupList # type: ignore - from ._models import ActionGroupPatchBody # type: ignore - from ._models import ActionGroupResource # type: ignore - from ._models import ArmRoleReceiver # type: ignore - from ._models import AutomationRunbookReceiver # type: ignore - from ._models import AzureAppPushReceiver # type: ignore - from ._models import AzureFunctionReceiver # type: ignore - from ._models import AzureResource # type: ignore - from ._models import Context # type: ignore - from ._models import EmailReceiver # type: ignore - from ._models import EnableRequest # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import EventHubReceiver # type: ignore - from ._models import ItsmReceiver # type: ignore - from ._models import LogicAppReceiver # type: ignore - from ._models import NotificationRequestBody # type: ignore - from ._models import SmsReceiver # type: ignore - from ._models import TestNotificationDetailsResponse # type: ignore - from ._models import TestNotificationResponse # type: ignore - from ._models import VoiceReceiver # type: ignore - from ._models import WebhookReceiver # type: ignore +from ._models_py3 import ActionDetail +from ._models_py3 import ActionGroupList +from ._models_py3 import ActionGroupPatchBody +from ._models_py3 import ActionGroupResource +from ._models_py3 import ArmRoleReceiver +from ._models_py3 import AutomationRunbookReceiver +from ._models_py3 import AzureAppPushReceiver +from ._models_py3 import AzureFunctionReceiver +from ._models_py3 import AzureResource +from ._models_py3 import Context +from ._models_py3 import EmailReceiver +from ._models_py3 import EnableRequest +from ._models_py3 import ErrorResponse +from ._models_py3 import EventHubReceiver +from ._models_py3 import ItsmReceiver +from ._models_py3 import LogicAppReceiver +from ._models_py3 import NotificationRequestBody +from ._models_py3 import SmsReceiver +from ._models_py3 import TestNotificationDetailsResponse +from ._models_py3 import TestNotificationResponse +from ._models_py3 import VoiceReceiver +from ._models_py3 import WebhookReceiver + from ._monitor_management_client_enums import ( ReceiverStatus, 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 deleted file mode 100644 index 66ef35c49301..000000000000 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/_models.py +++ /dev/null @@ -1,961 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class 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 - """ - - _attribute_map = { - 'mechanism_type': {'key': 'MechanismType', 'type': 'str'}, - 'name': {'key': 'Name', 'type': 'str'}, - 'status': {'key': 'Status', 'type': 'str'}, - 'sub_state': {'key': 'SubState', 'type': 'str'}, - 'send_time': {'key': 'SendTime', 'type': 'str'}, - 'detail': {'key': 'Detail', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ActionDetail, self).__init__(**kwargs) - self.mechanism_type = kwargs.get('mechanism_type', None) - self.name = kwargs.get('name', None) - self.status = kwargs.get('status', None) - self.sub_state = kwargs.get('sub_state', None) - self.send_time = kwargs.get('send_time', None) - self.detail = kwargs.get('detail', None) - - -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 - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ActionGroupResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ActionGroupList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -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 - enabled, then none of its actions will be activated. - :type enabled: bool - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(ActionGroupPatchBody, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.enabled = kwargs.get('enabled', True) - - -class AzureResource(msrest.serialization.Model): - """An azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar kind: Azure resource kind. - :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] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'readonly': True}, - 'identity': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureResource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.kind = None - self.identity = None - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - - -class ActionGroupResource(AzureResource): - """An action group resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar name: Azure resource name. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :ivar kind: Azure resource kind. - :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 - 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: - list[~$(python-base-namespace).v2021_09_01.models.AzureAppPushReceiver] - :param automation_runbook_receivers: The list of AutomationRunbook receivers that are part of - this action group. - :type 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 - action group. - :type 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. - 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] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'readonly': True}, - 'identity': {'readonly': True}, - 'location': {'required': True}, - 'group_short_name': {'max_length': 12, 'min_length': 0}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'group_short_name': {'key': 'properties.groupShortName', 'type': 'str'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - 'email_receivers': {'key': 'properties.emailReceivers', 'type': '[EmailReceiver]'}, - 'sms_receivers': {'key': 'properties.smsReceivers', 'type': '[SmsReceiver]'}, - 'webhook_receivers': {'key': 'properties.webhookReceivers', 'type': '[WebhookReceiver]'}, - 'itsm_receivers': {'key': 'properties.itsmReceivers', 'type': '[ItsmReceiver]'}, - 'azure_app_push_receivers': {'key': 'properties.azureAppPushReceivers', 'type': '[AzureAppPushReceiver]'}, - 'automation_runbook_receivers': {'key': 'properties.automationRunbookReceivers', 'type': '[AutomationRunbookReceiver]'}, - 'voice_receivers': {'key': 'properties.voiceReceivers', 'type': '[VoiceReceiver]'}, - 'logic_app_receivers': {'key': 'properties.logicAppReceivers', 'type': '[LogicAppReceiver]'}, - 'azure_function_receivers': {'key': 'properties.azureFunctionReceivers', 'type': '[AzureFunctionReceiver]'}, - 'arm_role_receivers': {'key': 'properties.armRoleReceivers', 'type': '[ArmRoleReceiver]'}, - 'event_hub_receivers': {'key': 'properties.eventHubReceivers', 'type': '[EventHubReceiver]'}, - } - - def __init__( - self, - **kwargs - ): - super(ActionGroupResource, self).__init__(**kwargs) - self.group_short_name = kwargs.get('group_short_name', None) - self.enabled = kwargs.get('enabled', True) - self.email_receivers = kwargs.get('email_receivers', None) - self.sms_receivers = kwargs.get('sms_receivers', None) - self.webhook_receivers = kwargs.get('webhook_receivers', None) - self.itsm_receivers = kwargs.get('itsm_receivers', None) - self.azure_app_push_receivers = kwargs.get('azure_app_push_receivers', None) - self.automation_runbook_receivers = kwargs.get('automation_runbook_receivers', None) - self.voice_receivers = kwargs.get('voice_receivers', None) - self.logic_app_receivers = kwargs.get('logic_app_receivers', None) - self.azure_function_receivers = kwargs.get('azure_function_receivers', None) - self.arm_role_receivers = kwargs.get('arm_role_receivers', None) - self.event_hub_receivers = kwargs.get('event_hub_receivers', None) - - -class ArmRoleReceiver(msrest.serialization.Model): - """An arm role receiver. - - 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 - 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 - """ - - _validation = { - 'name': {'required': True}, - 'role_id': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'role_id': {'key': 'roleId', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(ArmRoleReceiver, self).__init__(**kwargs) - self.name = kwargs['name'] - self.role_id = kwargs['role_id'] - self.use_common_alert_schema = kwargs.get('use_common_alert_schema', False) - - -class AutomationRunbookReceiver(msrest.serialization.Model): - """The Azure Automation Runbook notification receiver. - - 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 - """ - - _validation = { - 'automation_account_id': {'required': True}, - 'runbook_name': {'required': True}, - 'webhook_resource_id': {'required': True}, - 'is_global_runbook': {'required': True}, - } - - _attribute_map = { - 'automation_account_id': {'key': 'automationAccountId', 'type': 'str'}, - 'runbook_name': {'key': 'runbookName', 'type': 'str'}, - 'webhook_resource_id': {'key': 'webhookResourceId', 'type': 'str'}, - 'is_global_runbook': {'key': 'isGlobalRunbook', 'type': 'bool'}, - 'name': {'key': 'name', 'type': 'str'}, - 'service_uri': {'key': 'serviceUri', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(AutomationRunbookReceiver, self).__init__(**kwargs) - self.automation_account_id = kwargs['automation_account_id'] - self.runbook_name = kwargs['runbook_name'] - self.webhook_resource_id = kwargs['webhook_resource_id'] - self.is_global_runbook = kwargs['is_global_runbook'] - self.name = kwargs.get('name', None) - self.service_uri = kwargs.get('service_uri', None) - self.use_common_alert_schema = kwargs.get('use_common_alert_schema', False) - - -class AzureAppPushReceiver(msrest.serialization.Model): - """The Azure mobile App push notification receiver. - - 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 - 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 - """ - - _validation = { - 'name': {'required': True}, - 'email_address': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'email_address': {'key': 'emailAddress', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureAppPushReceiver, self).__init__(**kwargs) - self.name = kwargs['name'] - self.email_address = kwargs['email_address'] - - -class AzureFunctionReceiver(msrest.serialization.Model): - """An azure function receiver. - - 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 - 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 - """ - - _validation = { - 'name': {'required': True}, - 'function_app_resource_id': {'required': True}, - 'function_name': {'required': True}, - 'http_trigger_url': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'function_app_resource_id': {'key': 'functionAppResourceId', 'type': 'str'}, - 'function_name': {'key': 'functionName', 'type': 'str'}, - 'http_trigger_url': {'key': 'httpTriggerUrl', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureFunctionReceiver, self).__init__(**kwargs) - self.name = kwargs['name'] - self.function_app_resource_id = kwargs['function_app_resource_id'] - self.function_name = kwargs['function_name'] - self.http_trigger_url = kwargs['http_trigger_url'] - self.use_common_alert_schema = kwargs.get('use_common_alert_schema', False) - - -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 - """ - - _attribute_map = { - 'notification_source': {'key': 'NotificationSource', 'type': 'str'}, - 'context_type': {'key': 'ContextType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Context, self).__init__(**kwargs) - self.notification_source = kwargs.get('notification_source', None) - self.context_type = kwargs.get('context_type', None) - - -class EmailReceiver(msrest.serialization.Model): - """An email receiver. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param 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 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 - """ - - _validation = { - 'name': {'required': True}, - 'email_address': {'required': True}, - 'status': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'email_address': {'key': 'emailAddress', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, - 'status': {'key': 'status', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EmailReceiver, self).__init__(**kwargs) - self.name = kwargs['name'] - self.email_address = kwargs['email_address'] - self.use_common_alert_schema = kwargs.get('use_common_alert_schema', False) - self.status = None - - -class EnableRequest(msrest.serialization.Model): - """Describes a receiver that should be resubscribed. - - 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 - """ - - _validation = { - 'receiver_name': {'required': True}, - } - - _attribute_map = { - 'receiver_name': {'key': 'receiverName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EnableRequest, self).__init__(**kwargs) - self.receiver_name = kwargs['receiver_name'] - - -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 - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - - -class EventHubReceiver(msrest.serialization.Model): - """An Event hub receiver. - - 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 - 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 - """ - - _validation = { - 'name': {'required': True}, - 'event_hub_name_space': {'required': True}, - 'event_hub_name': {'required': True}, - 'subscription_id': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'event_hub_name_space': {'key': 'eventHubNameSpace', 'type': 'str'}, - 'event_hub_name': {'key': 'eventHubName', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EventHubReceiver, self).__init__(**kwargs) - self.name = kwargs['name'] - self.event_hub_name_space = kwargs['event_hub_name_space'] - self.event_hub_name = kwargs['event_hub_name'] - self.use_common_alert_schema = kwargs.get('use_common_alert_schema', False) - self.tenant_id = kwargs.get('tenant_id', None) - self.subscription_id = kwargs['subscription_id'] - - -class ItsmReceiver(msrest.serialization.Model): - """An Itsm receiver. - - 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 - 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 - in above workspace. - :type connection_id: str - :param 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 - values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. - :type region: str - """ - - _validation = { - 'name': {'required': True}, - 'workspace_id': {'required': True}, - 'connection_id': {'required': True}, - 'ticket_configuration': {'required': True}, - 'region': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'workspace_id': {'key': 'workspaceId', 'type': 'str'}, - 'connection_id': {'key': 'connectionId', 'type': 'str'}, - 'ticket_configuration': {'key': 'ticketConfiguration', 'type': 'str'}, - 'region': {'key': 'region', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ItsmReceiver, self).__init__(**kwargs) - self.name = kwargs['name'] - self.workspace_id = kwargs['workspace_id'] - self.connection_id = kwargs['connection_id'] - self.ticket_configuration = kwargs['ticket_configuration'] - self.region = kwargs['region'] - - -class LogicAppReceiver(msrest.serialization.Model): - """A logic app receiver. - - 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 - 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 - """ - - _validation = { - 'name': {'required': True}, - 'resource_id': {'required': True}, - 'callback_url': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'callback_url': {'key': 'callbackUrl', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(LogicAppReceiver, self).__init__(**kwargs) - self.name = kwargs['name'] - self.resource_id = kwargs['resource_id'] - self.callback_url = kwargs['callback_url'] - self.use_common_alert_schema = kwargs.get('use_common_alert_schema', False) - - -class NotificationRequestBody(msrest.serialization.Model): - """The request body which contain contact detail metadata. - - 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: - list[~$(python-base-namespace).v2021_09_01.models.AzureAppPushReceiver] - :param automation_runbook_receivers: The list of AutomationRunbook receivers that are part of - this action group. - :type 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 - action group. - :type 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. - 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] - """ - - _validation = { - 'alert_type': {'required': True, 'max_length': 30, 'min_length': 0}, - } - - _attribute_map = { - 'alert_type': {'key': 'alertType', 'type': 'str'}, - 'email_receivers': {'key': 'emailReceivers', 'type': '[EmailReceiver]'}, - 'sms_receivers': {'key': 'smsReceivers', 'type': '[SmsReceiver]'}, - 'webhook_receivers': {'key': 'webhookReceivers', 'type': '[WebhookReceiver]'}, - 'itsm_receivers': {'key': 'itsmReceivers', 'type': '[ItsmReceiver]'}, - 'azure_app_push_receivers': {'key': 'azureAppPushReceivers', 'type': '[AzureAppPushReceiver]'}, - 'automation_runbook_receivers': {'key': 'automationRunbookReceivers', 'type': '[AutomationRunbookReceiver]'}, - 'voice_receivers': {'key': 'voiceReceivers', 'type': '[VoiceReceiver]'}, - 'logic_app_receivers': {'key': 'logicAppReceivers', 'type': '[LogicAppReceiver]'}, - 'azure_function_receivers': {'key': 'azureFunctionReceivers', 'type': '[AzureFunctionReceiver]'}, - 'arm_role_receivers': {'key': 'armRoleReceivers', 'type': '[ArmRoleReceiver]'}, - 'event_hub_receivers': {'key': 'eventHubReceivers', 'type': '[EventHubReceiver]'}, - } - - def __init__( - self, - **kwargs - ): - super(NotificationRequestBody, self).__init__(**kwargs) - self.alert_type = kwargs['alert_type'] - self.email_receivers = kwargs.get('email_receivers', None) - self.sms_receivers = kwargs.get('sms_receivers', None) - self.webhook_receivers = kwargs.get('webhook_receivers', None) - self.itsm_receivers = kwargs.get('itsm_receivers', None) - self.azure_app_push_receivers = kwargs.get('azure_app_push_receivers', None) - self.automation_runbook_receivers = kwargs.get('automation_runbook_receivers', None) - self.voice_receivers = kwargs.get('voice_receivers', None) - self.logic_app_receivers = kwargs.get('logic_app_receivers', None) - self.azure_function_receivers = kwargs.get('azure_function_receivers', None) - self.arm_role_receivers = kwargs.get('arm_role_receivers', None) - self.event_hub_receivers = kwargs.get('event_hub_receivers', None) - - -class SmsReceiver(msrest.serialization.Model): - """An SMS receiver. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param 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 - :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 - """ - - _validation = { - 'name': {'required': True}, - 'country_code': {'required': True}, - 'phone_number': {'required': True}, - 'status': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'country_code': {'key': 'countryCode', 'type': 'str'}, - 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SmsReceiver, self).__init__(**kwargs) - self.name = kwargs['name'] - self.country_code = kwargs['country_code'] - self.phone_number = kwargs['phone_number'] - self.status = None - - -class TestNotificationDetailsResponse(msrest.serialization.Model): - """The details of the test notification results. - - 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] - """ - - _validation = { - 'state': {'required': True}, - } - - _attribute_map = { - 'context': {'key': 'Context', 'type': 'Context'}, - 'state': {'key': 'State', 'type': 'str'}, - 'completed_time': {'key': 'CompletedTime', 'type': 'str'}, - 'created_time': {'key': 'CreatedTime', 'type': 'str'}, - 'action_details': {'key': 'ActionDetails', 'type': '[ActionDetail]'}, - } - - def __init__( - self, - **kwargs - ): - super(TestNotificationDetailsResponse, self).__init__(**kwargs) - self.context = kwargs.get('context', None) - self.state = kwargs['state'] - self.completed_time = kwargs.get('completed_time', None) - self.created_time = kwargs.get('created_time', None) - self.action_details = kwargs.get('action_details', None) - - -class TestNotificationResponse(msrest.serialization.Model): - """The response when test notification succeeded. - - 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 - """ - - _validation = { - 'notification_id': {'required': True}, - 'correlation_id': {'required': True}, - 'created_time': {'required': True}, - } - - _attribute_map = { - 'notification_id': {'key': 'notificationId', 'type': 'str'}, - 'correlation_id': {'key': 'correlationId', 'type': 'str'}, - 'created_time': {'key': 'createdTime', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TestNotificationResponse, self).__init__(**kwargs) - self.notification_id = kwargs['notification_id'] - self.correlation_id = kwargs['correlation_id'] - self.created_time = kwargs['created_time'] - - -class VoiceReceiver(msrest.serialization.Model): - """A voice receiver. - - 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 - """ - - _validation = { - 'name': {'required': True}, - 'country_code': {'required': True}, - 'phone_number': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'country_code': {'key': 'countryCode', 'type': 'str'}, - 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(VoiceReceiver, self).__init__(**kwargs) - self.name = kwargs['name'] - self.country_code = kwargs['country_code'] - self.phone_number = kwargs['phone_number'] - - -class WebhookReceiver(msrest.serialization.Model): - """A webhook receiver. - - 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 - 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 - """ - - _validation = { - 'name': {'required': True}, - 'service_uri': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'service_uri': {'key': 'serviceUri', 'type': 'str'}, - 'use_common_alert_schema': {'key': 'useCommonAlertSchema', 'type': 'bool'}, - 'use_aad_auth': {'key': 'useAadAuth', 'type': 'bool'}, - 'object_id': {'key': 'objectId', 'type': 'str'}, - 'identifier_uri': {'key': 'identifierUri', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WebhookReceiver, self).__init__(**kwargs) - self.name = kwargs['name'] - self.service_uri = kwargs['service_uri'] - self.use_common_alert_schema = kwargs.get('use_common_alert_schema', False) - self.use_aad_auth = kwargs.get('use_aad_auth', False) - self.object_id = kwargs.get('object_id', None) - self.identifier_uri = kwargs.get('identifier_uri', None) - self.tenant_id = kwargs.get('tenant_id', None) 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 2f5c11e9c684..f4bb3bb6ba73 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 238df22ea2f0..5e8a759db49c 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 8c710ee5b3cc..b48ab2b71f6d 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,25 +5,367 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.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 - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_or_update_request( + resource_group_name: str, + action_group_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + action_group_name: str, + subscription_id: str, + **kwargs: Any +) -> 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: str, + action_group_name: str, + subscription_id: str, + **kwargs: Any +) -> 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: str, + resource_group_name: str, + action_group_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_post_test_notifications_request_initial( + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) + + +def build_get_test_notifications_request( + subscription_id: str, + notification_id: str, + **kwargs: Any +) -> 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: str, + **kwargs: Any +) -> 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: str, + subscription_id: str, + **kwargs: Any +) -> 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: str, + action_group_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> 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, + json=json, + content=content, + **kwargs + ) class ActionGroupsOperations(object): """ActionGroupsOperations operations. @@ -47,14 +389,14 @@ 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 - action_group_name, # type: str - action_group, # type: "_models.ActionGroupResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.ActionGroupResource" + resource_group_name: str, + action_group_name: str, + action_group: "_models.ActionGroupResource", + **kwargs: Any + ) -> "_models.ActionGroupResource": """Create a new action group or update an existing one. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -73,38 +415,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,15 +449,17 @@ 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 - action_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ActionGroupResource" + resource_group_name: str, + action_group_name: str, + **kwargs: Any + ) -> "_models.ActionGroupResource": """Get an action group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -142,33 +476,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,15 +501,17 @@ 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 - action_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + action_group_name: str, + **kwargs: Any + ) -> None: """Delete an action group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -202,33 +528,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,14 +552,15 @@ 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 - action_group_name, # type: str - action_group_patch, # type: "_models.ActionGroupPatchBody" - **kwargs # type: Any - ): - # type: (...) -> "_models.ActionGroupResource" + resource_group_name: str, + action_group_name: str, + action_group_patch: "_models.ActionGroupPatchBody", + **kwargs: Any + ) -> "_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. The name is case insensitive. @@ -262,38 +579,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] + + _json = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') - # 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, + 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,50 +609,40 @@ 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" - **kwargs # type: Any - ): - # type: (...) -> "_models.TestNotificationResponse" + notification_request: "_models.NotificationRequestBody", + **kwargs: Any + ) -> "_models.TestNotificationResponse": cls = kwargs.pop('cls', None) # type: ClsType["_models.TestNotificationResponse"] error_map = { 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] - # 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(notification_request, 'NotificationRequestBody') + + 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,29 +650,37 @@ 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" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.TestNotificationResponse"] + notification_request: "_models.NotificationRequestBody", + **kwargs: Any + ) -> LROPoller["_models.TestNotificationResponse"]: """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,14 +716,15 @@ 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 - **kwargs # type: Any - ): - # type: (...) -> "_models.TestNotificationDetailsResponse" + notification_id: str, + **kwargs: Any + ) -> "_models.TestNotificationDetailsResponse": """Get the test notifications by the notification id. :param notification_id: The notification id. @@ -437,32 +739,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,18 +763,21 @@ 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 - ): - # type: (...) -> Iterable["_models.ActionGroupList"] + **kwargs: Any + ) -> Iterable["_models.ActionGroupList"]: """Get a list of all action groups 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 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 +785,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,30 +820,32 @@ 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 - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ActionGroupList"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.ActionGroupList"]: """Get a list of all action groups in a 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).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 +853,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,25 +890,26 @@ 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 - action_group_name, # type: str - enable_request, # type: "_models.EnableRequest" - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + action_group_name: str, + enable_request: "_models.EnableRequest", + **kwargs: Any + ) -> None: """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. @@ -640,41 +929,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 +