From 3c95bfde885617fbf6c064be30c8d8d5bbd2e3fa Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Wed, 5 Jan 2022 11:17:33 +0000 Subject: [PATCH] CodeGen from PR 16847 in Azure/azure-rest-api-specs Add Track2 release go tag (#16847) * Add Track2 release go tag * recover --- .../azure-mgmt-changeanalysis/_meta.json | 11 + .../azure/mgmt/changeanalysis/__init__.py | 9 +- ...azure_change_analysis_management_client.py | 74 ++-- .../mgmt/changeanalysis/_configuration.py | 19 +- .../azure/mgmt/changeanalysis/_metadata.json | 69 ++- .../azure/mgmt/changeanalysis/_patch.py | 31 ++ .../azure/mgmt/changeanalysis/_vendor.py | 27 ++ .../azure/mgmt/changeanalysis/_version.py | 2 +- .../azure/mgmt/changeanalysis/aio/__init__.py | 5 + ...azure_change_analysis_management_client.py | 63 ++- .../mgmt/changeanalysis/aio/_configuration.py | 6 +- .../azure/mgmt/changeanalysis/aio/_patch.py | 31 ++ .../aio/operations/_changes_operations.py | 128 +++--- .../aio/operations/_operations.py | 61 +-- .../_resource_changes_operations.py | 67 +-- .../mgmt/changeanalysis/models/__init__.py | 39 +- ...change_analysis_management_client_enums.py | 25 +- .../mgmt/changeanalysis/models/_models.py | 404 ------------------ .../mgmt/changeanalysis/models/_models_py3.py | 260 +++++++---- .../operations/_changes_operations.py | 239 +++++++---- .../changeanalysis/operations/_operations.py | 106 +++-- .../_resource_changes_operations.py | 128 ++++-- 22 files changed, 904 insertions(+), 900 deletions(-) create mode 100644 sdk/changeanalysis/azure-mgmt-changeanalysis/_meta.json create mode 100644 sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/_patch.py create mode 100644 sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/_vendor.py create mode 100644 sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/aio/_patch.py delete mode 100644 sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/models/_models.py diff --git a/sdk/changeanalysis/azure-mgmt-changeanalysis/_meta.json b/sdk/changeanalysis/azure-mgmt-changeanalysis/_meta.json new file mode 100644 index 0000000000000..d793693491e5b --- /dev/null +++ b/sdk/changeanalysis/azure-mgmt-changeanalysis/_meta.json @@ -0,0 +1,11 @@ +{ + "autorest": "3.7.2", + "use": [ + "@autorest/python@5.12.0", + "@autorest/modelerfour@4.19.3" + ], + "commit": "6acc7e2e59b3777da22e417149d0c71d05054bff", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest_command": "autorest specification/changeanalysis/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --python3-only --track2 --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "readme": "specification/changeanalysis/resource-manager/readme.md" +} \ No newline at end of file diff --git a/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/__init__.py b/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/__init__.py index eb4a9e9308ffa..8661421038e08 100644 --- a/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/__init__.py +++ b/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['AzureChangeAnalysisManagementClient'] -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/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/_azure_change_analysis_management_client.py b/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/_azure_change_analysis_management_client.py index 59fade86330fc..cc1c87c6f5512 100644 --- a/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/_azure_change_analysis_management_client.py +++ b/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/_azure_change_analysis_management_client.py @@ -6,25 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import AzureChangeAnalysisManagementClientConfiguration +from .operations import ChangesOperations, Operations, ResourceChangesOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential -from ._configuration import AzureChangeAnalysisManagementClientConfiguration -from .operations import Operations -from .operations import ResourceChangesOperations -from .operations import ChangesOperations -from . import models - - -class AzureChangeAnalysisManagementClient(object): +class AzureChangeAnalysisManagementClient: """AzureChangeAnalysisManagementClient. :ivar operations: Operations operations @@ -37,33 +34,54 @@ class AzureChangeAnalysisManagementClient(object): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = AzureChangeAnalysisManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = AzureChangeAnalysisManagementClientConfiguration(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.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.resource_changes = ResourceChangesOperations(self._client, self._config, self._serialize, self._deserialize) + self.changes = ChangesOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request, # type: HttpRequest + **kwargs: Any + ) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.resource_changes = ResourceChangesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.changes = ChangesOperations( - self._client, self._config, self._serialize, self._deserialize) + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/_configuration.py b/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/_configuration.py index 8db0f707abf06..61b056931e52f 100644 --- a/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/_configuration.py +++ b/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/_configuration.py @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class AzureChangeAnalysisManagementClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(AzureChangeAnalysisManagementClientConfiguration, 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(AzureChangeAnalysisManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +65,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/_metadata.json b/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/_metadata.json index 7fd44a341edd2..57b41edcb52b9 100644 --- a/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/_metadata.json +++ b/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/_metadata.json @@ -5,11 +5,13 @@ "name": "AzureChangeAnalysisManagementClient", "filename": "_azure_change_analysis_management_client", "description": "AzureChangeAnalysisManagementClient.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, - "client_side_validation": false + "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\": [\"AzureChangeAnalysisManagementClientConfiguration\"]}}, \"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\": [\"AzureChangeAnalysisManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -28,13 +30,13 @@ }, "async": { "credential": { - "signature": "credential, # type: \"AsyncTokenCredential\"", + "signature": "credential: \"AsyncTokenCredential\",", "description": "Credential needed for the client to connect to Azure.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", + "signature": "subscription_id: str,", "description": "The ID of the target subscription.", "docstring_type": "str", "required": true @@ -42,22 +44,61 @@ }, "constant": { }, - "call": "credential, subscription_id" + "call": "credential, subscription_id", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=\"https://management.azure.com\", # type: str", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } }, "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null + "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": { "operations": "Operations", "resource_changes": "ResourceChangesOperations", "changes": "ChangesOperations" - }, - "operation_mixins": { - }, - "sync_imports": "None", - "async_imports": "None" + } } \ No newline at end of file diff --git a/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/_patch.py b/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/_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/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/_vendor.py b/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/_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/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/_version.py b/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/_version.py index c47f66669f1bf..e5754a47ce68f 100644 --- a/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/_version.py +++ b/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/_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/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/aio/__init__.py b/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/aio/__init__.py index 62cc3cf5659cd..ae1527bfee796 100644 --- a/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/aio/__init__.py +++ b/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/aio/__init__.py @@ -8,3 +8,8 @@ from ._azure_change_analysis_management_client import AzureChangeAnalysisManagementClient __all__ = ['AzureChangeAnalysisManagementClient'] + +# `._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/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/aio/_azure_change_analysis_management_client.py b/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/aio/_azure_change_analysis_management_client.py index ae4782f4ec1ba..9dc44d4285878 100644 --- a/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/aio/_azure_change_analysis_management_client.py +++ b/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/aio/_azure_change_analysis_management_client.py @@ -6,23 +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.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import AzureChangeAnalysisManagementClientConfiguration +from .operations import ChangesOperations, Operations, ResourceChangesOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import AzureChangeAnalysisManagementClientConfiguration -from .operations import Operations -from .operations import ResourceChangesOperations -from .operations import ChangesOperations -from .. import models - - -class AzureChangeAnalysisManagementClient(object): +class AzureChangeAnalysisManagementClient: """AzureChangeAnalysisManagementClient. :ivar operations: Operations operations @@ -35,32 +34,54 @@ class AzureChangeAnalysisManagementClient(object): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = AzureChangeAnalysisManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = AzureChangeAnalysisManagementClientConfiguration(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.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.resource_changes = ResourceChangesOperations(self._client, self._config, self._serialize, self._deserialize) + self.changes = ChangesOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.resource_changes = ResourceChangesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.changes = ChangesOperations( - self._client, self._config, self._serialize, self._deserialize) + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/aio/_configuration.py b/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/aio/_configuration.py index 857015f4191c3..405280f4e9bef 100644 --- a/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/aio/_configuration.py +++ b/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/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(AzureChangeAnalysisManagementClientConfiguration, 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(AzureChangeAnalysisManagementClientConfiguration, 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/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/aio/_patch.py b/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/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/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/aio/operations/_changes_operations.py b/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/aio/operations/_changes_operations.py index 3f8f556d0e547..af69f03c58df4 100644 --- a/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/aio/operations/_changes_operations.py +++ b/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/aio/operations/_changes_operations.py @@ -6,17 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar 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._changes_operations import build_list_changes_by_resource_group_request, build_list_changes_by_subscription_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -42,15 +47,17 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_changes_by_resource_group( self, resource_group_name: str, start_time: datetime.datetime, end_time: datetime.datetime, skip_token: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ChangeList"]: - """List the changes of a resource group within the specified time range. Customer data will always be masked. + """List the changes of a resource group within the specified time range. Customer data will always + be masked. List the changes of a resource group within the specified time range. Customer data will always be masked. @@ -76,39 +83,37 @@ def list_changes_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_changes_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, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - query_parameters['$startTime'] = self._serialize.query("start_time", start_time, 'iso-8601') - query_parameters['$endTime'] = self._serialize.query("end_time", end_time, 'iso-8601') - if skip_token is not None: - query_parameters['$skipToken'] = self._serialize.query("skip_token", skip_token, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_changes_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + start_time=start_time, + end_time=end_time, + skip_token=skip_token, + template_url=self.list_changes_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_changes_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + start_time=start_time, + end_time=end_time, + skip_token=skip_token, + 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('ChangeList', pipeline_response) + deserialized = self._deserialize("ChangeList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -121,25 +126,28 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + 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_changes_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ChangeAnalysis/changes'} # type: ignore + @distributed_trace def list_changes_by_subscription( self, start_time: datetime.datetime, end_time: datetime.datetime, skip_token: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ChangeList"]: - """List the changes of a subscription within the specified time range. Customer data will always be masked. + """List the changes of a subscription within the specified time range. Customer data will always + be masked. List the changes of a subscription within the specified time range. Customer data will always be masked. @@ -163,38 +171,35 @@ def list_changes_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_changes_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') - query_parameters['$startTime'] = self._serialize.query("start_time", start_time, 'iso-8601') - query_parameters['$endTime'] = self._serialize.query("end_time", end_time, 'iso-8601') - if skip_token is not None: - query_parameters['$skipToken'] = self._serialize.query("skip_token", skip_token, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_changes_by_subscription_request( + subscription_id=self._config.subscription_id, + start_time=start_time, + end_time=end_time, + skip_token=skip_token, + template_url=self.list_changes_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_changes_by_subscription_request( + subscription_id=self._config.subscription_id, + start_time=start_time, + end_time=end_time, + skip_token=skip_token, + 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('ChangeList', pipeline_response) + deserialized = self._deserialize("ChangeList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -207,12 +212,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + 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/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/aio/operations/_operations.py b/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/aio/operations/_operations.py index 2c46b20f74a6a..3fb05d04b61c6 100644 --- a/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/aio/operations/_operations.py +++ b/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/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,12 +46,14 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, skip_token: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ResourceProviderOperationList"]: - """Lists all the supported operations by the Microsoft.ChangeAnalysis resource provider along with their descriptions. + """Lists all the supported operations by the Microsoft.ChangeAnalysis resource provider along with + their descriptions. Lists all the supported operations by the Microsoft.ChangeAnalysis resource provider along with their descriptions. @@ -57,8 +64,10 @@ def list( subsequent calls. :type skip_token: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceProviderOperationList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~Microsoft.ChangeAnalysis.models.ResourceProviderOperationList] + :return: An iterator like instance of either ResourceProviderOperationList or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~Microsoft.ChangeAnalysis.models.ResourceProviderOperationList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceProviderOperationList"] @@ -66,32 +75,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if skip_token is not None: - query_parameters['$skipToken'] = self._serialize.query("skip_token", skip_token, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + skip_token=skip_token, + 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( + skip_token=skip_token, + 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('ResourceProviderOperationList', pipeline_response) + deserialized = self._deserialize("ResourceProviderOperationList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -104,12 +110,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + 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/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/aio/operations/_resource_changes_operations.py b/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/aio/operations/_resource_changes_operations.py index 96944ce0b6f04..c5cbe2c3ea201 100644 --- a/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/aio/operations/_resource_changes_operations.py +++ b/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/aio/operations/_resource_changes_operations.py @@ -6,17 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar 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._resource_changes_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -42,15 +47,17 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_id: str, start_time: datetime.datetime, end_time: datetime.datetime, skip_token: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ChangeList"]: - """List the changes of a resource within the specified time range. Customer data will be masked if the user doesn't have access. + """List the changes of a resource within the specified time range. Customer data will be masked if + the user doesn't have access. List the changes of a resource within the specified time range. Customer data will be masked if the user doesn't have access. @@ -76,38 +83,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - query_parameters['$startTime'] = self._serialize.query("start_time", start_time, 'iso-8601') - query_parameters['$endTime'] = self._serialize.query("end_time", end_time, 'iso-8601') - if skip_token is not None: - query_parameters['$skipToken'] = self._serialize.query("skip_token", skip_token, 'str') - - request = self._client.post(url, query_parameters, header_parameters) + + request = build_list_request( + resource_id=resource_id, + start_time=start_time, + end_time=end_time, + skip_token=skip_token, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_id=resource_id, + start_time=start_time, + end_time=end_time, + skip_token=skip_token, + 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('ChangeList', pipeline_response) + deserialized = self._deserialize("ChangeList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -120,12 +124,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_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/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/models/__init__.py b/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/models/__init__.py index 057fdce99a1bc..9215e5ade7dae 100644 --- a/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/models/__init__.py +++ b/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/models/__init__.py @@ -6,32 +6,19 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import Change - from ._models_py3 import ChangeList - from ._models_py3 import ChangeProperties - from ._models_py3 import ErrorAdditionalInfo - from ._models_py3 import ErrorDetail - from ._models_py3 import ErrorResponse - from ._models_py3 import PropertyChange - from ._models_py3 import ProxyResource - from ._models_py3 import Resource - from ._models_py3 import ResourceProviderOperationDefinition - from ._models_py3 import ResourceProviderOperationDisplay - from ._models_py3 import ResourceProviderOperationList -except (SyntaxError, ImportError): - from ._models import Change # type: ignore - from ._models import ChangeList # type: ignore - from ._models import ChangeProperties # type: ignore - from ._models import ErrorAdditionalInfo # type: ignore - from ._models import ErrorDetail # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import PropertyChange # type: ignore - from ._models import ProxyResource # type: ignore - from ._models import Resource # type: ignore - from ._models import ResourceProviderOperationDefinition # type: ignore - from ._models import ResourceProviderOperationDisplay # type: ignore - from ._models import ResourceProviderOperationList # type: ignore +from ._models_py3 import Change +from ._models_py3 import ChangeList +from ._models_py3 import ChangeProperties +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse +from ._models_py3 import PropertyChange +from ._models_py3 import ProxyResource +from ._models_py3 import Resource +from ._models_py3 import ResourceProviderOperationDefinition +from ._models_py3 import ResourceProviderOperationDisplay +from ._models_py3 import ResourceProviderOperationList + from ._azure_change_analysis_management_client_enums import ( ChangeCategory, diff --git a/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/models/_azure_change_analysis_management_client_enums.py b/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/models/_azure_change_analysis_management_client_enums.py index 67bd055a51bd6..4eb546b54b54d 100644 --- a/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/models/_azure_change_analysis_management_client_enums.py +++ b/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/models/_azure_change_analysis_management_client_enums.py @@ -6,34 +6,19 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class ChangeCategory(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ChangeCategory(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The change category. """ USER = "User" SYSTEM = "System" -class ChangeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ChangeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the change. """ @@ -41,7 +26,7 @@ class ChangeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): REMOVE = "Remove" UPDATE = "Update" -class Level(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Level(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): NOISY = "Noisy" NORMAL = "Normal" diff --git a/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/models/_models.py b/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/models/_models.py deleted file mode 100644 index 67a7aa6f19d08..0000000000000 --- a/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/models/_models.py +++ /dev/null @@ -1,404 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class Resource(msrest.serialization.Model): - """Common fields that are returned in the response for all Azure Resource Manager resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class Change(Resource): - """The detected change. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param properties: The properties of a change. - :type properties: ~Microsoft.ChangeAnalysis.models.ChangeProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'ChangeProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(Change, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - - -class ChangeList(msrest.serialization.Model): - """The list of detected changes. - - :param value: The list of changes. - :type value: list[~Microsoft.ChangeAnalysis.models.Change] - :param next_link: The URI that can be used to request the next page of changes. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Change]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ChangeList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class ChangeProperties(msrest.serialization.Model): - """The properties of a change. - - :param resource_id: The resource id that the change is attached to. - :type resource_id: str - :param time_stamp: The time when the change is detected. - :type time_stamp: ~datetime.datetime - :param initiated_by_list: The list of identities who might initiated the change. - The identity could be user name (email address) or the object ID of the Service Principal. - :type initiated_by_list: list[str] - :param change_type: The type of the change. Possible values include: "Add", "Remove", "Update". - :type change_type: str or ~Microsoft.ChangeAnalysis.models.ChangeType - :param property_changes: The list of detailed changes at json property level. - :type property_changes: list[~Microsoft.ChangeAnalysis.models.PropertyChange] - """ - - _attribute_map = { - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'time_stamp': {'key': 'timeStamp', 'type': 'iso-8601'}, - 'initiated_by_list': {'key': 'initiatedByList', 'type': '[str]'}, - 'change_type': {'key': 'changeType', 'type': 'str'}, - 'property_changes': {'key': 'propertyChanges', 'type': '[PropertyChange]'}, - } - - def __init__( - self, - **kwargs - ): - super(ChangeProperties, self).__init__(**kwargs) - self.resource_id = kwargs.get('resource_id', None) - self.time_stamp = kwargs.get('time_stamp', None) - self.initiated_by_list = kwargs.get('initiated_by_list', None) - self.change_type = kwargs.get('change_type', None) - self.property_changes = kwargs.get('property_changes', None) - - -class ErrorAdditionalInfo(msrest.serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: object - """ - - _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorAdditionalInfo, self).__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(msrest.serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~Microsoft.ChangeAnalysis.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: list[~Microsoft.ChangeAnalysis.models.ErrorAdditionalInfo] - """ - - _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorDetail]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorDetail, self).__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponse(msrest.serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). - - :param error: The error object. - :type error: ~Microsoft.ChangeAnalysis.models.ErrorDetail - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDetail'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class PropertyChange(msrest.serialization.Model): - """Data of a property change. - - :param change_type: The type of the change. Possible values include: "Add", "Remove", "Update". - :type change_type: str or ~Microsoft.ChangeAnalysis.models.ChangeType - :param change_category: The change category. Possible values include: "User", "System". - :type change_category: str or ~Microsoft.ChangeAnalysis.models.ChangeCategory - :param json_path: The json path of the changed property. - :type json_path: str - :param display_name: The enhanced display name of the json path. E.g., the json path - value[0].properties will be translated to something meaningful like - slots["Staging"].properties. - :type display_name: str - :param level: Possible values include: "Noisy", "Normal", "Important". - :type level: str or ~Microsoft.ChangeAnalysis.models.Level - :param description: The description of the changed property. - :type description: str - :param old_value: The value of the property before the change. - :type old_value: str - :param new_value: The value of the property after the change. - :type new_value: str - :param is_data_masked: The boolean indicating whether the oldValue and newValue are masked. The - values are masked if it contains sensitive information that the user doesn't have access to. - :type is_data_masked: bool - """ - - _attribute_map = { - 'change_type': {'key': 'changeType', 'type': 'str'}, - 'change_category': {'key': 'changeCategory', 'type': 'str'}, - 'json_path': {'key': 'jsonPath', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'level': {'key': 'level', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'old_value': {'key': 'oldValue', 'type': 'str'}, - 'new_value': {'key': 'newValue', 'type': 'str'}, - 'is_data_masked': {'key': 'isDataMasked', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(PropertyChange, self).__init__(**kwargs) - self.change_type = kwargs.get('change_type', None) - self.change_category = kwargs.get('change_category', None) - self.json_path = kwargs.get('json_path', None) - self.display_name = kwargs.get('display_name', None) - self.level = kwargs.get('level', None) - self.description = kwargs.get('description', None) - self.old_value = kwargs.get('old_value', None) - self.new_value = kwargs.get('new_value', None) - self.is_data_masked = kwargs.get('is_data_masked', None) - - -class ProxyResource(Resource): - """The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ProxyResource, self).__init__(**kwargs) - - -class ResourceProviderOperationDefinition(msrest.serialization.Model): - """The resource provider operation definition. - - :param name: The resource provider operation name. - :type name: str - :param display: The resource provider operation details. - :type display: ~Microsoft.ChangeAnalysis.models.ResourceProviderOperationDisplay - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'ResourceProviderOperationDisplay'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceProviderOperationDefinition, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display = kwargs.get('display', None) - - -class ResourceProviderOperationDisplay(msrest.serialization.Model): - """The resource provider operation details. - - :param provider: Name of the resource provider. - :type provider: str - :param resource: Name of the resource type. - :type resource: str - :param operation: Name of the resource provider operation. - :type operation: str - :param description: Description of the resource provider operation. - :type description: str - """ - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceProviderOperationDisplay, self).__init__(**kwargs) - self.provider = kwargs.get('provider', None) - self.resource = kwargs.get('resource', None) - self.operation = kwargs.get('operation', None) - self.description = kwargs.get('description', None) - - -class ResourceProviderOperationList(msrest.serialization.Model): - """The resource provider operation list. - - :param value: Resource provider operations list. - :type value: list[~Microsoft.ChangeAnalysis.models.ResourceProviderOperationDefinition] - :param next_link: The URI that can be used to request the next page for list of Azure - operations. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ResourceProviderOperationDefinition]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceProviderOperationList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) diff --git a/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/models/_models_py3.py b/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/models/_models_py3.py index e472276a1689f..34e7a3f55168e 100644 --- a/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/models/_models_py3.py +++ b/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/models/_models_py3.py @@ -46,13 +46,51 @@ def __init__( self, **kwargs ): + """ + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None self.type = None -class Change(Resource): +class ProxyResource(Resource): + """The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ProxyResource, self).__init__(**kwargs) + + +class Change(ProxyResource): """The detected change. Variables are only populated by the server, and will be ignored when sending a request. @@ -65,8 +103,8 @@ class Change(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param properties: The properties of a change. - :type properties: ~Microsoft.ChangeAnalysis.models.ChangeProperties + :ivar properties: The properties of a change. + :vartype properties: ~Microsoft.ChangeAnalysis.models.ChangeProperties """ _validation = { @@ -88,6 +126,10 @@ def __init__( properties: Optional["ChangeProperties"] = None, **kwargs ): + """ + :keyword properties: The properties of a change. + :paramtype properties: ~Microsoft.ChangeAnalysis.models.ChangeProperties + """ super(Change, self).__init__(**kwargs) self.properties = properties @@ -95,10 +137,10 @@ def __init__( class ChangeList(msrest.serialization.Model): """The list of detected changes. - :param value: The list of changes. - :type value: list[~Microsoft.ChangeAnalysis.models.Change] - :param next_link: The URI that can be used to request the next page of changes. - :type next_link: str + :ivar value: The list of changes. + :vartype value: list[~Microsoft.ChangeAnalysis.models.Change] + :ivar next_link: The URI that can be used to request the next page of changes. + :vartype next_link: str """ _attribute_map = { @@ -113,6 +155,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: The list of changes. + :paramtype value: list[~Microsoft.ChangeAnalysis.models.Change] + :keyword next_link: The URI that can be used to request the next page of changes. + :paramtype next_link: str + """ super(ChangeList, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -121,17 +169,17 @@ def __init__( class ChangeProperties(msrest.serialization.Model): """The properties of a change. - :param resource_id: The resource id that the change is attached to. - :type resource_id: str - :param time_stamp: The time when the change is detected. - :type time_stamp: ~datetime.datetime - :param initiated_by_list: The list of identities who might initiated the change. + :ivar resource_id: The resource id that the change is attached to. + :vartype resource_id: str + :ivar time_stamp: The time when the change is detected. + :vartype time_stamp: ~datetime.datetime + :ivar initiated_by_list: The list of identities who might initiated the change. The identity could be user name (email address) or the object ID of the Service Principal. - :type initiated_by_list: list[str] - :param change_type: The type of the change. Possible values include: "Add", "Remove", "Update". - :type change_type: str or ~Microsoft.ChangeAnalysis.models.ChangeType - :param property_changes: The list of detailed changes at json property level. - :type property_changes: list[~Microsoft.ChangeAnalysis.models.PropertyChange] + :vartype initiated_by_list: list[str] + :ivar change_type: The type of the change. Possible values include: "Add", "Remove", "Update". + :vartype change_type: str or ~Microsoft.ChangeAnalysis.models.ChangeType + :ivar property_changes: The list of detailed changes at json property level. + :vartype property_changes: list[~Microsoft.ChangeAnalysis.models.PropertyChange] """ _attribute_map = { @@ -152,6 +200,20 @@ def __init__( property_changes: Optional[List["PropertyChange"]] = None, **kwargs ): + """ + :keyword resource_id: The resource id that the change is attached to. + :paramtype resource_id: str + :keyword time_stamp: The time when the change is detected. + :paramtype time_stamp: ~datetime.datetime + :keyword initiated_by_list: The list of identities who might initiated the change. + The identity could be user name (email address) or the object ID of the Service Principal. + :paramtype initiated_by_list: list[str] + :keyword change_type: The type of the change. Possible values include: "Add", "Remove", + "Update". + :paramtype change_type: str or ~Microsoft.ChangeAnalysis.models.ChangeType + :keyword property_changes: The list of detailed changes at json property level. + :paramtype property_changes: list[~Microsoft.ChangeAnalysis.models.PropertyChange] + """ super(ChangeProperties, self).__init__(**kwargs) self.resource_id = resource_id self.time_stamp = time_stamp @@ -168,7 +230,7 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: object + :vartype info: any """ _validation = { @@ -185,6 +247,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -227,6 +291,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetail, self).__init__(**kwargs) self.code = None self.message = None @@ -238,8 +304,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.ChangeAnalysis.models.ErrorDetail + :ivar error: The error object. + :vartype error: ~Microsoft.ChangeAnalysis.models.ErrorDetail """ _attribute_map = { @@ -252,6 +318,10 @@ def __init__( error: Optional["ErrorDetail"] = None, **kwargs ): + """ + :keyword error: The error object. + :paramtype error: ~Microsoft.ChangeAnalysis.models.ErrorDetail + """ super(ErrorResponse, self).__init__(**kwargs) self.error = error @@ -259,27 +329,27 @@ def __init__( class PropertyChange(msrest.serialization.Model): """Data of a property change. - :param change_type: The type of the change. Possible values include: "Add", "Remove", "Update". - :type change_type: str or ~Microsoft.ChangeAnalysis.models.ChangeType - :param change_category: The change category. Possible values include: "User", "System". - :type change_category: str or ~Microsoft.ChangeAnalysis.models.ChangeCategory - :param json_path: The json path of the changed property. - :type json_path: str - :param display_name: The enhanced display name of the json path. E.g., the json path + :ivar change_type: The type of the change. Possible values include: "Add", "Remove", "Update". + :vartype change_type: str or ~Microsoft.ChangeAnalysis.models.ChangeType + :ivar change_category: The change category. Possible values include: "User", "System". + :vartype change_category: str or ~Microsoft.ChangeAnalysis.models.ChangeCategory + :ivar json_path: The json path of the changed property. + :vartype json_path: str + :ivar display_name: The enhanced display name of the json path. E.g., the json path value[0].properties will be translated to something meaningful like slots["Staging"].properties. - :type display_name: str - :param level: Possible values include: "Noisy", "Normal", "Important". - :type level: str or ~Microsoft.ChangeAnalysis.models.Level - :param description: The description of the changed property. - :type description: str - :param old_value: The value of the property before the change. - :type old_value: str - :param new_value: The value of the property after the change. - :type new_value: str - :param is_data_masked: The boolean indicating whether the oldValue and newValue are masked. The + :vartype display_name: str + :ivar level: Possible values include: "Noisy", "Normal", "Important". + :vartype level: str or ~Microsoft.ChangeAnalysis.models.Level + :ivar description: The description of the changed property. + :vartype description: str + :ivar old_value: The value of the property before the change. + :vartype old_value: str + :ivar new_value: The value of the property after the change. + :vartype new_value: str + :ivar is_data_masked: The boolean indicating whether the oldValue and newValue are masked. The values are masked if it contains sensitive information that the user doesn't have access to. - :type is_data_masked: bool + :vartype is_data_masked: bool """ _attribute_map = { @@ -308,6 +378,31 @@ def __init__( is_data_masked: Optional[bool] = None, **kwargs ): + """ + :keyword change_type: The type of the change. Possible values include: "Add", "Remove", + "Update". + :paramtype change_type: str or ~Microsoft.ChangeAnalysis.models.ChangeType + :keyword change_category: The change category. Possible values include: "User", "System". + :paramtype change_category: str or ~Microsoft.ChangeAnalysis.models.ChangeCategory + :keyword json_path: The json path of the changed property. + :paramtype json_path: str + :keyword display_name: The enhanced display name of the json path. E.g., the json path + value[0].properties will be translated to something meaningful like + slots["Staging"].properties. + :paramtype display_name: str + :keyword level: Possible values include: "Noisy", "Normal", "Important". + :paramtype level: str or ~Microsoft.ChangeAnalysis.models.Level + :keyword description: The description of the changed property. + :paramtype description: str + :keyword old_value: The value of the property before the change. + :paramtype old_value: str + :keyword new_value: The value of the property after the change. + :paramtype new_value: str + :keyword is_data_masked: The boolean indicating whether the oldValue and newValue are masked. + The values are masked if it contains sensitive information that the user doesn't have access + to. + :paramtype is_data_masked: bool + """ super(PropertyChange, self).__init__(**kwargs) self.change_type = change_type self.change_category = change_category @@ -320,47 +415,13 @@ def __init__( self.is_data_masked = is_data_masked -class ProxyResource(Resource): - """The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ProxyResource, self).__init__(**kwargs) - - class ResourceProviderOperationDefinition(msrest.serialization.Model): """The resource provider operation definition. - :param name: The resource provider operation name. - :type name: str - :param display: The resource provider operation details. - :type display: ~Microsoft.ChangeAnalysis.models.ResourceProviderOperationDisplay + :ivar name: The resource provider operation name. + :vartype name: str + :ivar display: The resource provider operation details. + :vartype display: ~Microsoft.ChangeAnalysis.models.ResourceProviderOperationDisplay """ _attribute_map = { @@ -375,6 +436,12 @@ def __init__( display: Optional["ResourceProviderOperationDisplay"] = None, **kwargs ): + """ + :keyword name: The resource provider operation name. + :paramtype name: str + :keyword display: The resource provider operation details. + :paramtype display: ~Microsoft.ChangeAnalysis.models.ResourceProviderOperationDisplay + """ super(ResourceProviderOperationDefinition, self).__init__(**kwargs) self.name = name self.display = display @@ -383,14 +450,14 @@ def __init__( class ResourceProviderOperationDisplay(msrest.serialization.Model): """The resource provider operation details. - :param provider: Name of the resource provider. - :type provider: str - :param resource: Name of the resource type. - :type resource: str - :param operation: Name of the resource provider operation. - :type operation: str - :param description: Description of the resource provider operation. - :type description: str + :ivar provider: Name of the resource provider. + :vartype provider: str + :ivar resource: Name of the resource type. + :vartype resource: str + :ivar operation: Name of the resource provider operation. + :vartype operation: str + :ivar description: Description of the resource provider operation. + :vartype description: str """ _attribute_map = { @@ -409,6 +476,16 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword provider: Name of the resource provider. + :paramtype provider: str + :keyword resource: Name of the resource type. + :paramtype resource: str + :keyword operation: Name of the resource provider operation. + :paramtype operation: str + :keyword description: Description of the resource provider operation. + :paramtype description: str + """ super(ResourceProviderOperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -419,11 +496,11 @@ def __init__( class ResourceProviderOperationList(msrest.serialization.Model): """The resource provider operation list. - :param value: Resource provider operations list. - :type value: list[~Microsoft.ChangeAnalysis.models.ResourceProviderOperationDefinition] - :param next_link: The URI that can be used to request the next page for list of Azure + :ivar value: Resource provider operations list. + :vartype value: list[~Microsoft.ChangeAnalysis.models.ResourceProviderOperationDefinition] + :ivar next_link: The URI that can be used to request the next page for list of Azure operations. - :type next_link: str + :vartype next_link: str """ _attribute_map = { @@ -438,6 +515,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Resource provider operations list. + :paramtype value: list[~Microsoft.ChangeAnalysis.models.ResourceProviderOperationDefinition] + :keyword next_link: The URI that can be used to request the next page for list of Azure + operations. + :paramtype next_link: str + """ super(ResourceProviderOperationList, self).__init__(**kwargs) self.value = value self.next_link = next_link diff --git a/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/operations/_changes_operations.py b/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/operations/_changes_operations.py index e68df8044032f..25d1c952a9bde 100644 --- a/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/operations/_changes_operations.py +++ b/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/operations/_changes_operations.py @@ -6,23 +6,105 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_changes_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + *, + start_time: datetime.datetime, + end_time: datetime.datetime, + skip_token: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ChangeAnalysis/changes') + 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') + query_parameters['$startTime'] = _SERIALIZER.query("start_time", start_time, 'iso-8601') + query_parameters['$endTime'] = _SERIALIZER.query("end_time", end_time, 'iso-8601') + if skip_token is not None: + query_parameters['$skipToken'] = _SERIALIZER.query("skip_token", skip_token, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: 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_changes_by_subscription_request( + subscription_id: str, + *, + start_time: datetime.datetime, + end_time: datetime.datetime, + skip_token: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.ChangeAnalysis/changes') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + query_parameters['$startTime'] = _SERIALIZER.query("start_time", start_time, 'iso-8601') + query_parameters['$endTime'] = _SERIALIZER.query("end_time", end_time, 'iso-8601') + if skip_token is not None: + query_parameters['$skipToken'] = _SERIALIZER.query("skip_token", skip_token, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ChangesOperations(object): """ChangesOperations operations. @@ -46,16 +128,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_changes_by_resource_group( self, - resource_group_name, # type: str - start_time, # type: datetime.datetime - end_time, # type: datetime.datetime - skip_token=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ChangeList"] - """List the changes of a resource group within the specified time range. Customer data will always be masked. + resource_group_name: str, + start_time: datetime.datetime, + end_time: datetime.datetime, + skip_token: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.ChangeList"]: + """List the changes of a resource group within the specified time range. Customer data will always + be masked. List the changes of a resource group within the specified time range. Customer data will always be masked. @@ -81,39 +164,37 @@ def list_changes_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_changes_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, pattern=r'^[-\w\._\(\)]+$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - query_parameters['$startTime'] = self._serialize.query("start_time", start_time, 'iso-8601') - query_parameters['$endTime'] = self._serialize.query("end_time", end_time, 'iso-8601') - if skip_token is not None: - query_parameters['$skipToken'] = self._serialize.query("skip_token", skip_token, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_changes_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + start_time=start_time, + end_time=end_time, + skip_token=skip_token, + template_url=self.list_changes_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_changes_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + start_time=start_time, + end_time=end_time, + skip_token=skip_token, + 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('ChangeList', pipeline_response) + deserialized = self._deserialize("ChangeList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -126,26 +207,28 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + 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_changes_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ChangeAnalysis/changes'} # type: ignore + @distributed_trace def list_changes_by_subscription( self, - start_time, # type: datetime.datetime - end_time, # type: datetime.datetime - skip_token=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ChangeList"] - """List the changes of a subscription within the specified time range. Customer data will always be masked. + start_time: datetime.datetime, + end_time: datetime.datetime, + skip_token: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.ChangeList"]: + """List the changes of a subscription within the specified time range. Customer data will always + be masked. List the changes of a subscription within the specified time range. Customer data will always be masked. @@ -169,38 +252,35 @@ def list_changes_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_changes_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') - query_parameters['$startTime'] = self._serialize.query("start_time", start_time, 'iso-8601') - query_parameters['$endTime'] = self._serialize.query("end_time", end_time, 'iso-8601') - if skip_token is not None: - query_parameters['$skipToken'] = self._serialize.query("skip_token", skip_token, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_changes_by_subscription_request( + subscription_id=self._config.subscription_id, + start_time=start_time, + end_time=end_time, + skip_token=skip_token, + template_url=self.list_changes_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_changes_by_subscription_request( + subscription_id=self._config.subscription_id, + start_time=start_time, + end_time=end_time, + skip_token=skip_token, + 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('ChangeList', pipeline_response) + deserialized = self._deserialize("ChangeList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -213,12 +293,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + 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/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/operations/_operations.py b/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/operations/_operations.py index 119f3e6d2f910..7a5060cb0d5c2 100644 --- a/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/operations/_operations.py +++ b/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/operations/_operations.py @@ -5,23 +5,54 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + *, + skip_token: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.ChangeAnalysis/operations') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if skip_token is not None: + query_parameters['$skipToken'] = _SERIALIZER.query("skip_token", skip_token, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class Operations(object): """Operations operations. @@ -45,13 +76,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - skip_token=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ResourceProviderOperationList"] - """Lists all the supported operations by the Microsoft.ChangeAnalysis resource provider along with their descriptions. + skip_token: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.ResourceProviderOperationList"]: + """Lists all the supported operations by the Microsoft.ChangeAnalysis resource provider along with + their descriptions. Lists all the supported operations by the Microsoft.ChangeAnalysis resource provider along with their descriptions. @@ -62,8 +94,10 @@ def list( subsequent calls. :type skip_token: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourceProviderOperationList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~Microsoft.ChangeAnalysis.models.ResourceProviderOperationList] + :return: An iterator like instance of either ResourceProviderOperationList or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~Microsoft.ChangeAnalysis.models.ResourceProviderOperationList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceProviderOperationList"] @@ -71,32 +105,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if skip_token is not None: - query_parameters['$skipToken'] = self._serialize.query("skip_token", skip_token, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + skip_token=skip_token, + 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( + skip_token=skip_token, + 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('ResourceProviderOperationList', pipeline_response) + deserialized = self._deserialize("ResourceProviderOperationList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -109,12 +140,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + 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/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/operations/_resource_changes_operations.py b/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/operations/_resource_changes_operations.py index 357cbe97225a5..0a9be57a9dbe2 100644 --- a/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/operations/_resource_changes_operations.py +++ b/sdk/changeanalysis/azure-mgmt-changeanalysis/azure/mgmt/changeanalysis/operations/_resource_changes_operations.py @@ -6,23 +6,64 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + resource_id: str, + *, + start_time: datetime.datetime, + end_time: datetime.datetime, + skip_token: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceId}/providers/Microsoft.ChangeAnalysis/resourceChanges') + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + query_parameters['$startTime'] = _SERIALIZER.query("start_time", start_time, 'iso-8601') + query_parameters['$endTime'] = _SERIALIZER.query("end_time", end_time, 'iso-8601') + if skip_token is not None: + query_parameters['$skipToken'] = _SERIALIZER.query("skip_token", skip_token, '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 + ) class ResourceChangesOperations(object): """ResourceChangesOperations operations. @@ -46,16 +87,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_id, # type: str - start_time, # type: datetime.datetime - end_time, # type: datetime.datetime - skip_token=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ChangeList"] - """List the changes of a resource within the specified time range. Customer data will be masked if the user doesn't have access. + resource_id: str, + start_time: datetime.datetime, + end_time: datetime.datetime, + skip_token: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.ChangeList"]: + """List the changes of a resource within the specified time range. Customer data will be masked if + the user doesn't have access. List the changes of a resource within the specified time range. Customer data will be masked if the user doesn't have access. @@ -81,38 +123,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceId': self._serialize.url("resource_id", resource_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - query_parameters['$startTime'] = self._serialize.query("start_time", start_time, 'iso-8601') - query_parameters['$endTime'] = self._serialize.query("end_time", end_time, 'iso-8601') - if skip_token is not None: - query_parameters['$skipToken'] = self._serialize.query("skip_token", skip_token, 'str') - - request = self._client.post(url, query_parameters, header_parameters) + + request = build_list_request( + resource_id=resource_id, + start_time=start_time, + end_time=end_time, + skip_token=skip_token, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_id=resource_id, + start_time=start_time, + end_time=end_time, + skip_token=skip_token, + 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('ChangeList', pipeline_response) + deserialized = self._deserialize("ChangeList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -125,12 +164,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + 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 )