diff --git a/sdk/logz/azure-mgmt-logz/_meta.json b/sdk/logz/azure-mgmt-logz/_meta.json index 4eaeea86761c7..58b5fc7820af5 100644 --- a/sdk/logz/azure-mgmt-logz/_meta.json +++ b/sdk/logz/azure-mgmt-logz/_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": "ca53ed5bcdb43c974a04234fcd27bcfad74d15fa", + "commit": "79bbe414002ca59d8becf500b658335617c09e25", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/logz/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/logz/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", "readme": "specification/logz/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/__init__.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/__init__.py index b3d287f58cb35..a9e753859392c 100644 --- a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/__init__.py +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['MicrosoftLogz'] -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/logz/azure-mgmt-logz/azure/mgmt/logz/_configuration.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/_configuration.py index d2ad1bd702b8e..39682bc61b782 100644 --- a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/_configuration.py +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(MicrosoftLogzConfiguration, 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(MicrosoftLogzConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/_metadata.json b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/_metadata.json index 227b84b4549eb..392d05d00b047 100644 --- a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/_metadata.json +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/_metadata.json @@ -5,13 +5,13 @@ "name": "MicrosoftLogz", "filename": "_microsoft_logz", "description": "MicrosoftLogz.", - "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\": [\"MicrosoftLogzConfiguration\"]}}, \"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\": [\"MicrosoftLogzConfiguration\"]}}, \"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\": [\"MicrosoftLogzConfiguration\"]}}, \"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\": [\"MicrosoftLogzConfiguration\"]}}, \"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": { "monitors": "MonitorsOperations", diff --git a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/_microsoft_logz.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/_microsoft_logz.py index 53e9748a6b5d8..6954ca887ac88 100644 --- a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/_microsoft_logz.py +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/_microsoft_logz.py @@ -6,28 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import MicrosoftLogzConfiguration +from .operations import MonitorOperations, MonitorsOperations, Operations, SingleSignOnOperations, SubAccountOperations, SubAccountTagRulesOperations, TagRulesOperations + 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 MicrosoftLogzConfiguration -from .operations import MonitorsOperations -from .operations import Operations -from .operations import TagRulesOperations -from .operations import SingleSignOnOperations -from .operations import SubAccountOperations -from .operations import SubAccountTagRulesOperations -from .operations import MonitorOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class MicrosoftLogz(object): """MicrosoftLogz. @@ -50,60 +44,62 @@ class MicrosoftLogz(object): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, credential, # type: "TokenCredential" subscription_id, # type: str - base_url=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MicrosoftLogzConfiguration(credential, subscription_id, **kwargs) + self._config = MicrosoftLogzConfiguration(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.monitors = MonitorsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.tag_rules = TagRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.single_sign_on = SingleSignOnOperations(self._client, self._config, self._serialize, self._deserialize) + self.sub_account = SubAccountOperations(self._client, self._config, self._serialize, self._deserialize) + self.sub_account_tag_rules = SubAccountTagRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.monitor = MonitorOperations(self._client, self._config, self._serialize, self._deserialize) + - self.monitors = MonitorsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.tag_rules = TagRulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.single_sign_on = SingleSignOnOperations( - self._client, self._config, self._serialize, self._deserialize) - self.sub_account = SubAccountOperations( - self._client, self._config, self._serialize, self._deserialize) - self.sub_account_tag_rules = SubAccountTagRulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.monitor = MonitorOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/_patch.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/_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/logz/azure-mgmt-logz/azure/mgmt/logz/_vendor.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/_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/logz/azure-mgmt-logz/azure/mgmt/logz/_version.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/_version.py index c47f66669f1bf..e5754a47ce68f 100644 --- a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/_version.py +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/__init__.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/__init__.py index dca956cbd29f6..8d653bcf21d1e 100644 --- a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/__init__.py +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/__init__.py @@ -8,3 +8,8 @@ from ._microsoft_logz import MicrosoftLogz __all__ = ['MicrosoftLogz'] + +# `._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/logz/azure-mgmt-logz/azure/mgmt/logz/aio/_configuration.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/_configuration.py index d8326f8e6e5a4..2abd8f40d7486 100644 --- a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/_configuration.py +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/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(MicrosoftLogzConfiguration, 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(MicrosoftLogzConfiguration, 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/logz/azure-mgmt-logz/azure/mgmt/logz/aio/_microsoft_logz.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/_microsoft_logz.py index 3ab07f0c6fb1d..250ceef323cd4 100644 --- a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/_microsoft_logz.py +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/_microsoft_logz.py @@ -6,28 +6,22 @@ # 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 MicrosoftLogzConfiguration +from .operations import MonitorOperations, MonitorsOperations, Operations, SingleSignOnOperations, SubAccountOperations, SubAccountTagRulesOperations, TagRulesOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import MicrosoftLogzConfiguration -from .operations import MonitorsOperations -from .operations import Operations -from .operations import TagRulesOperations -from .operations import SingleSignOnOperations -from .operations import SubAccountOperations -from .operations import SubAccountTagRulesOperations -from .operations import MonitorOperations -from .. import models - - -class MicrosoftLogz(object): +class MicrosoftLogz: """MicrosoftLogz. :ivar monitors: MonitorsOperations operations @@ -48,58 +42,60 @@ class MicrosoftLogz(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 - :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 = MicrosoftLogzConfiguration(credential, subscription_id, **kwargs) + self._config = MicrosoftLogzConfiguration(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.monitors = MonitorsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.tag_rules = TagRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.single_sign_on = SingleSignOnOperations(self._client, self._config, self._serialize, self._deserialize) + self.sub_account = SubAccountOperations(self._client, self._config, self._serialize, self._deserialize) + self.sub_account_tag_rules = SubAccountTagRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.monitor = MonitorOperations(self._client, self._config, self._serialize, self._deserialize) + - self.monitors = MonitorsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.tag_rules = TagRulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.single_sign_on = SingleSignOnOperations( - self._client, self._config, self._serialize, self._deserialize) - self.sub_account = SubAccountOperations( - self._client, self._config, self._serialize, self._deserialize) - self.sub_account_tag_rules = SubAccountTagRulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.monitor = MonitorOperations( - 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/logz/azure-mgmt-logz/azure/mgmt/logz/aio/_patch.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/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/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_monitor_operations.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_monitor_operations.py index 162ecce08f2f8..9909b7faa0557 100644 --- a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_monitor_operations.py +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_monitor_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._monitor_operations import build_list_vm_host_update_request, build_list_vm_hosts_request, build_vm_host_payload_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,13 +46,15 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def vm_host_payload( self, resource_group_name: str, monitor_name: str, **kwargs: Any ) -> "_models.VMExtensionPayload": - """Returns the payload that needs to be passed in the request body for installing Logz.io agent on a VM. + """Returns the payload that needs to be passed in the request body for installing Logz.io agent on + a VM. Returns the payload that needs to be passed in the request body for installing Logz.io agent on a VM. @@ -66,33 +73,23 @@ async def vm_host_payload( 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.vm_host_payload.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.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), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_vm_host_payload_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + template_url=self.vm_host_payload.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('VMExtensionPayload', pipeline_response) @@ -101,8 +98,11 @@ async def vm_host_payload( return cls(pipeline_response, deserialized, {}) return deserialized + vm_host_payload.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/vmHostPayload'} # type: ignore + + @distributed_trace def list_vm_host_update( self, resource_group_name: str, @@ -110,7 +110,8 @@ def list_vm_host_update( body: Optional["_models.VMHostUpdateRequest"] = None, **kwargs: Any ) -> AsyncIterable["_models.VMResourcesListResponse"]: - """Sending request to update the collection when Logz.io agent has been installed on a VM for a given monitor. + """Sending request to update the collection when Logz.io agent has been installed on a VM for a + given monitor. Sending request to update the collection when Logz.io agent has been installed on a VM for a given monitor. @@ -122,59 +123,57 @@ def list_vm_host_update( :param body: Request body to update the collection for agent installed in the given monitor. :type body: ~microsoft_logz.models.VMHostUpdateRequest :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either VMResourcesListResponse or the result of cls(response) + :return: An iterator like instance of either VMResourcesListResponse or the result of + cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~microsoft_logz.models.VMResourcesListResponse] :raises: ~azure.core.exceptions.HttpResponseError """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType["_models.VMResourcesListResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - content_type = "application/json" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_vm_host_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), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'VMHostUpdateRequest') + _json = self._serialize.body(body, 'VMHostUpdateRequest') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_list_vm_host_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + content_type=content_type, + json=_json, + template_url=self.list_vm_host_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'VMHostUpdateRequest') + _json = self._serialize.body(body, 'VMHostUpdateRequest') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.get(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_list_vm_host_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + content_type=content_type, + json=_json, + 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('VMResourcesListResponse', pipeline_response) + deserialized = self._deserialize("VMResourcesListResponse", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -187,17 +186,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_vm_host_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/vmHostUpdate'} # type: ignore + @distributed_trace def list_vm_hosts( self, resource_group_name: str, @@ -213,7 +214,8 @@ def list_vm_hosts( :param monitor_name: Monitor resource name. :type monitor_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either VMResourcesListResponse or the result of cls(response) + :return: An iterator like instance of either VMResourcesListResponse or the result of + cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~microsoft_logz.models.VMResourcesListResponse] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -222,36 +224,33 @@ def list_vm_hosts( 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_vm_hosts.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.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), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - } - url = self._client.format_url(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.post(url, query_parameters, header_parameters) + + request = build_list_vm_hosts_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + template_url=self.list_vm_hosts.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_vm_hosts_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_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('VMResourcesListResponse', pipeline_response) + deserialized = self._deserialize("VMResourcesListResponse", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -264,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/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_monitors_operations.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_monitors_operations.py index 56b5d482a305a..f7e6c3269ccc2 100644 --- a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_monitors_operations.py +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_monitors_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._monitors_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_list_monitored_resources_request, build_list_user_roles_request, 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 def list_monitored_resources( self, resource_group_name: str, @@ -58,8 +64,10 @@ def list_monitored_resources( :param monitor_name: Monitor resource name. :type monitor_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MonitoredResourceListResponse or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~microsoft_logz.models.MonitoredResourceListResponse] + :return: An iterator like instance of either MonitoredResourceListResponse or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~microsoft_logz.models.MonitoredResourceListResponse] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoredResourceListResponse"] @@ -67,36 +75,33 @@ def list_monitored_resources( 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_monitored_resources.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.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), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - } - url = self._client.format_url(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.post(url, query_parameters, header_parameters) + + request = build_list_monitored_resources_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + template_url=self.list_monitored_resources.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_monitored_resources_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_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('MonitoredResourceListResponse', pipeline_response) + deserialized = self._deserialize("MonitoredResourceListResponse", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -109,17 +114,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_monitored_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/listMonitoredResources'} # type: ignore + @distributed_trace def list_by_subscription( self, **kwargs: Any @@ -129,8 +136,10 @@ def list_by_subscription( List all monitors under 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 LogzMonitorResourceListResponse or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~microsoft_logz.models.LogzMonitorResourceListResponse] + :return: An iterator like instance of either LogzMonitorResourceListResponse or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~microsoft_logz.models.LogzMonitorResourceListResponse] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.LogzMonitorResourceListResponse"] @@ -138,34 +147,29 @@ def list_by_subscription( 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.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('LogzMonitorResourceListResponse', pipeline_response) + deserialized = self._deserialize("LogzMonitorResourceListResponse", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -178,17 +182,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.Logz/monitors'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -201,8 +207,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 LogzMonitorResourceListResponse or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~microsoft_logz.models.LogzMonitorResourceListResponse] + :return: An iterator like instance of either LogzMonitorResourceListResponse or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~microsoft_logz.models.LogzMonitorResourceListResponse] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.LogzMonitorResourceListResponse"] @@ -210,35 +218,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('LogzMonitorResourceListResponse', pipeline_response) + deserialized = self._deserialize("LogzMonitorResourceListResponse", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -251,17 +255,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.Logz/monitors'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -286,33 +292,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), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("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, + monitor_name=monitor_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('LogzMonitorResource', pipeline_response) @@ -321,8 +317,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}'} # type: ignore + async def _create_initial( self, resource_group_name: str, @@ -335,42 +333,31 @@ async def _create_initial( 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_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', max_length=90, min_length=1), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'LogzMonitorResource') + _json = self._serialize.body(body, 'LogzMonitorResource') 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_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + content_type=content_type, + json=_json, + template_url=self._create_initial.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) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('LogzMonitorResource', pipeline_response) @@ -382,8 +369,11 @@ async def _create_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}'} # type: ignore + + @distributed_trace_async async def begin_create( self, resource_group_name: str, @@ -403,15 +393,19 @@ async def begin_create( :type body: ~microsoft_logz.models.LogzMonitorResource :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 LogzMonitorResource or the result of cls(response) + :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 LogzMonitorResource or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~microsoft_logz.models.LogzMonitorResource] - :raises ~azure.core.exceptions.HttpResponseError: + :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.LogzMonitorResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -423,27 +417,21 @@ async def begin_create( resource_group_name=resource_group_name, monitor_name=monitor_name, body=body, + 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('LogzMonitorResource', 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', max_length=90, min_length=1), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -455,8 +443,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}'} # type: ignore + @distributed_trace_async async def update( self, resource_group_name: str, @@ -484,41 +474,31 @@ 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), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'LogzMonitorResourceUpdateParameters') + _json = self._serialize.body(body, 'LogzMonitorResourceUpdateParameters') 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, + monitor_name=monitor_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('LogzMonitorResource', pipeline_response) @@ -527,8 +507,10 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}'} # type: ignore + async def _delete_initial( self, resource_group_name: str, @@ -540,44 +522,36 @@ async def _delete_initial( 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_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', max_length=90, min_length=1), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("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_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_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 if response.status_code not in [200, 202, 204]: 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) response_headers = {} if response.status_code == 202: response_headers['location']=self._deserialize('str', response.headers.get('location')) + if cls: return cls(pipeline_response, None, response_headers) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -594,15 +568,17 @@ async def begin_delete( :type monitor_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', @@ -616,21 +592,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', max_length=90, min_length=1), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - } - 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: @@ -642,8 +611,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.Logz/monitors/{monitorName}'} # type: ignore + @distributed_trace def list_user_roles( self, resource_group_name: str, @@ -651,7 +622,8 @@ def list_user_roles( body: Optional["_models.UserRoleRequest"] = None, **kwargs: Any ) -> AsyncIterable["_models.UserRoleListResponse"]: - """List the user's roles configured on Logz.io side for the account corresponding to the monitor resource. + """List the user's roles configured on Logz.io side for the account corresponding to the monitor + resource. List the user's roles configured on Logz.io side for the account corresponding to the monitor resource. @@ -663,59 +635,57 @@ def list_user_roles( :param body: :type body: ~microsoft_logz.models.UserRoleRequest :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UserRoleListResponse or the result of cls(response) + :return: An iterator like instance of either UserRoleListResponse or the result of + cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~microsoft_logz.models.UserRoleListResponse] :raises: ~azure.core.exceptions.HttpResponseError """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType["_models.UserRoleListResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - content_type = "application/json" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_user_roles.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.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), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'UserRoleRequest') + _json = self._serialize.body(body, 'UserRoleRequest') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_list_user_roles_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + content_type=content_type, + json=_json, + template_url=self.list_user_roles.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'UserRoleRequest') + _json = self._serialize.body(body, 'UserRoleRequest') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.get(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_list_user_roles_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + content_type=content_type, + json=_json, + 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('UserRoleListResponse', pipeline_response) + deserialized = self._deserialize("UserRoleListResponse", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -728,12 +698,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/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_operations.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_operations.py index eb872047d5493..834b6826f6397 100644 --- a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_operations.py +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -59,28 +65,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - 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] + + 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('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -93,12 +98,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/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_single_sign_on_operations.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_single_sign_on_operations.py index 8e7db19a2519d..3506b90d9610c 100644 --- a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_single_sign_on_operations.py +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_single_sign_on_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._single_sign_on_operations import build_create_or_update_request_initial, build_get_request, build_list_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, resource_group_name: str, @@ -58,8 +64,10 @@ def list( :param monitor_name: Monitor resource name. :type monitor_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LogzSingleSignOnResourceListResponse or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~microsoft_logz.models.LogzSingleSignOnResourceListResponse] + :return: An iterator like instance of either LogzSingleSignOnResourceListResponse or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~microsoft_logz.models.LogzSingleSignOnResourceListResponse] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.LogzSingleSignOnResourceListResponse"] @@ -67,36 +75,33 @@ def list( 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.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.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), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - } - url = self._client.format_url(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, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + 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, + resource_group_name=resource_group_name, + monitor_name=monitor_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('LogzSingleSignOnResourceListResponse', pipeline_response) + deserialized = self._deserialize("LogzSingleSignOnResourceListResponse", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -109,12 +114,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 ) @@ -133,43 +139,32 @@ async def _create_or_update_initial( 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_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', max_length=90, min_length=1), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, 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, 'LogzSingleSignOnResource') + _json = self._serialize.body(body, 'LogzSingleSignOnResource') 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_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + configuration_name=configuration_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) + 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) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('LogzSingleSignOnResource', pipeline_response) @@ -181,8 +176,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.Logz/monitors/{monitorName}/singleSignOnConfigurations/{configurationName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -191,7 +189,8 @@ async def begin_create_or_update( body: Optional["_models.LogzSingleSignOnResource"] = None, **kwargs: Any ) -> AsyncLROPoller["_models.LogzSingleSignOnResource"]: - """Configures single-sign-on for this resource. This operation can take upto 10 minutes to complete. + """Configures single-sign-on for this resource. This operation can take upto 10 minutes to + complete. Configures single-sign-on for this resource. This operation can take upto 10 minutes to complete. @@ -206,15 +205,19 @@ async def begin_create_or_update( :type body: ~microsoft_logz.models.LogzSingleSignOnResource :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 LogzSingleSignOnResource or the result of cls(response) + :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 LogzSingleSignOnResource or the + result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~microsoft_logz.models.LogzSingleSignOnResource] - :raises ~azure.core.exceptions.HttpResponseError: + :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.LogzSingleSignOnResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -227,28 +230,21 @@ async def begin_create_or_update( monitor_name=monitor_name, configuration_name=configuration_name, body=body, + 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('LogzSingleSignOnResource', 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', max_length=90, min_length=1), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -260,8 +256,10 @@ 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.Logz/monitors/{monitorName}/singleSignOnConfigurations/{configurationName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -289,34 +287,24 @@ 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), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("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, + monitor_name=monitor_name, + configuration_name=configuration_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('LogzSingleSignOnResource', pipeline_response) @@ -325,4 +313,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/singleSignOnConfigurations/{configurationName}'} # type: ignore + diff --git a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_sub_account_operations.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_sub_account_operations.py index 94f10ba11fa82..c3d7f277d1ebc 100644 --- a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_sub_account_operations.py +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_sub_account_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._sub_account_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_monitored_resources_request, build_list_request, build_list_vm_host_update_request, build_list_vm_hosts_request, build_update_request, build_vm_host_payload_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, resource_group_name: str, @@ -58,8 +64,10 @@ def list( :param monitor_name: Monitor resource name. :type monitor_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LogzMonitorResourceListResponse or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~microsoft_logz.models.LogzMonitorResourceListResponse] + :return: An iterator like instance of either LogzMonitorResourceListResponse or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~microsoft_logz.models.LogzMonitorResourceListResponse] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.LogzMonitorResourceListResponse"] @@ -67,36 +75,33 @@ def list( 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.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.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), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - } - url = self._client.format_url(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, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + 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, + resource_group_name=resource_group_name, + monitor_name=monitor_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('LogzMonitorResourceListResponse', pipeline_response) + deserialized = self._deserialize("LogzMonitorResourceListResponse", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -109,12 +114,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 ) @@ -133,43 +139,32 @@ async def _create_initial( 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_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', max_length=90, min_length=1), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - 'subAccountName': self._serialize.url("sub_account_name", sub_account_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, 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, 'LogzMonitorResource') + _json = self._serialize.body(body, 'LogzMonitorResource') 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_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + sub_account_name=sub_account_name, + content_type=content_type, + json=_json, + template_url=self._create_initial.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) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('LogzMonitorResource', pipeline_response) @@ -181,8 +176,11 @@ async def _create_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}'} # type: ignore + + @distributed_trace_async async def begin_create( self, resource_group_name: str, @@ -191,7 +189,8 @@ async def begin_create( body: Optional["_models.LogzMonitorResource"] = None, **kwargs: Any ) -> AsyncLROPoller["_models.LogzMonitorResource"]: - """Create sub account under a given monitor resource. This create operation can take upto 10 minutes to complete. + """Create sub account under a given monitor resource. This create operation can take upto 10 + minutes to complete. Create sub account under a given monitor resource. This create operation can take upto 10 minutes to complete. @@ -206,15 +205,19 @@ async def begin_create( :type body: ~microsoft_logz.models.LogzMonitorResource :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 LogzMonitorResource or the result of cls(response) + :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 LogzMonitorResource or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~microsoft_logz.models.LogzMonitorResource] - :raises ~azure.core.exceptions.HttpResponseError: + :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.LogzMonitorResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -227,28 +230,21 @@ async def begin_create( monitor_name=monitor_name, sub_account_name=sub_account_name, body=body, + 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('LogzMonitorResource', 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', max_length=90, min_length=1), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - 'subAccountName': self._serialize.url("sub_account_name", sub_account_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -260,8 +256,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -289,34 +287,24 @@ 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), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - 'subAccountName': self._serialize.url("sub_account_name", sub_account_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("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, + monitor_name=monitor_name, + sub_account_name=sub_account_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('LogzMonitorResource', pipeline_response) @@ -325,8 +313,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}'} # type: ignore + async def _delete_initial( self, resource_group_name: str, @@ -339,45 +329,37 @@ async def _delete_initial( 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_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', max_length=90, min_length=1), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - 'subAccountName': self._serialize.url("sub_account_name", sub_account_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("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_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + sub_account_name=sub_account_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 if response.status_code not in [200, 202, 204]: 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) response_headers = {} if response.status_code == 202: response_headers['location']=self._deserialize('str', response.headers.get('location')) + if cls: return cls(pipeline_response, None, response_headers) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -397,15 +379,17 @@ async def begin_delete( :type sub_account_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', @@ -420,22 +404,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', max_length=90, min_length=1), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - 'subAccountName': self._serialize.url("sub_account_name", sub_account_name, 'str'), - } - 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: @@ -447,8 +423,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.Logz/monitors/{monitorName}/accounts/{subAccountName}'} # type: ignore + @distributed_trace_async async def update( self, resource_group_name: str, @@ -479,42 +457,32 @@ 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), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - 'subAccountName': self._serialize.url("sub_account_name", sub_account_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'LogzMonitorResourceUpdateParameters') + _json = self._serialize.body(body, 'LogzMonitorResourceUpdateParameters') 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, + monitor_name=monitor_name, + sub_account_name=sub_account_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('LogzMonitorResource', pipeline_response) @@ -523,8 +491,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}'} # type: ignore + + @distributed_trace def list_monitored_resources( self, resource_group_name: str, @@ -543,8 +514,10 @@ def list_monitored_resources( :param sub_account_name: Sub Account resource name. :type sub_account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MonitoredResourceListResponse or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~microsoft_logz.models.MonitoredResourceListResponse] + :return: An iterator like instance of either MonitoredResourceListResponse or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~microsoft_logz.models.MonitoredResourceListResponse] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoredResourceListResponse"] @@ -552,37 +525,35 @@ def list_monitored_resources( 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_monitored_resources.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.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), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - 'subAccountName': self._serialize.url("sub_account_name", sub_account_name, 'str'), - } - url = self._client.format_url(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.post(url, query_parameters, header_parameters) + + request = build_list_monitored_resources_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + sub_account_name=sub_account_name, + template_url=self.list_monitored_resources.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_monitored_resources_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + sub_account_name=sub_account_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('MonitoredResourceListResponse', pipeline_response) + deserialized = self._deserialize("MonitoredResourceListResponse", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -595,17 +566,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_monitored_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}/listMonitoredResources'} # type: ignore + @distributed_trace_async async def vm_host_payload( self, resource_group_name: str, @@ -633,34 +606,24 @@ async def vm_host_payload( 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.vm_host_payload.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.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), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - 'subAccountName': self._serialize.url("sub_account_name", sub_account_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_vm_host_payload_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + sub_account_name=sub_account_name, + template_url=self.vm_host_payload.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('VMExtensionPayload', pipeline_response) @@ -669,8 +632,11 @@ async def vm_host_payload( return cls(pipeline_response, deserialized, {}) return deserialized + vm_host_payload.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}/vmHostPayload'} # type: ignore + + @distributed_trace def list_vm_host_update( self, resource_group_name: str, @@ -679,7 +645,8 @@ def list_vm_host_update( body: Optional["_models.VMHostUpdateRequest"] = None, **kwargs: Any ) -> AsyncIterable["_models.VMResourcesListResponse"]: - """Sending request to update the collection when Logz.io agent has been installed on a VM for a given monitor. + """Sending request to update the collection when Logz.io agent has been installed on a VM for a + given monitor. Sending request to update the collection when Logz.io agent has been installed on a VM for a given monitor. @@ -693,60 +660,59 @@ def list_vm_host_update( :param body: Request body to update the collection for agent installed in the given monitor. :type body: ~microsoft_logz.models.VMHostUpdateRequest :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either VMResourcesListResponse or the result of cls(response) + :return: An iterator like instance of either VMResourcesListResponse or the result of + cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~microsoft_logz.models.VMResourcesListResponse] :raises: ~azure.core.exceptions.HttpResponseError """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType["_models.VMResourcesListResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - content_type = "application/json" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_vm_host_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), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - 'subAccountName': self._serialize.url("sub_account_name", sub_account_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'VMHostUpdateRequest') + _json = self._serialize.body(body, 'VMHostUpdateRequest') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_list_vm_host_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + sub_account_name=sub_account_name, + content_type=content_type, + json=_json, + template_url=self.list_vm_host_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'VMHostUpdateRequest') + _json = self._serialize.body(body, 'VMHostUpdateRequest') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.get(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_list_vm_host_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + sub_account_name=sub_account_name, + content_type=content_type, + json=_json, + 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('VMResourcesListResponse', pipeline_response) + deserialized = self._deserialize("VMResourcesListResponse", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -759,17 +725,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_vm_host_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}/vmHostUpdate'} # type: ignore + @distributed_trace def list_vm_hosts( self, resource_group_name: str, @@ -788,7 +756,8 @@ def list_vm_hosts( :param sub_account_name: Sub Account resource name. :type sub_account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either VMResourcesListResponse or the result of cls(response) + :return: An iterator like instance of either VMResourcesListResponse or the result of + cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~microsoft_logz.models.VMResourcesListResponse] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -797,37 +766,35 @@ def list_vm_hosts( 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_vm_hosts.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.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), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - 'subAccountName': self._serialize.url("sub_account_name", sub_account_name, 'str'), - } - url = self._client.format_url(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.post(url, query_parameters, header_parameters) + + request = build_list_vm_hosts_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + sub_account_name=sub_account_name, + template_url=self.list_vm_hosts.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_vm_hosts_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + sub_account_name=sub_account_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('VMResourcesListResponse', pipeline_response) + deserialized = self._deserialize("VMResourcesListResponse", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -840,12 +807,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/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_sub_account_tag_rules_operations.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_sub_account_tag_rules_operations.py index 62c6d307e3ee7..3c443f3ecddb2 100644 --- a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_sub_account_tag_rules_operations.py +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_sub_account_tag_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 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._sub_account_tag_rules_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 def list( self, resource_group_name: str, @@ -59,8 +65,10 @@ def list( :param sub_account_name: Sub Account resource name. :type sub_account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MonitoringTagRulesListResponse or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~microsoft_logz.models.MonitoringTagRulesListResponse] + :return: An iterator like instance of either MonitoringTagRulesListResponse or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~microsoft_logz.models.MonitoringTagRulesListResponse] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringTagRulesListResponse"] @@ -68,37 +76,35 @@ def list( 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.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.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), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - 'subAccountName': self._serialize.url("sub_account_name", sub_account_name, 'str'), - } - url = self._client.format_url(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, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + sub_account_name=sub_account_name, + 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, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + sub_account_name=sub_account_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('MonitoringTagRulesListResponse', pipeline_response) + deserialized = self._deserialize("MonitoringTagRulesListResponse", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -111,17 +117,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}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}/tagRules'} # type: ignore + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -155,43 +163,33 @@ 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), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - 'subAccountName': self._serialize.url("sub_account_name", sub_account_name, 'str'), - 'ruleSetName': self._serialize.url("rule_set_name", rule_set_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'MonitoringTagRules') + _json = self._serialize.body(body, 'MonitoringTagRules') 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_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + sub_account_name=sub_account_name, + rule_set_name=rule_set_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('MonitoringTagRules', pipeline_response) @@ -200,8 +198,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}/tagRules/{ruleSetName}'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -232,35 +233,25 @@ 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), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - 'subAccountName': self._serialize.url("sub_account_name", sub_account_name, 'str'), - 'ruleSetName': self._serialize.url("rule_set_name", rule_set_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("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, + monitor_name=monitor_name, + sub_account_name=sub_account_name, + rule_set_name=rule_set_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('MonitoringTagRules', pipeline_response) @@ -269,8 +260,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}/tagRules/{ruleSetName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -301,42 +295,34 @@ 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), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - 'subAccountName': self._serialize.url("sub_account_name", sub_account_name, 'str'), - 'ruleSetName': self._serialize.url("rule_set_name", rule_set_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("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, + monitor_name=monitor_name, + sub_account_name=sub_account_name, + rule_set_name=rule_set_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, 202, 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) response_headers = {} if response.status_code == 202: response_headers['location']=self._deserialize('str', response.headers.get('location')) + if cls: return cls(pipeline_response, None, response_headers) delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}/tagRules/{ruleSetName}'} # type: ignore + diff --git a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_tag_rules_operations.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_tag_rules_operations.py index 8b601798141f7..7d502edde83c5 100644 --- a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_tag_rules_operations.py +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/aio/operations/_tag_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 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._tag_rules_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 def list( self, resource_group_name: str, @@ -56,8 +62,10 @@ def list( :param monitor_name: Monitor resource name. :type monitor_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MonitoringTagRulesListResponse or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~microsoft_logz.models.MonitoringTagRulesListResponse] + :return: An iterator like instance of either MonitoringTagRulesListResponse or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~microsoft_logz.models.MonitoringTagRulesListResponse] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.MonitoringTagRulesListResponse"] @@ -65,36 +73,33 @@ def list( 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.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.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), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - } - url = self._client.format_url(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, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + 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, + resource_group_name=resource_group_name, + monitor_name=monitor_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('MonitoringTagRulesListResponse', pipeline_response) + deserialized = self._deserialize("MonitoringTagRulesListResponse", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -107,17 +112,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}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/tagRules'} # type: ignore + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -148,42 +155,32 @@ 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), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - 'ruleSetName': self._serialize.url("rule_set_name", rule_set_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'MonitoringTagRules') + _json = self._serialize.body(body, 'MonitoringTagRules') 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_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + rule_set_name=rule_set_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('MonitoringTagRules', pipeline_response) @@ -192,8 +189,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/tagRules/{ruleSetName}'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -221,34 +221,24 @@ 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), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - 'ruleSetName': self._serialize.url("rule_set_name", rule_set_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("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, + monitor_name=monitor_name, + rule_set_name=rule_set_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('MonitoringTagRules', pipeline_response) @@ -257,8 +247,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/tagRules/{ruleSetName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -286,41 +279,33 @@ 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), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - 'ruleSetName': self._serialize.url("rule_set_name", rule_set_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("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, + monitor_name=monitor_name, + rule_set_name=rule_set_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, 202, 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) response_headers = {} if response.status_code == 202: response_headers['location']=self._deserialize('str', response.headers.get('location')) + if cls: return cls(pipeline_response, None, response_headers) delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/tagRules/{ruleSetName}'} # type: ignore + diff --git a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/models/_microsoft_logz_enums.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/models/_microsoft_logz_enums.py index 87ebc78de4fe2..f4f42194c82f5 100644 --- a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/models/_microsoft_logz_enums.py +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/models/_microsoft_logz_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,17 +20,17 @@ class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class LiftrResourceCategories(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class LiftrResourceCategories(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): UNKNOWN = "Unknown" MONITOR_LOGS = "MonitorLogs" -class ManagedIdentityTypes(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ManagedIdentityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" -class MarketplaceSubscriptionStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class MarketplaceSubscriptionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Flag specifying the Marketplace Subscription Status of the resource. If payment is not made in time, the resource will go in Suspended state. """ @@ -53,14 +38,14 @@ class MarketplaceSubscriptionStatus(with_metaclass(_CaseInsensitiveEnumMeta, str ACTIVE = "Active" SUSPENDED = "Suspended" -class MonitoringStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class MonitoringStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Flag specifying if the resource monitoring is enabled or disabled. """ ENABLED = "Enabled" DISABLED = "Disabled" -class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Flag specifying if the resource provisioning state as tracked by ARM. """ @@ -74,7 +59,7 @@ class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): DELETED = "Deleted" NOT_SPECIFIED = "NotSpecified" -class SingleSignOnStates(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SingleSignOnStates(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Various states of the SSO resource """ @@ -83,14 +68,14 @@ class SingleSignOnStates(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): DISABLE = "Disable" EXISTING = "Existing" -class TagAction(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class TagAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Valid actions for a filtering tag. Exclusion takes priority over inclusion. """ INCLUDE = "Include" EXCLUDE = "Exclude" -class UserRole(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class UserRole(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """User roles on configured in Logz.io account. """ @@ -98,7 +83,7 @@ class UserRole(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): USER = "User" ADMIN = "Admin" -class VMHostUpdateStates(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class VMHostUpdateStates(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Various states of the updating vm extension on resource """ diff --git a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/models/_models.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/models/_models.py index 06dc00e1fc1e5..b966b0b5caa8d 100644 --- a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/models/_models.py +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/models/_models.py @@ -35,6 +35,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -77,6 +79,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetail, self).__init__(**kwargs) self.code = None self.message = None @@ -88,8 +92,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: ~microsoft_logz.models.ErrorDetail + :ivar error: The error object. + :vartype error: ~microsoft_logz.models.ErrorDetail """ _attribute_map = { @@ -100,6 +104,10 @@ def __init__( self, **kwargs ): + """ + :keyword error: The error object. + :paramtype error: ~microsoft_logz.models.ErrorDetail + """ super(ErrorResponse, self).__init__(**kwargs) self.error = kwargs.get('error', None) @@ -107,13 +115,13 @@ def __init__( class FilteringTag(msrest.serialization.Model): """The definition of a filtering tag. Filtering tags are used for capturing resources and include/exclude them from being monitored. - :param name: The name (also known as the key) of the tag. - :type name: str - :param value: The value of the tag. - :type value: str - :param action: Valid actions for a filtering tag. Exclusion takes priority over inclusion. + :ivar name: The name (also known as the key) of the tag. + :vartype name: str + :ivar value: The value of the tag. + :vartype value: str + :ivar action: Valid actions for a filtering tag. Exclusion takes priority over inclusion. Possible values include: "Include", "Exclude". - :type action: str or ~microsoft_logz.models.TagAction + :vartype action: str or ~microsoft_logz.models.TagAction """ _attribute_map = { @@ -126,6 +134,15 @@ def __init__( self, **kwargs ): + """ + :keyword name: The name (also known as the key) of the tag. + :paramtype name: str + :keyword value: The value of the tag. + :paramtype value: str + :keyword action: Valid actions for a filtering tag. Exclusion takes priority over inclusion. + Possible values include: "Include", "Exclude". + :paramtype action: str or ~microsoft_logz.models.TagAction + """ super(FilteringTag, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.value = kwargs.get('value', None) @@ -141,8 +158,8 @@ class IdentityProperties(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param type: Possible values include: "SystemAssigned", "UserAssigned". - :type type: str or ~microsoft_logz.models.ManagedIdentityTypes + :ivar type: Possible values include: "SystemAssigned", "UserAssigned". + :vartype type: str or ~microsoft_logz.models.ManagedIdentityTypes """ _validation = { @@ -160,6 +177,10 @@ def __init__( self, **kwargs ): + """ + :keyword type: Possible values include: "SystemAssigned", "UserAssigned". + :paramtype type: str or ~microsoft_logz.models.ManagedIdentityTypes + """ super(IdentityProperties, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -169,19 +190,19 @@ def __init__( class LogRules(msrest.serialization.Model): """Set of rules for sending logs for the Monitor resource. - :param send_aad_logs: Flag specifying if AAD logs should be sent for the Monitor resource. - :type send_aad_logs: bool - :param send_subscription_logs: Flag specifying if subscription logs should be sent for the + :ivar send_aad_logs: Flag specifying if AAD logs should be sent for the Monitor resource. + :vartype send_aad_logs: bool + :ivar send_subscription_logs: Flag specifying if subscription logs should be sent for the Monitor resource. - :type send_subscription_logs: bool - :param send_activity_logs: Flag specifying if activity logs from Azure resources should be sent + :vartype send_subscription_logs: bool + :ivar send_activity_logs: Flag specifying if activity logs from Azure resources should be sent for the Monitor resource. - :type send_activity_logs: bool - :param filtering_tags: List of filtering tags to be used for capturing logs. This only takes + :vartype send_activity_logs: bool + :ivar filtering_tags: List of filtering tags to be used for capturing logs. This only takes effect if SendActivityLogs flag is enabled. If empty, all resources will be captured. If only Exclude action is specified, the rules will apply to the list of all available resources. If Include actions are specified, the rules will only include resources with the associated tags. - :type filtering_tags: list[~microsoft_logz.models.FilteringTag] + :vartype filtering_tags: list[~microsoft_logz.models.FilteringTag] """ _attribute_map = { @@ -195,6 +216,21 @@ def __init__( self, **kwargs ): + """ + :keyword send_aad_logs: Flag specifying if AAD logs should be sent for the Monitor resource. + :paramtype send_aad_logs: bool + :keyword send_subscription_logs: Flag specifying if subscription logs should be sent for the + Monitor resource. + :paramtype send_subscription_logs: bool + :keyword send_activity_logs: Flag specifying if activity logs from Azure resources should be + sent for the Monitor resource. + :paramtype send_activity_logs: bool + :keyword filtering_tags: List of filtering tags to be used for capturing logs. This only takes + effect if SendActivityLogs flag is enabled. If empty, all resources will be captured. If only + Exclude action is specified, the rules will apply to the list of all available resources. If + Include actions are specified, the rules will only include resources with the associated tags. + :paramtype filtering_tags: list[~microsoft_logz.models.FilteringTag] + """ super(LogRules, self).__init__(**kwargs) self.send_aad_logs = kwargs.get('send_aad_logs', None) self.send_subscription_logs = kwargs.get('send_subscription_logs', None) @@ -217,14 +253,14 @@ class LogzMonitorResource(msrest.serialization.Model): :vartype name: str :ivar type: The type of the monitor resource. :vartype type: str - :param properties: Properties specific to the monitor resource. - :type properties: ~microsoft_logz.models.MonitorProperties - :param identity: - :type identity: ~microsoft_logz.models.IdentityProperties - :param tags: A set of tags. Dictionary of :code:``. - :type tags: dict[str, str] - :param location: Required. - :type location: str + :ivar properties: Properties specific to the monitor resource. + :vartype properties: ~microsoft_logz.models.MonitorProperties + :ivar identity: + :vartype identity: ~microsoft_logz.models.IdentityProperties + :ivar tags: A set of tags. Dictionary of :code:``. + :vartype tags: dict[str, str] + :ivar location: Required. + :vartype location: str """ _validation = { @@ -250,6 +286,16 @@ def __init__( self, **kwargs ): + """ + :keyword properties: Properties specific to the monitor resource. + :paramtype properties: ~microsoft_logz.models.MonitorProperties + :keyword identity: + :paramtype identity: ~microsoft_logz.models.IdentityProperties + :keyword tags: A set of tags. Dictionary of :code:``. + :paramtype tags: dict[str, str] + :keyword location: Required. + :paramtype location: str + """ super(LogzMonitorResource, self).__init__(**kwargs) self.id = None self.system_data = None @@ -264,10 +310,10 @@ def __init__( class LogzMonitorResourceListResponse(msrest.serialization.Model): """Response of a list operation. - :param value: Results of a list operation. - :type value: list[~microsoft_logz.models.LogzMonitorResource] - :param next_link: Link to the next set of results, if any. - :type next_link: str + :ivar value: Results of a list operation. + :vartype value: list[~microsoft_logz.models.LogzMonitorResource] + :ivar next_link: Link to the next set of results, if any. + :vartype next_link: str """ _attribute_map = { @@ -279,6 +325,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: Results of a list operation. + :paramtype value: list[~microsoft_logz.models.LogzMonitorResource] + :keyword next_link: Link to the next set of results, if any. + :paramtype next_link: str + """ super(LogzMonitorResourceListResponse, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -287,11 +339,11 @@ def __init__( class LogzMonitorResourceUpdateParameters(msrest.serialization.Model): """The parameters for a PATCH request to a monitor resource. - :param properties: The set of properties that can be update in a PATCH request to a monitor + :ivar properties: The set of properties that can be update in a PATCH request to a monitor resource. - :type properties: ~microsoft_logz.models.MonitorUpdateProperties - :param tags: A set of tags. The new tags of the monitor resource. - :type tags: dict[str, str] + :vartype properties: ~microsoft_logz.models.MonitorUpdateProperties + :ivar tags: A set of tags. The new tags of the monitor resource. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -303,6 +355,13 @@ def __init__( self, **kwargs ): + """ + :keyword properties: The set of properties that can be update in a PATCH request to a monitor + resource. + :paramtype properties: ~microsoft_logz.models.MonitorUpdateProperties + :keyword tags: A set of tags. The new tags of the monitor resource. + :paramtype tags: dict[str, str] + """ super(LogzMonitorResourceUpdateParameters, self).__init__(**kwargs) self.properties = kwargs.get('properties', None) self.tags = kwargs.get('tags', None) @@ -313,14 +372,14 @@ class LogzOrganizationProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param company_name: Name of the Logz organization. - :type company_name: str + :ivar company_name: Name of the Logz organization. + :vartype company_name: str :ivar id: Id of the Logz organization. :vartype id: str - :param enterprise_app_id: The Id of the Enterprise App used for Single sign on. - :type enterprise_app_id: str - :param single_sign_on_url: The login URL specific to this Logz Organization. - :type single_sign_on_url: str + :ivar enterprise_app_id: The Id of the Enterprise App used for Single sign on. + :vartype enterprise_app_id: str + :ivar single_sign_on_url: The login URL specific to this Logz Organization. + :vartype single_sign_on_url: str """ _validation = { @@ -338,6 +397,14 @@ def __init__( self, **kwargs ): + """ + :keyword company_name: Name of the Logz organization. + :paramtype company_name: str + :keyword enterprise_app_id: The Id of the Enterprise App used for Single sign on. + :paramtype enterprise_app_id: str + :keyword single_sign_on_url: The login URL specific to this Logz Organization. + :paramtype single_sign_on_url: str + """ super(LogzOrganizationProperties, self).__init__(**kwargs) self.company_name = kwargs.get('company_name', None) self.id = None @@ -350,13 +417,13 @@ class LogzSingleSignOnProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param single_sign_on_state: Various states of the SSO resource. Possible values include: + :ivar single_sign_on_state: Various states of the SSO resource. Possible values include: "Initial", "Enable", "Disable", "Existing". - :type single_sign_on_state: str or ~microsoft_logz.models.SingleSignOnStates - :param enterprise_app_id: The Id of the Enterprise App used for Single sign-on. - :type enterprise_app_id: str - :param single_sign_on_url: The login URL specific to this Logz Organization. - :type single_sign_on_url: str + :vartype single_sign_on_state: str or ~microsoft_logz.models.SingleSignOnStates + :ivar enterprise_app_id: The Id of the Enterprise App used for Single sign-on. + :vartype enterprise_app_id: str + :ivar single_sign_on_url: The login URL specific to this Logz Organization. + :vartype single_sign_on_url: str :ivar provisioning_state: Flag specifying if the resource provisioning state as tracked by ARM. Possible values include: "Accepted", "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled", "Deleted", "NotSpecified". @@ -378,6 +445,15 @@ def __init__( self, **kwargs ): + """ + :keyword single_sign_on_state: Various states of the SSO resource. Possible values include: + "Initial", "Enable", "Disable", "Existing". + :paramtype single_sign_on_state: str or ~microsoft_logz.models.SingleSignOnStates + :keyword enterprise_app_id: The Id of the Enterprise App used for Single sign-on. + :paramtype enterprise_app_id: str + :keyword single_sign_on_url: The login URL specific to this Logz Organization. + :paramtype single_sign_on_url: str + """ super(LogzSingleSignOnProperties, self).__init__(**kwargs) self.single_sign_on_state = kwargs.get('single_sign_on_state', None) self.enterprise_app_id = kwargs.get('enterprise_app_id', None) @@ -398,8 +474,8 @@ class LogzSingleSignOnResource(msrest.serialization.Model): :vartype type: str :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~microsoft_logz.models.SystemData - :param properties: - :type properties: ~microsoft_logz.models.LogzSingleSignOnProperties + :ivar properties: + :vartype properties: ~microsoft_logz.models.LogzSingleSignOnProperties """ _validation = { @@ -421,6 +497,10 @@ def __init__( self, **kwargs ): + """ + :keyword properties: + :paramtype properties: ~microsoft_logz.models.LogzSingleSignOnProperties + """ super(LogzSingleSignOnResource, self).__init__(**kwargs) self.id = None self.name = None @@ -432,10 +512,10 @@ def __init__( class LogzSingleSignOnResourceListResponse(msrest.serialization.Model): """Response of a list operation. - :param value: Results of a list operation. - :type value: list[~microsoft_logz.models.LogzSingleSignOnResource] - :param next_link: Link to the next set of results, if any. - :type next_link: str + :ivar value: Results of a list operation. + :vartype value: list[~microsoft_logz.models.LogzSingleSignOnResource] + :ivar next_link: Link to the next set of results, if any. + :vartype next_link: str """ _attribute_map = { @@ -447,6 +527,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: Results of a list operation. + :paramtype value: list[~microsoft_logz.models.LogzSingleSignOnResource] + :keyword next_link: Link to the next set of results, if any. + :paramtype next_link: str + """ super(LogzSingleSignOnResourceListResponse, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -457,20 +543,20 @@ class MonitoredResource(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param id: The ARM id of the resource. - :type id: str - :param sending_metrics: Flag indicating if resource is sending metrics to Logz. - :type sending_metrics: bool - :param reason_for_metrics_status: Reason for why the resource is sending metrics (or why it is + :ivar id: The ARM id of the resource. + :vartype id: str + :ivar sending_metrics: Flag indicating if resource is sending metrics to Logz. + :vartype sending_metrics: bool + :ivar reason_for_metrics_status: Reason for why the resource is sending metrics (or why it is not sending). - :type reason_for_metrics_status: str - :param sending_logs: Flag indicating if resource is sending logs to Logz. - :type sending_logs: bool + :vartype reason_for_metrics_status: str + :ivar sending_logs: Flag indicating if resource is sending logs to Logz. + :vartype sending_logs: bool :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~microsoft_logz.models.SystemData - :param reason_for_logs_status: Reason for why the resource is sending logs (or why it is not + :ivar reason_for_logs_status: Reason for why the resource is sending logs (or why it is not sending). - :type reason_for_logs_status: str + :vartype reason_for_logs_status: str """ _validation = { @@ -490,6 +576,20 @@ def __init__( self, **kwargs ): + """ + :keyword id: The ARM id of the resource. + :paramtype id: str + :keyword sending_metrics: Flag indicating if resource is sending metrics to Logz. + :paramtype sending_metrics: bool + :keyword reason_for_metrics_status: Reason for why the resource is sending metrics (or why it + is not sending). + :paramtype reason_for_metrics_status: str + :keyword sending_logs: Flag indicating if resource is sending logs to Logz. + :paramtype sending_logs: bool + :keyword reason_for_logs_status: Reason for why the resource is sending logs (or why it is not + sending). + :paramtype reason_for_logs_status: str + """ super(MonitoredResource, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.sending_metrics = kwargs.get('sending_metrics', None) @@ -502,10 +602,10 @@ def __init__( class MonitoredResourceListResponse(msrest.serialization.Model): """Response of a list operation. - :param value: Results of a list operation. - :type value: list[~microsoft_logz.models.MonitoredResource] - :param next_link: Link to the next set of results, if any. - :type next_link: str + :ivar value: Results of a list operation. + :vartype value: list[~microsoft_logz.models.MonitoredResource] + :ivar next_link: Link to the next set of results, if any. + :vartype next_link: str """ _attribute_map = { @@ -517,6 +617,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: Results of a list operation. + :paramtype value: list[~microsoft_logz.models.MonitoredResource] + :keyword next_link: Link to the next set of results, if any. + :paramtype next_link: str + """ super(MonitoredResourceListResponse, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -535,8 +641,8 @@ class MonitoringTagRules(msrest.serialization.Model): :vartype type: str :ivar system_data: The system metadata relating to this resource. :vartype system_data: ~microsoft_logz.models.SystemData - :param properties: Definition of the properties for a TagRules resource. - :type properties: ~microsoft_logz.models.MonitoringTagRulesProperties + :ivar properties: Definition of the properties for a TagRules resource. + :vartype properties: ~microsoft_logz.models.MonitoringTagRulesProperties """ _validation = { @@ -558,6 +664,10 @@ def __init__( self, **kwargs ): + """ + :keyword properties: Definition of the properties for a TagRules resource. + :paramtype properties: ~microsoft_logz.models.MonitoringTagRulesProperties + """ super(MonitoringTagRules, self).__init__(**kwargs) self.name = None self.id = None @@ -569,10 +679,10 @@ def __init__( class MonitoringTagRulesListResponse(msrest.serialization.Model): """Response of a list operation. - :param value: Results of a list operation. - :type value: list[~microsoft_logz.models.MonitoringTagRules] - :param next_link: Link to the next set of results, if any. - :type next_link: str + :ivar value: Results of a list operation. + :vartype value: list[~microsoft_logz.models.MonitoringTagRules] + :ivar next_link: Link to the next set of results, if any. + :vartype next_link: str """ _attribute_map = { @@ -584,6 +694,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: Results of a list operation. + :paramtype value: list[~microsoft_logz.models.MonitoringTagRules] + :keyword next_link: Link to the next set of results, if any. + :paramtype next_link: str + """ super(MonitoringTagRulesListResponse, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -598,8 +714,8 @@ class MonitoringTagRulesProperties(msrest.serialization.Model): Possible values include: "Accepted", "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled", "Deleted", "NotSpecified". :vartype provisioning_state: str or ~microsoft_logz.models.ProvisioningState - :param log_rules: Set of rules for sending logs for the Monitor resource. - :type log_rules: ~microsoft_logz.models.LogRules + :ivar log_rules: Set of rules for sending logs for the Monitor resource. + :vartype log_rules: ~microsoft_logz.models.LogRules :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~microsoft_logz.models.SystemData """ @@ -619,6 +735,10 @@ def __init__( self, **kwargs ): + """ + :keyword log_rules: Set of rules for sending logs for the Monitor resource. + :paramtype log_rules: ~microsoft_logz.models.LogRules + """ super(MonitoringTagRulesProperties, self).__init__(**kwargs) self.provisioning_state = None self.log_rules = kwargs.get('log_rules', None) @@ -634,21 +754,21 @@ class MonitorProperties(msrest.serialization.Model): Possible values include: "Accepted", "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled", "Deleted", "NotSpecified". :vartype provisioning_state: str or ~microsoft_logz.models.ProvisioningState - :param monitoring_status: Flag specifying if the resource monitoring is enabled or disabled. + :ivar monitoring_status: Flag specifying if the resource monitoring is enabled or disabled. Possible values include: "Enabled", "Disabled". Default value: "Enabled". - :type monitoring_status: str or ~microsoft_logz.models.MonitoringStatus - :param marketplace_subscription_status: Flag specifying the Marketplace Subscription Status of + :vartype monitoring_status: str or ~microsoft_logz.models.MonitoringStatus + :ivar marketplace_subscription_status: Flag specifying the Marketplace Subscription Status of the resource. If payment is not made in time, the resource will go in Suspended state. Possible values include: "Active", "Suspended". Default value: "Active". - :type marketplace_subscription_status: str or + :vartype marketplace_subscription_status: str or ~microsoft_logz.models.MarketplaceSubscriptionStatus - :param logz_organization_properties: - :type logz_organization_properties: ~microsoft_logz.models.LogzOrganizationProperties - :param user_info: - :type user_info: ~microsoft_logz.models.UserInfo - :param plan_data: - :type plan_data: ~microsoft_logz.models.PlanData - :ivar liftr_resource_category: Possible values include: "Unknown", "MonitorLogs". + :ivar logz_organization_properties: + :vartype logz_organization_properties: ~microsoft_logz.models.LogzOrganizationProperties + :ivar user_info: + :vartype user_info: ~microsoft_logz.models.UserInfo + :ivar plan_data: + :vartype plan_data: ~microsoft_logz.models.PlanData + :ivar liftr_resource_category: Possible values include: "Unknown", "MonitorLogs". :vartype liftr_resource_category: str or ~microsoft_logz.models.LiftrResourceCategories :ivar liftr_resource_preference: The priority of the resource. :vartype liftr_resource_preference: int @@ -675,6 +795,22 @@ def __init__( self, **kwargs ): + """ + :keyword monitoring_status: Flag specifying if the resource monitoring is enabled or disabled. + Possible values include: "Enabled", "Disabled". Default value: "Enabled". + :paramtype monitoring_status: str or ~microsoft_logz.models.MonitoringStatus + :keyword marketplace_subscription_status: Flag specifying the Marketplace Subscription Status + of the resource. If payment is not made in time, the resource will go in Suspended state. + Possible values include: "Active", "Suspended". Default value: "Active". + :paramtype marketplace_subscription_status: str or + ~microsoft_logz.models.MarketplaceSubscriptionStatus + :keyword logz_organization_properties: + :paramtype logz_organization_properties: ~microsoft_logz.models.LogzOrganizationProperties + :keyword user_info: + :paramtype user_info: ~microsoft_logz.models.UserInfo + :keyword plan_data: + :paramtype plan_data: ~microsoft_logz.models.PlanData + """ super(MonitorProperties, self).__init__(**kwargs) self.provisioning_state = None self.monitoring_status = kwargs.get('monitoring_status', "Enabled") @@ -689,9 +825,9 @@ def __init__( class MonitorUpdateProperties(msrest.serialization.Model): """The set of properties that can be update in a PATCH request to a monitor resource. - :param monitoring_status: Flag specifying if the resource monitoring is enabled or disabled. + :ivar monitoring_status: Flag specifying if the resource monitoring is enabled or disabled. Possible values include: "Enabled", "Disabled". Default value: "Enabled". - :type monitoring_status: str or ~microsoft_logz.models.MonitoringStatus + :vartype monitoring_status: str or ~microsoft_logz.models.MonitoringStatus """ _attribute_map = { @@ -702,6 +838,11 @@ def __init__( self, **kwargs ): + """ + :keyword monitoring_status: Flag specifying if the resource monitoring is enabled or disabled. + Possible values include: "Enabled", "Disabled". Default value: "Enabled". + :paramtype monitoring_status: str or ~microsoft_logz.models.MonitoringStatus + """ super(MonitorUpdateProperties, self).__init__(**kwargs) self.monitoring_status = kwargs.get('monitoring_status', "Enabled") @@ -709,14 +850,14 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider, i.e., Microsoft.Logz. - :type provider: str - :param resource: Type on which the operation is performed, e.g., 'monitors'. - :type resource: str - :param operation: Operation type, e.g., read, write, delete, etc. - :type operation: str - :param description: Description of the operation, e.g., 'Write monitors'. - :type description: str + :ivar provider: Service provider, i.e., Microsoft.Logz. + :vartype provider: str + :ivar resource: Type on which the operation is performed, e.g., 'monitors'. + :vartype resource: str + :ivar operation: Operation type, e.g., read, write, delete, etc. + :vartype operation: str + :ivar description: Description of the operation, e.g., 'Write monitors'. + :vartype description: str """ _attribute_map = { @@ -730,6 +871,16 @@ def __init__( self, **kwargs ): + """ + :keyword provider: Service provider, i.e., Microsoft.Logz. + :paramtype provider: str + :keyword resource: Type on which the operation is performed, e.g., 'monitors'. + :paramtype resource: str + :keyword operation: Operation type, e.g., read, write, delete, etc. + :paramtype operation: str + :keyword description: Description of the operation, e.g., 'Write monitors'. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = kwargs.get('provider', None) self.resource = kwargs.get('resource', None) @@ -740,10 +891,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """Result of GET request to list the Microsoft.Logz operations. - :param value: List of operations supported by the Microsoft.Logz provider. - :type value: list[~microsoft_logz.models.OperationResult] - :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.Logz provider. + :vartype value: list[~microsoft_logz.models.OperationResult] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -755,6 +906,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: List of operations supported by the Microsoft.Logz provider. + :paramtype value: list[~microsoft_logz.models.OperationResult] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -763,14 +920,14 @@ def __init__( class OperationResult(msrest.serialization.Model): """A Microsoft.Logz REST API operation. - :param name: Operation name, i.e., {provider}/{resource}/{operation}. - :type name: str - :param is_data_action: Indicates whether the operation is a data action. - :type is_data_action: bool - :param display: The object that represents the operation. - :type display: ~microsoft_logz.models.OperationDisplay - :param origin: Origin of the operation. - :type origin: str + :ivar name: Operation name, i.e., {provider}/{resource}/{operation}. + :vartype name: str + :ivar is_data_action: Indicates whether the operation is a data action. + :vartype is_data_action: bool + :ivar display: The object that represents the operation. + :vartype display: ~microsoft_logz.models.OperationDisplay + :ivar origin: Origin of the operation. + :vartype origin: str """ _attribute_map = { @@ -784,6 +941,16 @@ def __init__( self, **kwargs ): + """ + :keyword name: Operation name, i.e., {provider}/{resource}/{operation}. + :paramtype name: str + :keyword is_data_action: Indicates whether the operation is a data action. + :paramtype is_data_action: bool + :keyword display: The object that represents the operation. + :paramtype display: ~microsoft_logz.models.OperationDisplay + :keyword origin: Origin of the operation. + :paramtype origin: str + """ super(OperationResult, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.is_data_action = kwargs.get('is_data_action', None) @@ -794,14 +961,14 @@ def __init__( class PlanData(msrest.serialization.Model): """PlanData. - :param usage_type: different usage type like PAYG/COMMITTED. this could be enum. - :type usage_type: str - :param billing_cycle: different billing cycles like MONTHLY/WEEKLY. this could be enum. - :type billing_cycle: str - :param plan_details: plan id as published by Logz. - :type plan_details: str - :param effective_date: date when plan was applied. - :type effective_date: ~datetime.datetime + :ivar usage_type: different usage type like PAYG/COMMITTED. this could be enum. + :vartype usage_type: str + :ivar billing_cycle: different billing cycles like MONTHLY/WEEKLY. this could be enum. + :vartype billing_cycle: str + :ivar plan_details: plan id as published by Logz. + :vartype plan_details: str + :ivar effective_date: date when plan was applied. + :vartype effective_date: ~datetime.datetime """ _validation = { @@ -821,6 +988,16 @@ def __init__( self, **kwargs ): + """ + :keyword usage_type: different usage type like PAYG/COMMITTED. this could be enum. + :paramtype usage_type: str + :keyword billing_cycle: different billing cycles like MONTHLY/WEEKLY. this could be enum. + :paramtype billing_cycle: str + :keyword plan_details: plan id as published by Logz. + :paramtype plan_details: str + :keyword effective_date: date when plan was applied. + :paramtype effective_date: ~datetime.datetime + """ super(PlanData, self).__init__(**kwargs) self.usage_type = kwargs.get('usage_type', None) self.billing_cycle = kwargs.get('billing_cycle', None) @@ -831,20 +1008,20 @@ 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 ~microsoft_logz.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 ~microsoft_logz.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 ~microsoft_logz.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 ~microsoft_logz.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { @@ -860,6 +1037,22 @@ def __init__( self, **kwargs ): + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or ~microsoft_logz.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 ~microsoft_logz.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ super(SystemData, self).__init__(**kwargs) self.created_by = kwargs.get('created_by', None) self.created_by_type = kwargs.get('created_by_type', None) @@ -872,14 +1065,14 @@ def __init__( class UserInfo(msrest.serialization.Model): """UserInfo. - :param first_name: First Name of the user. - :type first_name: str - :param last_name: Last Name of the user. - :type last_name: str - :param email_address: Email of the user used by Logz for contacting them if needed. - :type email_address: str - :param phone_number: Phone number of the user used by Logz for contacting them if needed. - :type phone_number: str + :ivar first_name: First Name of the user. + :vartype first_name: str + :ivar last_name: Last Name of the user. + :vartype last_name: str + :ivar email_address: Email of the user used by Logz for contacting them if needed. + :vartype email_address: str + :ivar phone_number: Phone number of the user used by Logz for contacting them if needed. + :vartype phone_number: str """ _validation = { @@ -900,6 +1093,16 @@ def __init__( self, **kwargs ): + """ + :keyword first_name: First Name of the user. + :paramtype first_name: str + :keyword last_name: Last Name of the user. + :paramtype last_name: str + :keyword email_address: Email of the user used by Logz for contacting them if needed. + :paramtype email_address: str + :keyword phone_number: Phone number of the user used by Logz for contacting them if needed. + :paramtype phone_number: str + """ super(UserInfo, self).__init__(**kwargs) self.first_name = kwargs.get('first_name', None) self.last_name = kwargs.get('last_name', None) @@ -910,10 +1113,10 @@ def __init__( class UserRoleListResponse(msrest.serialization.Model): """Response for list of user's role for Logz.io account. - :param value: List of user roles for Logz.io account. - :type value: list[~microsoft_logz.models.UserRoleResponse] - :param next_link: Link to the next set of results, if any. - :type next_link: str + :ivar value: List of user roles for Logz.io account. + :vartype value: list[~microsoft_logz.models.UserRoleResponse] + :ivar next_link: Link to the next set of results, if any. + :vartype next_link: str """ _attribute_map = { @@ -925,6 +1128,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: List of user roles for Logz.io account. + :paramtype value: list[~microsoft_logz.models.UserRoleResponse] + :keyword next_link: Link to the next set of results, if any. + :paramtype next_link: str + """ super(UserRoleListResponse, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -933,8 +1142,8 @@ def __init__( class UserRoleRequest(msrest.serialization.Model): """Request for checking user's role for Logz.io account. - :param email_address: Email of the user used by Logz for contacting them if needed. - :type email_address: str + :ivar email_address: Email of the user used by Logz for contacting them if needed. + :vartype email_address: str """ _validation = { @@ -949,6 +1158,10 @@ def __init__( self, **kwargs ): + """ + :keyword email_address: Email of the user used by Logz for contacting them if needed. + :paramtype email_address: str + """ super(UserRoleRequest, self).__init__(**kwargs) self.email_address = kwargs.get('email_address', None) @@ -956,9 +1169,9 @@ def __init__( class UserRoleResponse(msrest.serialization.Model): """Response for checking user's role for Logz.io account. - :param role: User roles on configured in Logz.io account. Possible values include: "None", + :ivar role: User roles on configured in Logz.io account. Possible values include: "None", "User", "Admin". - :type role: str or ~microsoft_logz.models.UserRole + :vartype role: str or ~microsoft_logz.models.UserRole """ _attribute_map = { @@ -969,6 +1182,11 @@ def __init__( self, **kwargs ): + """ + :keyword role: User roles on configured in Logz.io account. Possible values include: "None", + "User", "Admin". + :paramtype role: str or ~microsoft_logz.models.UserRole + """ super(UserRoleResponse, self).__init__(**kwargs) self.role = kwargs.get('role', None) @@ -976,10 +1194,10 @@ def __init__( class VMExtensionPayload(msrest.serialization.Model): """Response of payload to be passed while installing VM agent. - :param api_key: API Key corresponding to the resource. - :type api_key: str - :param region: Logz.io region where the resource has been created. - :type region: str + :ivar api_key: API Key corresponding to the resource. + :vartype api_key: str + :ivar region: Logz.io region where the resource has been created. + :vartype region: str """ _attribute_map = { @@ -991,6 +1209,12 @@ def __init__( self, **kwargs ): + """ + :keyword api_key: API Key corresponding to the resource. + :paramtype api_key: str + :keyword region: Logz.io region where the resource has been created. + :paramtype region: str + """ super(VMExtensionPayload, self).__init__(**kwargs) self.api_key = kwargs.get('api_key', None) self.region = kwargs.get('region', None) @@ -999,11 +1223,11 @@ def __init__( class VMHostUpdateRequest(msrest.serialization.Model): """Request of a list VM Host Update Operation. - :param vm_resource_ids: Request of a list vm host update operation. - :type vm_resource_ids: list[~microsoft_logz.models.VMResources] - :param state: Specifies the state of the operation - install/ delete. Possible values include: + :ivar vm_resource_ids: Request of a list vm host update operation. + :vartype vm_resource_ids: list[~microsoft_logz.models.VMResources] + :ivar state: Specifies the state of the operation - install/ delete. Possible values include: "Install", "Delete". - :type state: str or ~microsoft_logz.models.VMHostUpdateStates + :vartype state: str or ~microsoft_logz.models.VMHostUpdateStates """ _attribute_map = { @@ -1015,6 +1239,13 @@ def __init__( self, **kwargs ): + """ + :keyword vm_resource_ids: Request of a list vm host update operation. + :paramtype vm_resource_ids: list[~microsoft_logz.models.VMResources] + :keyword state: Specifies the state of the operation - install/ delete. Possible values + include: "Install", "Delete". + :paramtype state: str or ~microsoft_logz.models.VMHostUpdateStates + """ super(VMHostUpdateRequest, self).__init__(**kwargs) self.vm_resource_ids = kwargs.get('vm_resource_ids', None) self.state = kwargs.get('state', None) @@ -1023,10 +1254,10 @@ def __init__( class VMResources(msrest.serialization.Model): """VM Resource Ids. - :param id: Request of a list vm host update operation. - :type id: str - :param agent_version: Version of the Logz agent installed on the VM. - :type agent_version: str + :ivar id: Request of a list vm host update operation. + :vartype id: str + :ivar agent_version: Version of the Logz agent installed on the VM. + :vartype agent_version: str """ _attribute_map = { @@ -1038,6 +1269,12 @@ def __init__( self, **kwargs ): + """ + :keyword id: Request of a list vm host update operation. + :paramtype id: str + :keyword agent_version: Version of the Logz agent installed on the VM. + :paramtype agent_version: str + """ super(VMResources, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.agent_version = kwargs.get('agent_version', None) @@ -1046,10 +1283,10 @@ def __init__( class VMResourcesListResponse(msrest.serialization.Model): """Response of a list VM Host Update Operation. - :param value: Response of a list vm host update operation. - :type value: list[~microsoft_logz.models.VMResources] - :param next_link: Link to the next set of results, if any. - :type next_link: str + :ivar value: Response of a list vm host update operation. + :vartype value: list[~microsoft_logz.models.VMResources] + :ivar next_link: Link to the next set of results, if any. + :vartype next_link: str """ _attribute_map = { @@ -1061,6 +1298,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: Response of a list vm host update operation. + :paramtype value: list[~microsoft_logz.models.VMResources] + :keyword next_link: Link to the next set of results, if any. + :paramtype next_link: str + """ super(VMResourcesListResponse, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) diff --git a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/models/_models_py3.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/models/_models_py3.py index 1381e244b47ad..0aec332ce17f3 100644 --- a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/models/_models_py3.py +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/models/_models_py3.py @@ -40,6 +40,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -82,6 +84,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetail, self).__init__(**kwargs) self.code = None self.message = None @@ -93,8 +97,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: ~microsoft_logz.models.ErrorDetail + :ivar error: The error object. + :vartype error: ~microsoft_logz.models.ErrorDetail """ _attribute_map = { @@ -107,6 +111,10 @@ def __init__( error: Optional["ErrorDetail"] = None, **kwargs ): + """ + :keyword error: The error object. + :paramtype error: ~microsoft_logz.models.ErrorDetail + """ super(ErrorResponse, self).__init__(**kwargs) self.error = error @@ -114,13 +122,13 @@ def __init__( class FilteringTag(msrest.serialization.Model): """The definition of a filtering tag. Filtering tags are used for capturing resources and include/exclude them from being monitored. - :param name: The name (also known as the key) of the tag. - :type name: str - :param value: The value of the tag. - :type value: str - :param action: Valid actions for a filtering tag. Exclusion takes priority over inclusion. + :ivar name: The name (also known as the key) of the tag. + :vartype name: str + :ivar value: The value of the tag. + :vartype value: str + :ivar action: Valid actions for a filtering tag. Exclusion takes priority over inclusion. Possible values include: "Include", "Exclude". - :type action: str or ~microsoft_logz.models.TagAction + :vartype action: str or ~microsoft_logz.models.TagAction """ _attribute_map = { @@ -137,6 +145,15 @@ def __init__( action: Optional[Union[str, "TagAction"]] = None, **kwargs ): + """ + :keyword name: The name (also known as the key) of the tag. + :paramtype name: str + :keyword value: The value of the tag. + :paramtype value: str + :keyword action: Valid actions for a filtering tag. Exclusion takes priority over inclusion. + Possible values include: "Include", "Exclude". + :paramtype action: str or ~microsoft_logz.models.TagAction + """ super(FilteringTag, self).__init__(**kwargs) self.name = name self.value = value @@ -152,8 +169,8 @@ class IdentityProperties(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param type: Possible values include: "SystemAssigned", "UserAssigned". - :type type: str or ~microsoft_logz.models.ManagedIdentityTypes + :ivar type: Possible values include: "SystemAssigned", "UserAssigned". + :vartype type: str or ~microsoft_logz.models.ManagedIdentityTypes """ _validation = { @@ -173,6 +190,10 @@ def __init__( type: Optional[Union[str, "ManagedIdentityTypes"]] = None, **kwargs ): + """ + :keyword type: Possible values include: "SystemAssigned", "UserAssigned". + :paramtype type: str or ~microsoft_logz.models.ManagedIdentityTypes + """ super(IdentityProperties, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -182,19 +203,19 @@ def __init__( class LogRules(msrest.serialization.Model): """Set of rules for sending logs for the Monitor resource. - :param send_aad_logs: Flag specifying if AAD logs should be sent for the Monitor resource. - :type send_aad_logs: bool - :param send_subscription_logs: Flag specifying if subscription logs should be sent for the + :ivar send_aad_logs: Flag specifying if AAD logs should be sent for the Monitor resource. + :vartype send_aad_logs: bool + :ivar send_subscription_logs: Flag specifying if subscription logs should be sent for the Monitor resource. - :type send_subscription_logs: bool - :param send_activity_logs: Flag specifying if activity logs from Azure resources should be sent + :vartype send_subscription_logs: bool + :ivar send_activity_logs: Flag specifying if activity logs from Azure resources should be sent for the Monitor resource. - :type send_activity_logs: bool - :param filtering_tags: List of filtering tags to be used for capturing logs. This only takes + :vartype send_activity_logs: bool + :ivar filtering_tags: List of filtering tags to be used for capturing logs. This only takes effect if SendActivityLogs flag is enabled. If empty, all resources will be captured. If only Exclude action is specified, the rules will apply to the list of all available resources. If Include actions are specified, the rules will only include resources with the associated tags. - :type filtering_tags: list[~microsoft_logz.models.FilteringTag] + :vartype filtering_tags: list[~microsoft_logz.models.FilteringTag] """ _attribute_map = { @@ -213,6 +234,21 @@ def __init__( filtering_tags: Optional[List["FilteringTag"]] = None, **kwargs ): + """ + :keyword send_aad_logs: Flag specifying if AAD logs should be sent for the Monitor resource. + :paramtype send_aad_logs: bool + :keyword send_subscription_logs: Flag specifying if subscription logs should be sent for the + Monitor resource. + :paramtype send_subscription_logs: bool + :keyword send_activity_logs: Flag specifying if activity logs from Azure resources should be + sent for the Monitor resource. + :paramtype send_activity_logs: bool + :keyword filtering_tags: List of filtering tags to be used for capturing logs. This only takes + effect if SendActivityLogs flag is enabled. If empty, all resources will be captured. If only + Exclude action is specified, the rules will apply to the list of all available resources. If + Include actions are specified, the rules will only include resources with the associated tags. + :paramtype filtering_tags: list[~microsoft_logz.models.FilteringTag] + """ super(LogRules, self).__init__(**kwargs) self.send_aad_logs = send_aad_logs self.send_subscription_logs = send_subscription_logs @@ -235,14 +271,14 @@ class LogzMonitorResource(msrest.serialization.Model): :vartype name: str :ivar type: The type of the monitor resource. :vartype type: str - :param properties: Properties specific to the monitor resource. - :type properties: ~microsoft_logz.models.MonitorProperties - :param identity: - :type identity: ~microsoft_logz.models.IdentityProperties - :param tags: A set of tags. Dictionary of :code:``. - :type tags: dict[str, str] - :param location: Required. - :type location: str + :ivar properties: Properties specific to the monitor resource. + :vartype properties: ~microsoft_logz.models.MonitorProperties + :ivar identity: + :vartype identity: ~microsoft_logz.models.IdentityProperties + :ivar tags: A set of tags. Dictionary of :code:``. + :vartype tags: dict[str, str] + :ivar location: Required. + :vartype location: str """ _validation = { @@ -273,6 +309,16 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword properties: Properties specific to the monitor resource. + :paramtype properties: ~microsoft_logz.models.MonitorProperties + :keyword identity: + :paramtype identity: ~microsoft_logz.models.IdentityProperties + :keyword tags: A set of tags. Dictionary of :code:``. + :paramtype tags: dict[str, str] + :keyword location: Required. + :paramtype location: str + """ super(LogzMonitorResource, self).__init__(**kwargs) self.id = None self.system_data = None @@ -287,10 +333,10 @@ def __init__( class LogzMonitorResourceListResponse(msrest.serialization.Model): """Response of a list operation. - :param value: Results of a list operation. - :type value: list[~microsoft_logz.models.LogzMonitorResource] - :param next_link: Link to the next set of results, if any. - :type next_link: str + :ivar value: Results of a list operation. + :vartype value: list[~microsoft_logz.models.LogzMonitorResource] + :ivar next_link: Link to the next set of results, if any. + :vartype next_link: str """ _attribute_map = { @@ -305,6 +351,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Results of a list operation. + :paramtype value: list[~microsoft_logz.models.LogzMonitorResource] + :keyword next_link: Link to the next set of results, if any. + :paramtype next_link: str + """ super(LogzMonitorResourceListResponse, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -313,11 +365,11 @@ def __init__( class LogzMonitorResourceUpdateParameters(msrest.serialization.Model): """The parameters for a PATCH request to a monitor resource. - :param properties: The set of properties that can be update in a PATCH request to a monitor + :ivar properties: The set of properties that can be update in a PATCH request to a monitor resource. - :type properties: ~microsoft_logz.models.MonitorUpdateProperties - :param tags: A set of tags. The new tags of the monitor resource. - :type tags: dict[str, str] + :vartype properties: ~microsoft_logz.models.MonitorUpdateProperties + :ivar tags: A set of tags. The new tags of the monitor resource. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -332,6 +384,13 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword properties: The set of properties that can be update in a PATCH request to a monitor + resource. + :paramtype properties: ~microsoft_logz.models.MonitorUpdateProperties + :keyword tags: A set of tags. The new tags of the monitor resource. + :paramtype tags: dict[str, str] + """ super(LogzMonitorResourceUpdateParameters, self).__init__(**kwargs) self.properties = properties self.tags = tags @@ -342,14 +401,14 @@ class LogzOrganizationProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param company_name: Name of the Logz organization. - :type company_name: str + :ivar company_name: Name of the Logz organization. + :vartype company_name: str :ivar id: Id of the Logz organization. :vartype id: str - :param enterprise_app_id: The Id of the Enterprise App used for Single sign on. - :type enterprise_app_id: str - :param single_sign_on_url: The login URL specific to this Logz Organization. - :type single_sign_on_url: str + :ivar enterprise_app_id: The Id of the Enterprise App used for Single sign on. + :vartype enterprise_app_id: str + :ivar single_sign_on_url: The login URL specific to this Logz Organization. + :vartype single_sign_on_url: str """ _validation = { @@ -371,6 +430,14 @@ def __init__( single_sign_on_url: Optional[str] = None, **kwargs ): + """ + :keyword company_name: Name of the Logz organization. + :paramtype company_name: str + :keyword enterprise_app_id: The Id of the Enterprise App used for Single sign on. + :paramtype enterprise_app_id: str + :keyword single_sign_on_url: The login URL specific to this Logz Organization. + :paramtype single_sign_on_url: str + """ super(LogzOrganizationProperties, self).__init__(**kwargs) self.company_name = company_name self.id = None @@ -383,13 +450,13 @@ class LogzSingleSignOnProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param single_sign_on_state: Various states of the SSO resource. Possible values include: + :ivar single_sign_on_state: Various states of the SSO resource. Possible values include: "Initial", "Enable", "Disable", "Existing". - :type single_sign_on_state: str or ~microsoft_logz.models.SingleSignOnStates - :param enterprise_app_id: The Id of the Enterprise App used for Single sign-on. - :type enterprise_app_id: str - :param single_sign_on_url: The login URL specific to this Logz Organization. - :type single_sign_on_url: str + :vartype single_sign_on_state: str or ~microsoft_logz.models.SingleSignOnStates + :ivar enterprise_app_id: The Id of the Enterprise App used for Single sign-on. + :vartype enterprise_app_id: str + :ivar single_sign_on_url: The login URL specific to this Logz Organization. + :vartype single_sign_on_url: str :ivar provisioning_state: Flag specifying if the resource provisioning state as tracked by ARM. Possible values include: "Accepted", "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled", "Deleted", "NotSpecified". @@ -415,6 +482,15 @@ def __init__( single_sign_on_url: Optional[str] = None, **kwargs ): + """ + :keyword single_sign_on_state: Various states of the SSO resource. Possible values include: + "Initial", "Enable", "Disable", "Existing". + :paramtype single_sign_on_state: str or ~microsoft_logz.models.SingleSignOnStates + :keyword enterprise_app_id: The Id of the Enterprise App used for Single sign-on. + :paramtype enterprise_app_id: str + :keyword single_sign_on_url: The login URL specific to this Logz Organization. + :paramtype single_sign_on_url: str + """ super(LogzSingleSignOnProperties, self).__init__(**kwargs) self.single_sign_on_state = single_sign_on_state self.enterprise_app_id = enterprise_app_id @@ -435,8 +511,8 @@ class LogzSingleSignOnResource(msrest.serialization.Model): :vartype type: str :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~microsoft_logz.models.SystemData - :param properties: - :type properties: ~microsoft_logz.models.LogzSingleSignOnProperties + :ivar properties: + :vartype properties: ~microsoft_logz.models.LogzSingleSignOnProperties """ _validation = { @@ -460,6 +536,10 @@ def __init__( properties: Optional["LogzSingleSignOnProperties"] = None, **kwargs ): + """ + :keyword properties: + :paramtype properties: ~microsoft_logz.models.LogzSingleSignOnProperties + """ super(LogzSingleSignOnResource, self).__init__(**kwargs) self.id = None self.name = None @@ -471,10 +551,10 @@ def __init__( class LogzSingleSignOnResourceListResponse(msrest.serialization.Model): """Response of a list operation. - :param value: Results of a list operation. - :type value: list[~microsoft_logz.models.LogzSingleSignOnResource] - :param next_link: Link to the next set of results, if any. - :type next_link: str + :ivar value: Results of a list operation. + :vartype value: list[~microsoft_logz.models.LogzSingleSignOnResource] + :ivar next_link: Link to the next set of results, if any. + :vartype next_link: str """ _attribute_map = { @@ -489,6 +569,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Results of a list operation. + :paramtype value: list[~microsoft_logz.models.LogzSingleSignOnResource] + :keyword next_link: Link to the next set of results, if any. + :paramtype next_link: str + """ super(LogzSingleSignOnResourceListResponse, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -499,20 +585,20 @@ class MonitoredResource(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param id: The ARM id of the resource. - :type id: str - :param sending_metrics: Flag indicating if resource is sending metrics to Logz. - :type sending_metrics: bool - :param reason_for_metrics_status: Reason for why the resource is sending metrics (or why it is + :ivar id: The ARM id of the resource. + :vartype id: str + :ivar sending_metrics: Flag indicating if resource is sending metrics to Logz. + :vartype sending_metrics: bool + :ivar reason_for_metrics_status: Reason for why the resource is sending metrics (or why it is not sending). - :type reason_for_metrics_status: str - :param sending_logs: Flag indicating if resource is sending logs to Logz. - :type sending_logs: bool + :vartype reason_for_metrics_status: str + :ivar sending_logs: Flag indicating if resource is sending logs to Logz. + :vartype sending_logs: bool :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~microsoft_logz.models.SystemData - :param reason_for_logs_status: Reason for why the resource is sending logs (or why it is not + :ivar reason_for_logs_status: Reason for why the resource is sending logs (or why it is not sending). - :type reason_for_logs_status: str + :vartype reason_for_logs_status: str """ _validation = { @@ -538,6 +624,20 @@ def __init__( reason_for_logs_status: Optional[str] = None, **kwargs ): + """ + :keyword id: The ARM id of the resource. + :paramtype id: str + :keyword sending_metrics: Flag indicating if resource is sending metrics to Logz. + :paramtype sending_metrics: bool + :keyword reason_for_metrics_status: Reason for why the resource is sending metrics (or why it + is not sending). + :paramtype reason_for_metrics_status: str + :keyword sending_logs: Flag indicating if resource is sending logs to Logz. + :paramtype sending_logs: bool + :keyword reason_for_logs_status: Reason for why the resource is sending logs (or why it is not + sending). + :paramtype reason_for_logs_status: str + """ super(MonitoredResource, self).__init__(**kwargs) self.id = id self.sending_metrics = sending_metrics @@ -550,10 +650,10 @@ def __init__( class MonitoredResourceListResponse(msrest.serialization.Model): """Response of a list operation. - :param value: Results of a list operation. - :type value: list[~microsoft_logz.models.MonitoredResource] - :param next_link: Link to the next set of results, if any. - :type next_link: str + :ivar value: Results of a list operation. + :vartype value: list[~microsoft_logz.models.MonitoredResource] + :ivar next_link: Link to the next set of results, if any. + :vartype next_link: str """ _attribute_map = { @@ -568,6 +668,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Results of a list operation. + :paramtype value: list[~microsoft_logz.models.MonitoredResource] + :keyword next_link: Link to the next set of results, if any. + :paramtype next_link: str + """ super(MonitoredResourceListResponse, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -586,8 +692,8 @@ class MonitoringTagRules(msrest.serialization.Model): :vartype type: str :ivar system_data: The system metadata relating to this resource. :vartype system_data: ~microsoft_logz.models.SystemData - :param properties: Definition of the properties for a TagRules resource. - :type properties: ~microsoft_logz.models.MonitoringTagRulesProperties + :ivar properties: Definition of the properties for a TagRules resource. + :vartype properties: ~microsoft_logz.models.MonitoringTagRulesProperties """ _validation = { @@ -611,6 +717,10 @@ def __init__( properties: Optional["MonitoringTagRulesProperties"] = None, **kwargs ): + """ + :keyword properties: Definition of the properties for a TagRules resource. + :paramtype properties: ~microsoft_logz.models.MonitoringTagRulesProperties + """ super(MonitoringTagRules, self).__init__(**kwargs) self.name = None self.id = None @@ -622,10 +732,10 @@ def __init__( class MonitoringTagRulesListResponse(msrest.serialization.Model): """Response of a list operation. - :param value: Results of a list operation. - :type value: list[~microsoft_logz.models.MonitoringTagRules] - :param next_link: Link to the next set of results, if any. - :type next_link: str + :ivar value: Results of a list operation. + :vartype value: list[~microsoft_logz.models.MonitoringTagRules] + :ivar next_link: Link to the next set of results, if any. + :vartype next_link: str """ _attribute_map = { @@ -640,6 +750,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Results of a list operation. + :paramtype value: list[~microsoft_logz.models.MonitoringTagRules] + :keyword next_link: Link to the next set of results, if any. + :paramtype next_link: str + """ super(MonitoringTagRulesListResponse, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -654,8 +770,8 @@ class MonitoringTagRulesProperties(msrest.serialization.Model): Possible values include: "Accepted", "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled", "Deleted", "NotSpecified". :vartype provisioning_state: str or ~microsoft_logz.models.ProvisioningState - :param log_rules: Set of rules for sending logs for the Monitor resource. - :type log_rules: ~microsoft_logz.models.LogRules + :ivar log_rules: Set of rules for sending logs for the Monitor resource. + :vartype log_rules: ~microsoft_logz.models.LogRules :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~microsoft_logz.models.SystemData """ @@ -677,6 +793,10 @@ def __init__( log_rules: Optional["LogRules"] = None, **kwargs ): + """ + :keyword log_rules: Set of rules for sending logs for the Monitor resource. + :paramtype log_rules: ~microsoft_logz.models.LogRules + """ super(MonitoringTagRulesProperties, self).__init__(**kwargs) self.provisioning_state = None self.log_rules = log_rules @@ -692,21 +812,21 @@ class MonitorProperties(msrest.serialization.Model): Possible values include: "Accepted", "Creating", "Updating", "Deleting", "Succeeded", "Failed", "Canceled", "Deleted", "NotSpecified". :vartype provisioning_state: str or ~microsoft_logz.models.ProvisioningState - :param monitoring_status: Flag specifying if the resource monitoring is enabled or disabled. + :ivar monitoring_status: Flag specifying if the resource monitoring is enabled or disabled. Possible values include: "Enabled", "Disabled". Default value: "Enabled". - :type monitoring_status: str or ~microsoft_logz.models.MonitoringStatus - :param marketplace_subscription_status: Flag specifying the Marketplace Subscription Status of + :vartype monitoring_status: str or ~microsoft_logz.models.MonitoringStatus + :ivar marketplace_subscription_status: Flag specifying the Marketplace Subscription Status of the resource. If payment is not made in time, the resource will go in Suspended state. Possible values include: "Active", "Suspended". Default value: "Active". - :type marketplace_subscription_status: str or + :vartype marketplace_subscription_status: str or ~microsoft_logz.models.MarketplaceSubscriptionStatus - :param logz_organization_properties: - :type logz_organization_properties: ~microsoft_logz.models.LogzOrganizationProperties - :param user_info: - :type user_info: ~microsoft_logz.models.UserInfo - :param plan_data: - :type plan_data: ~microsoft_logz.models.PlanData - :ivar liftr_resource_category: Possible values include: "Unknown", "MonitorLogs". + :ivar logz_organization_properties: + :vartype logz_organization_properties: ~microsoft_logz.models.LogzOrganizationProperties + :ivar user_info: + :vartype user_info: ~microsoft_logz.models.UserInfo + :ivar plan_data: + :vartype plan_data: ~microsoft_logz.models.PlanData + :ivar liftr_resource_category: Possible values include: "Unknown", "MonitorLogs". :vartype liftr_resource_category: str or ~microsoft_logz.models.LiftrResourceCategories :ivar liftr_resource_preference: The priority of the resource. :vartype liftr_resource_preference: int @@ -739,6 +859,22 @@ def __init__( plan_data: Optional["PlanData"] = None, **kwargs ): + """ + :keyword monitoring_status: Flag specifying if the resource monitoring is enabled or disabled. + Possible values include: "Enabled", "Disabled". Default value: "Enabled". + :paramtype monitoring_status: str or ~microsoft_logz.models.MonitoringStatus + :keyword marketplace_subscription_status: Flag specifying the Marketplace Subscription Status + of the resource. If payment is not made in time, the resource will go in Suspended state. + Possible values include: "Active", "Suspended". Default value: "Active". + :paramtype marketplace_subscription_status: str or + ~microsoft_logz.models.MarketplaceSubscriptionStatus + :keyword logz_organization_properties: + :paramtype logz_organization_properties: ~microsoft_logz.models.LogzOrganizationProperties + :keyword user_info: + :paramtype user_info: ~microsoft_logz.models.UserInfo + :keyword plan_data: + :paramtype plan_data: ~microsoft_logz.models.PlanData + """ super(MonitorProperties, self).__init__(**kwargs) self.provisioning_state = None self.monitoring_status = monitoring_status @@ -753,9 +889,9 @@ def __init__( class MonitorUpdateProperties(msrest.serialization.Model): """The set of properties that can be update in a PATCH request to a monitor resource. - :param monitoring_status: Flag specifying if the resource monitoring is enabled or disabled. + :ivar monitoring_status: Flag specifying if the resource monitoring is enabled or disabled. Possible values include: "Enabled", "Disabled". Default value: "Enabled". - :type monitoring_status: str or ~microsoft_logz.models.MonitoringStatus + :vartype monitoring_status: str or ~microsoft_logz.models.MonitoringStatus """ _attribute_map = { @@ -768,6 +904,11 @@ def __init__( monitoring_status: Optional[Union[str, "MonitoringStatus"]] = "Enabled", **kwargs ): + """ + :keyword monitoring_status: Flag specifying if the resource monitoring is enabled or disabled. + Possible values include: "Enabled", "Disabled". Default value: "Enabled". + :paramtype monitoring_status: str or ~microsoft_logz.models.MonitoringStatus + """ super(MonitorUpdateProperties, self).__init__(**kwargs) self.monitoring_status = monitoring_status @@ -775,14 +916,14 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """The object that represents the operation. - :param provider: Service provider, i.e., Microsoft.Logz. - :type provider: str - :param resource: Type on which the operation is performed, e.g., 'monitors'. - :type resource: str - :param operation: Operation type, e.g., read, write, delete, etc. - :type operation: str - :param description: Description of the operation, e.g., 'Write monitors'. - :type description: str + :ivar provider: Service provider, i.e., Microsoft.Logz. + :vartype provider: str + :ivar resource: Type on which the operation is performed, e.g., 'monitors'. + :vartype resource: str + :ivar operation: Operation type, e.g., read, write, delete, etc. + :vartype operation: str + :ivar description: Description of the operation, e.g., 'Write monitors'. + :vartype description: str """ _attribute_map = { @@ -801,6 +942,16 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword provider: Service provider, i.e., Microsoft.Logz. + :paramtype provider: str + :keyword resource: Type on which the operation is performed, e.g., 'monitors'. + :paramtype resource: str + :keyword operation: Operation type, e.g., read, write, delete, etc. + :paramtype operation: str + :keyword description: Description of the operation, e.g., 'Write monitors'. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -811,10 +962,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """Result of GET request to list the Microsoft.Logz operations. - :param value: List of operations supported by the Microsoft.Logz provider. - :type value: list[~microsoft_logz.models.OperationResult] - :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.Logz provider. + :vartype value: list[~microsoft_logz.models.OperationResult] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -829,6 +980,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: List of operations supported by the Microsoft.Logz provider. + :paramtype value: list[~microsoft_logz.models.OperationResult] + :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 @@ -837,14 +994,14 @@ def __init__( class OperationResult(msrest.serialization.Model): """A Microsoft.Logz REST API operation. - :param name: Operation name, i.e., {provider}/{resource}/{operation}. - :type name: str - :param is_data_action: Indicates whether the operation is a data action. - :type is_data_action: bool - :param display: The object that represents the operation. - :type display: ~microsoft_logz.models.OperationDisplay - :param origin: Origin of the operation. - :type origin: str + :ivar name: Operation name, i.e., {provider}/{resource}/{operation}. + :vartype name: str + :ivar is_data_action: Indicates whether the operation is a data action. + :vartype is_data_action: bool + :ivar display: The object that represents the operation. + :vartype display: ~microsoft_logz.models.OperationDisplay + :ivar origin: Origin of the operation. + :vartype origin: str """ _attribute_map = { @@ -863,6 +1020,16 @@ def __init__( origin: Optional[str] = None, **kwargs ): + """ + :keyword name: Operation name, i.e., {provider}/{resource}/{operation}. + :paramtype name: str + :keyword is_data_action: Indicates whether the operation is a data action. + :paramtype is_data_action: bool + :keyword display: The object that represents the operation. + :paramtype display: ~microsoft_logz.models.OperationDisplay + :keyword origin: Origin of the operation. + :paramtype origin: str + """ super(OperationResult, self).__init__(**kwargs) self.name = name self.is_data_action = is_data_action @@ -873,14 +1040,14 @@ def __init__( class PlanData(msrest.serialization.Model): """PlanData. - :param usage_type: different usage type like PAYG/COMMITTED. this could be enum. - :type usage_type: str - :param billing_cycle: different billing cycles like MONTHLY/WEEKLY. this could be enum. - :type billing_cycle: str - :param plan_details: plan id as published by Logz. - :type plan_details: str - :param effective_date: date when plan was applied. - :type effective_date: ~datetime.datetime + :ivar usage_type: different usage type like PAYG/COMMITTED. this could be enum. + :vartype usage_type: str + :ivar billing_cycle: different billing cycles like MONTHLY/WEEKLY. this could be enum. + :vartype billing_cycle: str + :ivar plan_details: plan id as published by Logz. + :vartype plan_details: str + :ivar effective_date: date when plan was applied. + :vartype effective_date: ~datetime.datetime """ _validation = { @@ -905,6 +1072,16 @@ def __init__( effective_date: Optional[datetime.datetime] = None, **kwargs ): + """ + :keyword usage_type: different usage type like PAYG/COMMITTED. this could be enum. + :paramtype usage_type: str + :keyword billing_cycle: different billing cycles like MONTHLY/WEEKLY. this could be enum. + :paramtype billing_cycle: str + :keyword plan_details: plan id as published by Logz. + :paramtype plan_details: str + :keyword effective_date: date when plan was applied. + :paramtype effective_date: ~datetime.datetime + """ super(PlanData, self).__init__(**kwargs) self.usage_type = usage_type self.billing_cycle = billing_cycle @@ -915,20 +1092,20 @@ 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 ~microsoft_logz.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 ~microsoft_logz.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 ~microsoft_logz.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 ~microsoft_logz.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { @@ -951,6 +1128,22 @@ 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 ~microsoft_logz.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 ~microsoft_logz.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 @@ -963,14 +1156,14 @@ def __init__( class UserInfo(msrest.serialization.Model): """UserInfo. - :param first_name: First Name of the user. - :type first_name: str - :param last_name: Last Name of the user. - :type last_name: str - :param email_address: Email of the user used by Logz for contacting them if needed. - :type email_address: str - :param phone_number: Phone number of the user used by Logz for contacting them if needed. - :type phone_number: str + :ivar first_name: First Name of the user. + :vartype first_name: str + :ivar last_name: Last Name of the user. + :vartype last_name: str + :ivar email_address: Email of the user used by Logz for contacting them if needed. + :vartype email_address: str + :ivar phone_number: Phone number of the user used by Logz for contacting them if needed. + :vartype phone_number: str """ _validation = { @@ -996,6 +1189,16 @@ def __init__( phone_number: Optional[str] = None, **kwargs ): + """ + :keyword first_name: First Name of the user. + :paramtype first_name: str + :keyword last_name: Last Name of the user. + :paramtype last_name: str + :keyword email_address: Email of the user used by Logz for contacting them if needed. + :paramtype email_address: str + :keyword phone_number: Phone number of the user used by Logz for contacting them if needed. + :paramtype phone_number: str + """ super(UserInfo, self).__init__(**kwargs) self.first_name = first_name self.last_name = last_name @@ -1006,10 +1209,10 @@ def __init__( class UserRoleListResponse(msrest.serialization.Model): """Response for list of user's role for Logz.io account. - :param value: List of user roles for Logz.io account. - :type value: list[~microsoft_logz.models.UserRoleResponse] - :param next_link: Link to the next set of results, if any. - :type next_link: str + :ivar value: List of user roles for Logz.io account. + :vartype value: list[~microsoft_logz.models.UserRoleResponse] + :ivar next_link: Link to the next set of results, if any. + :vartype next_link: str """ _attribute_map = { @@ -1024,6 +1227,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: List of user roles for Logz.io account. + :paramtype value: list[~microsoft_logz.models.UserRoleResponse] + :keyword next_link: Link to the next set of results, if any. + :paramtype next_link: str + """ super(UserRoleListResponse, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1032,8 +1241,8 @@ def __init__( class UserRoleRequest(msrest.serialization.Model): """Request for checking user's role for Logz.io account. - :param email_address: Email of the user used by Logz for contacting them if needed. - :type email_address: str + :ivar email_address: Email of the user used by Logz for contacting them if needed. + :vartype email_address: str """ _validation = { @@ -1050,6 +1259,10 @@ def __init__( email_address: Optional[str] = None, **kwargs ): + """ + :keyword email_address: Email of the user used by Logz for contacting them if needed. + :paramtype email_address: str + """ super(UserRoleRequest, self).__init__(**kwargs) self.email_address = email_address @@ -1057,9 +1270,9 @@ def __init__( class UserRoleResponse(msrest.serialization.Model): """Response for checking user's role for Logz.io account. - :param role: User roles on configured in Logz.io account. Possible values include: "None", + :ivar role: User roles on configured in Logz.io account. Possible values include: "None", "User", "Admin". - :type role: str or ~microsoft_logz.models.UserRole + :vartype role: str or ~microsoft_logz.models.UserRole """ _attribute_map = { @@ -1072,6 +1285,11 @@ def __init__( role: Optional[Union[str, "UserRole"]] = None, **kwargs ): + """ + :keyword role: User roles on configured in Logz.io account. Possible values include: "None", + "User", "Admin". + :paramtype role: str or ~microsoft_logz.models.UserRole + """ super(UserRoleResponse, self).__init__(**kwargs) self.role = role @@ -1079,10 +1297,10 @@ def __init__( class VMExtensionPayload(msrest.serialization.Model): """Response of payload to be passed while installing VM agent. - :param api_key: API Key corresponding to the resource. - :type api_key: str - :param region: Logz.io region where the resource has been created. - :type region: str + :ivar api_key: API Key corresponding to the resource. + :vartype api_key: str + :ivar region: Logz.io region where the resource has been created. + :vartype region: str """ _attribute_map = { @@ -1097,6 +1315,12 @@ def __init__( region: Optional[str] = None, **kwargs ): + """ + :keyword api_key: API Key corresponding to the resource. + :paramtype api_key: str + :keyword region: Logz.io region where the resource has been created. + :paramtype region: str + """ super(VMExtensionPayload, self).__init__(**kwargs) self.api_key = api_key self.region = region @@ -1105,11 +1329,11 @@ def __init__( class VMHostUpdateRequest(msrest.serialization.Model): """Request of a list VM Host Update Operation. - :param vm_resource_ids: Request of a list vm host update operation. - :type vm_resource_ids: list[~microsoft_logz.models.VMResources] - :param state: Specifies the state of the operation - install/ delete. Possible values include: + :ivar vm_resource_ids: Request of a list vm host update operation. + :vartype vm_resource_ids: list[~microsoft_logz.models.VMResources] + :ivar state: Specifies the state of the operation - install/ delete. Possible values include: "Install", "Delete". - :type state: str or ~microsoft_logz.models.VMHostUpdateStates + :vartype state: str or ~microsoft_logz.models.VMHostUpdateStates """ _attribute_map = { @@ -1124,6 +1348,13 @@ def __init__( state: Optional[Union[str, "VMHostUpdateStates"]] = None, **kwargs ): + """ + :keyword vm_resource_ids: Request of a list vm host update operation. + :paramtype vm_resource_ids: list[~microsoft_logz.models.VMResources] + :keyword state: Specifies the state of the operation - install/ delete. Possible values + include: "Install", "Delete". + :paramtype state: str or ~microsoft_logz.models.VMHostUpdateStates + """ super(VMHostUpdateRequest, self).__init__(**kwargs) self.vm_resource_ids = vm_resource_ids self.state = state @@ -1132,10 +1363,10 @@ def __init__( class VMResources(msrest.serialization.Model): """VM Resource Ids. - :param id: Request of a list vm host update operation. - :type id: str - :param agent_version: Version of the Logz agent installed on the VM. - :type agent_version: str + :ivar id: Request of a list vm host update operation. + :vartype id: str + :ivar agent_version: Version of the Logz agent installed on the VM. + :vartype agent_version: str """ _attribute_map = { @@ -1150,6 +1381,12 @@ def __init__( agent_version: Optional[str] = None, **kwargs ): + """ + :keyword id: Request of a list vm host update operation. + :paramtype id: str + :keyword agent_version: Version of the Logz agent installed on the VM. + :paramtype agent_version: str + """ super(VMResources, self).__init__(**kwargs) self.id = id self.agent_version = agent_version @@ -1158,10 +1395,10 @@ def __init__( class VMResourcesListResponse(msrest.serialization.Model): """Response of a list VM Host Update Operation. - :param value: Response of a list vm host update operation. - :type value: list[~microsoft_logz.models.VMResources] - :param next_link: Link to the next set of results, if any. - :type next_link: str + :ivar value: Response of a list vm host update operation. + :vartype value: list[~microsoft_logz.models.VMResources] + :ivar next_link: Link to the next set of results, if any. + :vartype next_link: str """ _attribute_map = { @@ -1176,6 +1413,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Response of a list vm host update operation. + :paramtype value: list[~microsoft_logz.models.VMResources] + :keyword next_link: Link to the next set of results, if any. + :paramtype next_link: str + """ super(VMResourcesListResponse, self).__init__(**kwargs) self.value = value self.next_link = next_link diff --git a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_monitor_operations.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_monitor_operations.py index f9d54fa1884a7..bd496d13bea79 100644 --- a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_monitor_operations.py +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_monitor_operations.py @@ -5,24 +5,144 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_vm_host_payload_request( + subscription_id, # type: str + resource_group_name, # type: str + monitor_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/vmHostPayload') + 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), + "monitorName": _SERIALIZER.url("monitor_name", monitor_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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_vm_host_update_request( + subscription_id, # type: str + resource_group_name, # type: str + monitor_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/vmHostUpdate') + 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), + "monitorName": _SERIALIZER.url("monitor_name", monitor_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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_vm_hosts_request( + subscription_id, # type: str + resource_group_name, # type: str + monitor_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/listVMHosts') + 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), + "monitorName": _SERIALIZER.url("monitor_name", monitor_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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +# fmt: on class MonitorOperations(object): """MonitorOperations operations. @@ -45,6 +165,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def vm_host_payload( self, resource_group_name, # type: str @@ -52,7 +173,8 @@ def vm_host_payload( **kwargs # type: Any ): # type: (...) -> "_models.VMExtensionPayload" - """Returns the payload that needs to be passed in the request body for installing Logz.io agent on a VM. + """Returns the payload that needs to be passed in the request body for installing Logz.io agent on + a VM. Returns the payload that needs to be passed in the request body for installing Logz.io agent on a VM. @@ -71,33 +193,23 @@ def vm_host_payload( 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.vm_host_payload.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.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), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_vm_host_payload_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + template_url=self.vm_host_payload.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('VMExtensionPayload', pipeline_response) @@ -106,8 +218,11 @@ def vm_host_payload( return cls(pipeline_response, deserialized, {}) return deserialized + vm_host_payload.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/vmHostPayload'} # type: ignore + + @distributed_trace def list_vm_host_update( self, resource_group_name, # type: str @@ -116,7 +231,8 @@ def list_vm_host_update( **kwargs # type: Any ): # type: (...) -> Iterable["_models.VMResourcesListResponse"] - """Sending request to update the collection when Logz.io agent has been installed on a VM for a given monitor. + """Sending request to update the collection when Logz.io agent has been installed on a VM for a + given monitor. Sending request to update the collection when Logz.io agent has been installed on a VM for a given monitor. @@ -128,59 +244,57 @@ def list_vm_host_update( :param body: Request body to update the collection for agent installed in the given monitor. :type body: ~microsoft_logz.models.VMHostUpdateRequest :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either VMResourcesListResponse or the result of cls(response) + :return: An iterator like instance of either VMResourcesListResponse or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~microsoft_logz.models.VMResourcesListResponse] :raises: ~azure.core.exceptions.HttpResponseError """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType["_models.VMResourcesListResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - content_type = "application/json" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_vm_host_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), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'VMHostUpdateRequest') + _json = self._serialize.body(body, 'VMHostUpdateRequest') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_list_vm_host_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + content_type=content_type, + json=_json, + template_url=self.list_vm_host_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'VMHostUpdateRequest') + _json = self._serialize.body(body, 'VMHostUpdateRequest') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.get(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_list_vm_host_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + content_type=content_type, + json=_json, + 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('VMResourcesListResponse', pipeline_response) + deserialized = self._deserialize("VMResourcesListResponse", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -193,17 +307,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_vm_host_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/vmHostUpdate'} # type: ignore + @distributed_trace def list_vm_hosts( self, resource_group_name, # type: str @@ -220,7 +336,8 @@ def list_vm_hosts( :param monitor_name: Monitor resource name. :type monitor_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either VMResourcesListResponse or the result of cls(response) + :return: An iterator like instance of either VMResourcesListResponse or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~microsoft_logz.models.VMResourcesListResponse] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -229,36 +346,33 @@ def list_vm_hosts( 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_vm_hosts.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.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), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - } - url = self._client.format_url(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.post(url, query_parameters, header_parameters) + + request = build_list_vm_hosts_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + template_url=self.list_vm_hosts.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_vm_hosts_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_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('VMResourcesListResponse', pipeline_response) + deserialized = self._deserialize("VMResourcesListResponse", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -271,12 +385,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/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_monitors_operations.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_monitors_operations.py index c2d61ed0f8760..f0aea9f94ad6c 100644 --- a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_monitors_operations.py +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_monitors_operations.py @@ -5,26 +5,328 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_monitored_resources_request( + subscription_id, # type: str + resource_group_name, # type: str + monitor_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/listMonitoredResources') + 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), + "monitorName": _SERIALIZER.url("monitor_name", monitor_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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Logz/monitors') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id, # type: str + resource_group_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id, # type: str + resource_group_name, # type: str + monitor_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}') + 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), + "monitorName": _SERIALIZER.url("monitor_name", monitor_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_initial( + subscription_id, # type: str + resource_group_name, # type: str + monitor_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}') + 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), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_request( + subscription_id, # type: str + resource_group_name, # type: str + monitor_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}') + 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), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id, # type: str + resource_group_name, # type: str + monitor_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}') + 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), + "monitorName": _SERIALIZER.url("monitor_name", monitor_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_user_roles_request( + subscription_id, # type: str + resource_group_name, # type: str + monitor_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/listUserRoles') + 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), + "monitorName": _SERIALIZER.url("monitor_name", monitor_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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +# fmt: on class MonitorsOperations(object): """MonitorsOperations operations. @@ -47,6 +349,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_monitored_resources( self, resource_group_name, # type: str @@ -63,7 +366,8 @@ def list_monitored_resources( :param monitor_name: Monitor resource name. :type monitor_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MonitoredResourceListResponse or the result of cls(response) + :return: An iterator like instance of either MonitoredResourceListResponse or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~microsoft_logz.models.MonitoredResourceListResponse] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -72,36 +376,33 @@ def list_monitored_resources( 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_monitored_resources.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.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), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - } - url = self._client.format_url(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.post(url, query_parameters, header_parameters) + + request = build_list_monitored_resources_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + template_url=self.list_monitored_resources.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_monitored_resources_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_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('MonitoredResourceListResponse', pipeline_response) + deserialized = self._deserialize("MonitoredResourceListResponse", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -114,17 +415,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_monitored_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/listMonitoredResources'} # type: ignore + @distributed_trace def list_by_subscription( self, **kwargs # type: Any @@ -135,7 +438,8 @@ def list_by_subscription( List all monitors under 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 LogzMonitorResourceListResponse or the result of cls(response) + :return: An iterator like instance of either LogzMonitorResourceListResponse or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~microsoft_logz.models.LogzMonitorResourceListResponse] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -144,34 +448,29 @@ def list_by_subscription( 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.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('LogzMonitorResourceListResponse', pipeline_response) + deserialized = self._deserialize("LogzMonitorResourceListResponse", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -184,17 +483,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Logz/monitors'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -208,7 +509,8 @@ 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 LogzMonitorResourceListResponse or the result of cls(response) + :return: An iterator like instance of either LogzMonitorResourceListResponse or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~microsoft_logz.models.LogzMonitorResourceListResponse] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -217,35 +519,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('LogzMonitorResourceListResponse', pipeline_response) + deserialized = self._deserialize("LogzMonitorResourceListResponse", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -258,17 +556,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -294,33 +594,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), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("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, + monitor_name=monitor_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('LogzMonitorResource', pipeline_response) @@ -329,8 +619,10 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}'} # type: ignore + def _create_initial( self, resource_group_name, # type: str @@ -344,42 +636,31 @@ def _create_initial( 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_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', max_length=90, min_length=1), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'LogzMonitorResource') + _json = self._serialize.body(body, 'LogzMonitorResource') 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_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + content_type=content_type, + json=_json, + template_url=self._create_initial.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) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('LogzMonitorResource', pipeline_response) @@ -391,8 +672,11 @@ def _create_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}'} # type: ignore + + @distributed_trace def begin_create( self, resource_group_name, # type: str @@ -413,15 +697,19 @@ def begin_create( :type body: ~microsoft_logz.models.LogzMonitorResource :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 LogzMonitorResource or the result of cls(response) + :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 LogzMonitorResource or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~microsoft_logz.models.LogzMonitorResource] - :raises ~azure.core.exceptions.HttpResponseError: + :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.LogzMonitorResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -433,27 +721,21 @@ def begin_create( resource_group_name=resource_group_name, monitor_name=monitor_name, body=body, + 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('LogzMonitorResource', 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', max_length=90, min_length=1), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -465,8 +747,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}'} # type: ignore + @distributed_trace def update( self, resource_group_name, # type: str @@ -495,41 +779,31 @@ 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), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'LogzMonitorResourceUpdateParameters') + _json = self._serialize.body(body, 'LogzMonitorResourceUpdateParameters') 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, + monitor_name=monitor_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('LogzMonitorResource', pipeline_response) @@ -538,8 +812,10 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}'} # type: ignore + def _delete_initial( self, resource_group_name, # type: str @@ -552,44 +828,36 @@ def _delete_initial( 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_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', max_length=90, min_length=1), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("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_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_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 if response.status_code not in [200, 202, 204]: 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) response_headers = {} if response.status_code == 202: response_headers['location']=self._deserialize('str', response.headers.get('location')) + if cls: return cls(pipeline_response, None, response_headers) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}'} # type: ignore + + @distributed_trace def begin_delete( self, resource_group_name, # type: str @@ -607,15 +875,17 @@ def begin_delete( :type monitor_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', @@ -629,21 +899,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', max_length=90, min_length=1), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - } - 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: @@ -655,8 +918,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}'} # type: ignore + @distributed_trace def list_user_roles( self, resource_group_name, # type: str @@ -665,7 +930,8 @@ def list_user_roles( **kwargs # type: Any ): # type: (...) -> Iterable["_models.UserRoleListResponse"] - """List the user's roles configured on Logz.io side for the account corresponding to the monitor resource. + """List the user's roles configured on Logz.io side for the account corresponding to the monitor + resource. List the user's roles configured on Logz.io side for the account corresponding to the monitor resource. @@ -677,59 +943,57 @@ def list_user_roles( :param body: :type body: ~microsoft_logz.models.UserRoleRequest :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UserRoleListResponse or the result of cls(response) + :return: An iterator like instance of either UserRoleListResponse or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~microsoft_logz.models.UserRoleListResponse] :raises: ~azure.core.exceptions.HttpResponseError """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType["_models.UserRoleListResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - content_type = "application/json" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_user_roles.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.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), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'UserRoleRequest') + _json = self._serialize.body(body, 'UserRoleRequest') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_list_user_roles_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + content_type=content_type, + json=_json, + template_url=self.list_user_roles.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'UserRoleRequest') + _json = self._serialize.body(body, 'UserRoleRequest') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.get(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_list_user_roles_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + content_type=content_type, + json=_json, + 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('UserRoleListResponse', pipeline_response) + deserialized = self._deserialize("UserRoleListResponse", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -742,12 +1006,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/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_operations.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_operations.py index f277b281438a6..5ef2599a502cf 100644 --- a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_operations.py +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_operations.py @@ -5,24 +5,52 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Logz/operations') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + +# fmt: on class Operations(object): """Operations operations. @@ -45,6 +73,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs # type: Any @@ -64,28 +93,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - 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] + + 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('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,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/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_single_sign_on_operations.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_single_sign_on_operations.py index 844f3e7cbf3c3..05c6cb6955c48 100644 --- a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_single_sign_on_operations.py +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_single_sign_on_operations.py @@ -5,26 +5,150 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + subscription_id, # type: str + resource_group_name, # type: str + monitor_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/singleSignOnConfigurations') + 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), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + subscription_id, # type: str + resource_group_name, # type: str + monitor_name, # type: str + configuration_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/singleSignOnConfigurations/{configurationName}') + 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), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, 'str'), + "configurationName": _SERIALIZER.url("configuration_name", configuration_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id, # type: str + resource_group_name, # type: str + monitor_name, # type: str + configuration_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/singleSignOnConfigurations/{configurationName}') + 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), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, 'str'), + "configurationName": _SERIALIZER.url("configuration_name", configuration_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +# fmt: on class SingleSignOnOperations(object): """SingleSignOnOperations operations. @@ -47,6 +171,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_group_name, # type: str @@ -63,8 +188,10 @@ def list( :param monitor_name: Monitor resource name. :type monitor_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LogzSingleSignOnResourceListResponse or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~microsoft_logz.models.LogzSingleSignOnResourceListResponse] + :return: An iterator like instance of either LogzSingleSignOnResourceListResponse or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~microsoft_logz.models.LogzSingleSignOnResourceListResponse] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.LogzSingleSignOnResourceListResponse"] @@ -72,36 +199,33 @@ def list( 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.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.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), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - } - url = self._client.format_url(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, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + 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, + resource_group_name=resource_group_name, + monitor_name=monitor_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('LogzSingleSignOnResourceListResponse', pipeline_response) + deserialized = self._deserialize("LogzSingleSignOnResourceListResponse", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -114,12 +238,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 ) @@ -139,43 +264,32 @@ def _create_or_update_initial( 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_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', max_length=90, min_length=1), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, 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, 'LogzSingleSignOnResource') + _json = self._serialize.body(body, 'LogzSingleSignOnResource') 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_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + configuration_name=configuration_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) + 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) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('LogzSingleSignOnResource', pipeline_response) @@ -187,8 +301,11 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/singleSignOnConfigurations/{configurationName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, resource_group_name, # type: str @@ -198,7 +315,8 @@ def begin_create_or_update( **kwargs # type: Any ): # type: (...) -> LROPoller["_models.LogzSingleSignOnResource"] - """Configures single-sign-on for this resource. This operation can take upto 10 minutes to complete. + """Configures single-sign-on for this resource. This operation can take upto 10 minutes to + complete. Configures single-sign-on for this resource. This operation can take upto 10 minutes to complete. @@ -213,15 +331,19 @@ def begin_create_or_update( :type body: ~microsoft_logz.models.LogzSingleSignOnResource :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 LogzSingleSignOnResource or the result of cls(response) + :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 LogzSingleSignOnResource or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~microsoft_logz.models.LogzSingleSignOnResource] - :raises ~azure.core.exceptions.HttpResponseError: + :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.LogzSingleSignOnResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -234,28 +356,21 @@ def begin_create_or_update( monitor_name=monitor_name, configuration_name=configuration_name, body=body, + 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('LogzSingleSignOnResource', 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', max_length=90, min_length=1), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -267,8 +382,10 @@ 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.Logz/monitors/{monitorName}/singleSignOnConfigurations/{configurationName}'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -297,34 +414,24 @@ 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), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("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, + monitor_name=monitor_name, + configuration_name=configuration_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('LogzSingleSignOnResource', pipeline_response) @@ -333,4 +440,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/singleSignOnConfigurations/{configurationName}'} # type: ignore + diff --git a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_sub_account_operations.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_sub_account_operations.py index 9206cd135ba08..0fc2922cbf5f9 100644 --- a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_sub_account_operations.py +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_sub_account_operations.py @@ -5,26 +5,386 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + subscription_id, # type: str + resource_group_name, # type: str + monitor_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts') + 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), + "monitorName": _SERIALIZER.url("monitor_name", monitor_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_initial( + subscription_id, # type: str + resource_group_name, # type: str + monitor_name, # type: str + sub_account_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}') + 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), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, 'str'), + "subAccountName": _SERIALIZER.url("sub_account_name", sub_account_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id, # type: str + resource_group_name, # type: str + monitor_name, # type: str + sub_account_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}') + 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), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, 'str'), + "subAccountName": _SERIALIZER.url("sub_account_name", sub_account_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_initial( + subscription_id, # type: str + resource_group_name, # type: str + monitor_name, # type: str + sub_account_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}') + 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), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, 'str'), + "subAccountName": _SERIALIZER.url("sub_account_name", sub_account_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_request( + subscription_id, # type: str + resource_group_name, # type: str + monitor_name, # type: str + sub_account_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}') + 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), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, 'str'), + "subAccountName": _SERIALIZER.url("sub_account_name", sub_account_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_monitored_resources_request( + subscription_id, # type: str + resource_group_name, # type: str + monitor_name, # type: str + sub_account_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}/listMonitoredResources') + 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), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, 'str'), + "subAccountName": _SERIALIZER.url("sub_account_name", sub_account_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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_vm_host_payload_request( + subscription_id, # type: str + resource_group_name, # type: str + monitor_name, # type: str + sub_account_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}/vmHostPayload') + 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), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, 'str'), + "subAccountName": _SERIALIZER.url("sub_account_name", sub_account_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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_vm_host_update_request( + subscription_id, # type: str + resource_group_name, # type: str + monitor_name, # type: str + sub_account_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}/vmHostUpdate') + 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), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, 'str'), + "subAccountName": _SERIALIZER.url("sub_account_name", sub_account_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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_vm_hosts_request( + subscription_id, # type: str + resource_group_name, # type: str + monitor_name, # type: str + sub_account_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}/listVMHosts') + 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), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, 'str'), + "subAccountName": _SERIALIZER.url("sub_account_name", sub_account_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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +# fmt: on class SubAccountOperations(object): """SubAccountOperations operations. @@ -47,6 +407,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_group_name, # type: str @@ -63,7 +424,8 @@ def list( :param monitor_name: Monitor resource name. :type monitor_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LogzMonitorResourceListResponse or the result of cls(response) + :return: An iterator like instance of either LogzMonitorResourceListResponse or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~microsoft_logz.models.LogzMonitorResourceListResponse] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -72,36 +434,33 @@ def list( 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.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.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), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - } - url = self._client.format_url(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, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + 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, + resource_group_name=resource_group_name, + monitor_name=monitor_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('LogzMonitorResourceListResponse', pipeline_response) + deserialized = self._deserialize("LogzMonitorResourceListResponse", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -114,12 +473,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 ) @@ -139,43 +499,32 @@ def _create_initial( 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_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', max_length=90, min_length=1), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - 'subAccountName': self._serialize.url("sub_account_name", sub_account_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, 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, 'LogzMonitorResource') + _json = self._serialize.body(body, 'LogzMonitorResource') 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_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + sub_account_name=sub_account_name, + content_type=content_type, + json=_json, + template_url=self._create_initial.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) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('LogzMonitorResource', pipeline_response) @@ -187,8 +536,11 @@ def _create_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}'} # type: ignore + + @distributed_trace def begin_create( self, resource_group_name, # type: str @@ -198,7 +550,8 @@ def begin_create( **kwargs # type: Any ): # type: (...) -> LROPoller["_models.LogzMonitorResource"] - """Create sub account under a given monitor resource. This create operation can take upto 10 minutes to complete. + """Create sub account under a given monitor resource. This create operation can take upto 10 + minutes to complete. Create sub account under a given monitor resource. This create operation can take upto 10 minutes to complete. @@ -213,15 +566,19 @@ def begin_create( :type body: ~microsoft_logz.models.LogzMonitorResource :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 LogzMonitorResource or the result of cls(response) + :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 LogzMonitorResource or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~microsoft_logz.models.LogzMonitorResource] - :raises ~azure.core.exceptions.HttpResponseError: + :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.LogzMonitorResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -234,28 +591,21 @@ def begin_create( monitor_name=monitor_name, sub_account_name=sub_account_name, body=body, + 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('LogzMonitorResource', 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', max_length=90, min_length=1), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - 'subAccountName': self._serialize.url("sub_account_name", sub_account_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -267,8 +617,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -297,34 +649,24 @@ 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), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - 'subAccountName': self._serialize.url("sub_account_name", sub_account_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("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, + monitor_name=monitor_name, + sub_account_name=sub_account_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('LogzMonitorResource', pipeline_response) @@ -333,8 +675,10 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}'} # type: ignore + def _delete_initial( self, resource_group_name, # type: str @@ -348,45 +692,37 @@ def _delete_initial( 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_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', max_length=90, min_length=1), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - 'subAccountName': self._serialize.url("sub_account_name", sub_account_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("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_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + sub_account_name=sub_account_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 if response.status_code not in [200, 202, 204]: 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) response_headers = {} if response.status_code == 202: response_headers['location']=self._deserialize('str', response.headers.get('location')) + if cls: return cls(pipeline_response, None, response_headers) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}'} # type: ignore + + @distributed_trace def begin_delete( self, resource_group_name, # type: str @@ -407,15 +743,17 @@ def begin_delete( :type sub_account_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', @@ -430,22 +768,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', max_length=90, min_length=1), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - 'subAccountName': self._serialize.url("sub_account_name", sub_account_name, 'str'), - } - 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: @@ -457,8 +787,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}'} # type: ignore + @distributed_trace def update( self, resource_group_name, # type: str @@ -490,42 +822,32 @@ 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), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - 'subAccountName': self._serialize.url("sub_account_name", sub_account_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'LogzMonitorResourceUpdateParameters') + _json = self._serialize.body(body, 'LogzMonitorResourceUpdateParameters') 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, + monitor_name=monitor_name, + sub_account_name=sub_account_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('LogzMonitorResource', pipeline_response) @@ -534,8 +856,11 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}'} # type: ignore + + @distributed_trace def list_monitored_resources( self, resource_group_name, # type: str @@ -555,7 +880,8 @@ def list_monitored_resources( :param sub_account_name: Sub Account resource name. :type sub_account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MonitoredResourceListResponse or the result of cls(response) + :return: An iterator like instance of either MonitoredResourceListResponse or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~microsoft_logz.models.MonitoredResourceListResponse] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -564,37 +890,35 @@ def list_monitored_resources( 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_monitored_resources.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.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), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - 'subAccountName': self._serialize.url("sub_account_name", sub_account_name, 'str'), - } - url = self._client.format_url(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.post(url, query_parameters, header_parameters) + + request = build_list_monitored_resources_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + sub_account_name=sub_account_name, + template_url=self.list_monitored_resources.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_monitored_resources_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + sub_account_name=sub_account_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('MonitoredResourceListResponse', pipeline_response) + deserialized = self._deserialize("MonitoredResourceListResponse", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -607,17 +931,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_monitored_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}/listMonitoredResources'} # type: ignore + @distributed_trace def vm_host_payload( self, resource_group_name, # type: str @@ -646,34 +972,24 @@ def vm_host_payload( 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.vm_host_payload.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.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), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - 'subAccountName': self._serialize.url("sub_account_name", sub_account_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_vm_host_payload_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + sub_account_name=sub_account_name, + template_url=self.vm_host_payload.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('VMExtensionPayload', pipeline_response) @@ -682,8 +998,11 @@ def vm_host_payload( return cls(pipeline_response, deserialized, {}) return deserialized + vm_host_payload.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}/vmHostPayload'} # type: ignore + + @distributed_trace def list_vm_host_update( self, resource_group_name, # type: str @@ -693,7 +1012,8 @@ def list_vm_host_update( **kwargs # type: Any ): # type: (...) -> Iterable["_models.VMResourcesListResponse"] - """Sending request to update the collection when Logz.io agent has been installed on a VM for a given monitor. + """Sending request to update the collection when Logz.io agent has been installed on a VM for a + given monitor. Sending request to update the collection when Logz.io agent has been installed on a VM for a given monitor. @@ -707,60 +1027,59 @@ def list_vm_host_update( :param body: Request body to update the collection for agent installed in the given monitor. :type body: ~microsoft_logz.models.VMHostUpdateRequest :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either VMResourcesListResponse or the result of cls(response) + :return: An iterator like instance of either VMResourcesListResponse or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~microsoft_logz.models.VMResourcesListResponse] :raises: ~azure.core.exceptions.HttpResponseError """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType["_models.VMResourcesListResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - content_type = "application/json" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_vm_host_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), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - 'subAccountName': self._serialize.url("sub_account_name", sub_account_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'VMHostUpdateRequest') + _json = self._serialize.body(body, 'VMHostUpdateRequest') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_list_vm_host_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + sub_account_name=sub_account_name, + content_type=content_type, + json=_json, + template_url=self.list_vm_host_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'VMHostUpdateRequest') + _json = self._serialize.body(body, 'VMHostUpdateRequest') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.get(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_list_vm_host_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + sub_account_name=sub_account_name, + content_type=content_type, + json=_json, + 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('VMResourcesListResponse', pipeline_response) + deserialized = self._deserialize("VMResourcesListResponse", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -773,17 +1092,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_vm_host_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}/vmHostUpdate'} # type: ignore + @distributed_trace def list_vm_hosts( self, resource_group_name, # type: str @@ -803,7 +1124,8 @@ def list_vm_hosts( :param sub_account_name: Sub Account resource name. :type sub_account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either VMResourcesListResponse or the result of cls(response) + :return: An iterator like instance of either VMResourcesListResponse or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~microsoft_logz.models.VMResourcesListResponse] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -812,37 +1134,35 @@ def list_vm_hosts( 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_vm_hosts.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.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), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - 'subAccountName': self._serialize.url("sub_account_name", sub_account_name, 'str'), - } - url = self._client.format_url(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.post(url, query_parameters, header_parameters) + + request = build_list_vm_hosts_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + sub_account_name=sub_account_name, + template_url=self.list_vm_hosts.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_vm_hosts_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + sub_account_name=sub_account_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('VMResourcesListResponse', pipeline_response) + deserialized = self._deserialize("VMResourcesListResponse", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -855,12 +1175,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/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_sub_account_tag_rules_operations.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_sub_account_tag_rules_operations.py index 5c32a196e2abc..c5d30526137f0 100644 --- a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_sub_account_tag_rules_operations.py +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_sub_account_tag_rules_operations.py @@ -5,24 +5,194 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + subscription_id, # type: str + resource_group_name, # type: str + monitor_name, # type: str + sub_account_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}/tagRules') + 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), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, 'str'), + "subAccountName": _SERIALIZER.url("sub_account_name", sub_account_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + subscription_id, # type: str + resource_group_name, # type: str + monitor_name, # type: str + sub_account_name, # type: str + rule_set_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}/tagRules/{ruleSetName}') + 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), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, 'str'), + "subAccountName": _SERIALIZER.url("sub_account_name", sub_account_name, 'str'), + "ruleSetName": _SERIALIZER.url("rule_set_name", rule_set_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id, # type: str + resource_group_name, # type: str + monitor_name, # type: str + sub_account_name, # type: str + rule_set_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}/tagRules/{ruleSetName}') + 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), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, 'str'), + "subAccountName": _SERIALIZER.url("sub_account_name", sub_account_name, 'str'), + "ruleSetName": _SERIALIZER.url("rule_set_name", rule_set_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + subscription_id, # type: str + resource_group_name, # type: str + monitor_name, # type: str + sub_account_name, # type: str + rule_set_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}/tagRules/{ruleSetName}') + 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), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, 'str'), + "subAccountName": _SERIALIZER.url("sub_account_name", sub_account_name, 'str'), + "ruleSetName": _SERIALIZER.url("rule_set_name", rule_set_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +# fmt: on class SubAccountTagRulesOperations(object): """SubAccountTagRulesOperations operations. @@ -45,6 +215,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_group_name, # type: str @@ -64,7 +235,8 @@ def list( :param sub_account_name: Sub Account resource name. :type sub_account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MonitoringTagRulesListResponse or the result of cls(response) + :return: An iterator like instance of either MonitoringTagRulesListResponse or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~microsoft_logz.models.MonitoringTagRulesListResponse] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -73,37 +245,35 @@ def list( 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.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.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), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - 'subAccountName': self._serialize.url("sub_account_name", sub_account_name, 'str'), - } - url = self._client.format_url(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, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + sub_account_name=sub_account_name, + 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, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + sub_account_name=sub_account_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('MonitoringTagRulesListResponse', pipeline_response) + deserialized = self._deserialize("MonitoringTagRulesListResponse", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -116,17 +286,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}/tagRules'} # type: ignore + @distributed_trace def create_or_update( self, resource_group_name, # type: str @@ -161,43 +333,33 @@ 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), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - 'subAccountName': self._serialize.url("sub_account_name", sub_account_name, 'str'), - 'ruleSetName': self._serialize.url("rule_set_name", rule_set_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'MonitoringTagRules') + _json = self._serialize.body(body, 'MonitoringTagRules') 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_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + sub_account_name=sub_account_name, + rule_set_name=rule_set_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('MonitoringTagRules', pipeline_response) @@ -206,8 +368,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}/tagRules/{ruleSetName}'} # type: ignore + + @distributed_trace def get( self, resource_group_name, # type: str @@ -239,35 +404,25 @@ 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), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - 'subAccountName': self._serialize.url("sub_account_name", sub_account_name, 'str'), - 'ruleSetName': self._serialize.url("rule_set_name", rule_set_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("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, + monitor_name=monitor_name, + sub_account_name=sub_account_name, + rule_set_name=rule_set_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('MonitoringTagRules', pipeline_response) @@ -276,8 +431,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}/tagRules/{ruleSetName}'} # type: ignore + + @distributed_trace def delete( self, resource_group_name, # type: str @@ -309,42 +467,34 @@ 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), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - 'subAccountName': self._serialize.url("sub_account_name", sub_account_name, 'str'), - 'ruleSetName': self._serialize.url("rule_set_name", rule_set_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("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, + monitor_name=monitor_name, + sub_account_name=sub_account_name, + rule_set_name=rule_set_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, 202, 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) response_headers = {} if response.status_code == 202: response_headers['location']=self._deserialize('str', response.headers.get('location')) + if cls: return cls(pipeline_response, None, response_headers) delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/accounts/{subAccountName}/tagRules/{ruleSetName}'} # type: ignore + diff --git a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_tag_rules_operations.py b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_tag_rules_operations.py index 52faf9eb75fa1..bc338d433b520 100644 --- a/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_tag_rules_operations.py +++ b/sdk/logz/azure-mgmt-logz/azure/mgmt/logz/operations/_tag_rules_operations.py @@ -5,24 +5,186 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + subscription_id, # type: str + resource_group_name, # type: str + monitor_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/tagRules') + 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), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + subscription_id, # type: str + resource_group_name, # type: str + monitor_name, # type: str + rule_set_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/tagRules/{ruleSetName}') + 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), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, 'str'), + "ruleSetName": _SERIALIZER.url("rule_set_name", rule_set_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id, # type: str + resource_group_name, # type: str + monitor_name, # type: str + rule_set_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/tagRules/{ruleSetName}') + 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), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, 'str'), + "ruleSetName": _SERIALIZER.url("rule_set_name", rule_set_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + subscription_id, # type: str + resource_group_name, # type: str + monitor_name, # type: str + rule_set_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/tagRules/{ruleSetName}') + 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), + "monitorName": _SERIALIZER.url("monitor_name", monitor_name, 'str'), + "ruleSetName": _SERIALIZER.url("rule_set_name", rule_set_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +# fmt: on class TagRulesOperations(object): """TagRulesOperations operations. @@ -45,6 +207,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_group_name, # type: str @@ -61,7 +224,8 @@ def list( :param monitor_name: Monitor resource name. :type monitor_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MonitoringTagRulesListResponse or the result of cls(response) + :return: An iterator like instance of either MonitoringTagRulesListResponse or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~microsoft_logz.models.MonitoringTagRulesListResponse] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -70,36 +234,33 @@ def list( 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.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.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), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - } - url = self._client.format_url(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, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + 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, + resource_group_name=resource_group_name, + monitor_name=monitor_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('MonitoringTagRulesListResponse', pipeline_response) + deserialized = self._deserialize("MonitoringTagRulesListResponse", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -112,17 +273,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/tagRules'} # type: ignore + @distributed_trace def create_or_update( self, resource_group_name, # type: str @@ -154,42 +317,32 @@ 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), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - 'ruleSetName': self._serialize.url("rule_set_name", rule_set_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'MonitoringTagRules') + _json = self._serialize.body(body, 'MonitoringTagRules') 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_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + monitor_name=monitor_name, + rule_set_name=rule_set_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('MonitoringTagRules', pipeline_response) @@ -198,8 +351,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/tagRules/{ruleSetName}'} # type: ignore + + @distributed_trace def get( self, resource_group_name, # type: str @@ -228,34 +384,24 @@ 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), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - 'ruleSetName': self._serialize.url("rule_set_name", rule_set_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("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, + monitor_name=monitor_name, + rule_set_name=rule_set_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('MonitoringTagRules', pipeline_response) @@ -264,8 +410,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/tagRules/{ruleSetName}'} # type: ignore + + @distributed_trace def delete( self, resource_group_name, # type: str @@ -294,41 +443,33 @@ 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), - 'monitorName': self._serialize.url("monitor_name", monitor_name, 'str'), - 'ruleSetName': self._serialize.url("rule_set_name", rule_set_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("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, + monitor_name=monitor_name, + rule_set_name=rule_set_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, 202, 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) response_headers = {} if response.status_code == 202: response_headers['location']=self._deserialize('str', response.headers.get('location')) + if cls: return cls(pipeline_response, None, response_headers) delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logz/monitors/{monitorName}/tagRules/{ruleSetName}'} # type: ignore +