From e3cbed51e8e526686689a1d2d918714a2fa70b25 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Wed, 5 Jan 2022 10:08:14 +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-automanage/_meta.json | 11 + .../azure/mgmt/automanage/__init__.py | 9 +- .../mgmt/automanage/_automanage_client.py | 86 +- .../azure/mgmt/automanage/_configuration.py | 22 +- .../azure/mgmt/automanage/_metadata.json | 77 +- .../azure/mgmt/automanage/_patch.py | 31 + .../azure/mgmt/automanage/_vendor.py | 27 + .../azure/mgmt/automanage/_version.py | 2 +- .../azure/mgmt/automanage/aio/__init__.py | 7 +- .../mgmt/automanage/aio/_automanage_client.py | 101 +++ .../aio/_automanage_client_async.py | 78 -- ...nfiguration_async.py => _configuration.py} | 9 +- .../azure/mgmt/automanage/aio/_patch.py | 31 + .../__init__.py | 8 +- .../_accounts_operations.py} | 302 ++++--- ...uration_profile_assignments_operations.py} | 310 +++---- ...uration_profile_preferences_operations.py} | 314 ++++---- .../_operations.py} | 59 +- .../azure/mgmt/automanage/models/__init__.py | 81 +- .../models/_automanage_client_enums.py | 49 +- .../azure/mgmt/automanage/models/_models.py | 760 ------------------ .../mgmt/automanage/models/_models_py3.py | 505 +++++++----- .../operations/_accounts_operations.py | 564 ++++++++----- ...guration_profile_assignments_operations.py | 539 ++++++++----- ...guration_profile_preferences_operations.py | 576 ++++++++----- .../mgmt/automanage/operations/_operations.py | 98 ++- 26 files changed, 2409 insertions(+), 2247 deletions(-) create mode 100644 sdk/automanage/azure-mgmt-automanage/_meta.json create mode 100644 sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_patch.py create mode 100644 sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_vendor.py create mode 100644 sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/_automanage_client.py delete mode 100644 sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/_automanage_client_async.py rename sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/{_configuration_async.py => _configuration.py} (86%) create mode 100644 sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/_patch.py rename sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/{operations_async => operations}/__init__.py (66%) rename sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/{operations_async/_accounts_operations_async.py => operations/_accounts_operations.py} (55%) rename sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/{operations_async/_configuration_profile_assignments_operations_async.py => operations/_configuration_profile_assignments_operations.py} (58%) rename sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/{operations_async/_configuration_profile_preferences_operations_async.py => operations/_configuration_profile_preferences_operations.py} (54%) rename sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/{operations_async/_operations_async.py => operations/_operations.py} (67%) delete mode 100644 sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/_models.py diff --git a/sdk/automanage/azure-mgmt-automanage/_meta.json b/sdk/automanage/azure-mgmt-automanage/_meta.json new file mode 100644 index 0000000000000..4f45a189261ed --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/_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/automanage/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/automanage/resource-manager/readme.md" +} \ No newline at end of file diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/__init__.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/__init__.py index e9400926d2ea4..0e852bdc349c3 100644 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/__init__.py +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['AutomanageClient'] -try: - from ._patch import patch_sdk - 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/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_automanage_client.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_automanage_client.py index a35de58538063..03832b0af563b 100644 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_automanage_client.py +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_automanage_client.py @@ -6,69 +6,89 @@ # 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 AutomanageClientConfiguration +from .operations import AccountsOperations, ConfigurationProfileAssignmentsOperations, ConfigurationProfilePreferencesOperations, Operations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential -from ._configuration import AutomanageClientConfiguration -from .operations import AccountsOperations -from .operations import ConfigurationProfileAssignmentsOperations -from .operations import ConfigurationProfilePreferencesOperations -from .operations import Operations -from . import models - - -class AutomanageClient(object): +class AutomanageClient: """Automanage Client. :ivar accounts: AccountsOperations operations :vartype accounts: automanage_client.operations.AccountsOperations :ivar configuration_profile_assignments: ConfigurationProfileAssignmentsOperations operations - :vartype configuration_profile_assignments: automanage_client.operations.ConfigurationProfileAssignmentsOperations + :vartype configuration_profile_assignments: + automanage_client.operations.ConfigurationProfileAssignmentsOperations :ivar configuration_profile_preferences: ConfigurationProfilePreferencesOperations operations - :vartype configuration_profile_preferences: automanage_client.operations.ConfigurationProfilePreferencesOperations + :vartype configuration_profile_preferences: + automanage_client.operations.ConfigurationProfilePreferencesOperations :ivar operations: Operations operations :vartype operations: automanage_client.operations.Operations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = AutomanageClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = AutomanageClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.accounts = AccountsOperations(self._client, self._config, self._serialize, self._deserialize) + self.configuration_profile_assignments = ConfigurationProfileAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.configuration_profile_preferences = ConfigurationProfilePreferencesOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(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.accounts = AccountsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.configuration_profile_assignments = ConfigurationProfileAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.configuration_profile_preferences = ConfigurationProfilePreferencesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - 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/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_configuration.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_configuration.py index 1c10217f4124b..ed8aa50b0ac35 100644 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_configuration.py +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_configuration.py @@ -6,17 +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 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 @@ -34,22 +33,20 @@ class AutomanageClientConfiguration(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(AutomanageClientConfiguration, 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(AutomanageClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id self.api_version = "2020-06-30-preview" - self.credential_scopes = ['https://management.azure.com/.default'] - self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-automanage/{}'.format(VERSION)) self._configure(**kwargs) @@ -62,9 +59,10 @@ def _configure( self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) 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/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_metadata.json b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_metadata.json index 3ce69338c0907..6fd31a2e658c8 100644 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_metadata.json +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_metadata.json @@ -4,32 +4,39 @@ "client": { "name": "AutomanageClient", "filename": "_automanage_client", - "description": "Automanage Client." + "description": "Automanage Client.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_lro_operations": true, + "client_side_validation": false, + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AutomanageClientConfiguration\"]}}, \"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\": [\"AutomanageClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { - "sync_method": { + "sync": { "credential": { - "method_signature": "credential, # type: \"TokenCredential\"", + "signature": "credential, # type: \"TokenCredential\"", "description": "Credential needed for the client to connect to Azure.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "method_signature": "subscription_id, # type: str", + "signature": "subscription_id, # type: str", "description": "The ID of the target subscription.", "docstring_type": "str", "required": true } }, - "async_method": { + "async": { "credential": { - "method_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": { - "method_signature": "subscription_id, # type: str", + "signature": "subscription_id: str,", "description": "The ID of the target subscription.", "docstring_type": "str", "required": true @@ -37,20 +44,62 @@ }, "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_scopes": ["https://management.azure.com/.default"], + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "accounts": "AccountsOperations", "configuration_profile_assignments": "ConfigurationProfileAssignmentsOperations", "configuration_profile_preferences": "ConfigurationProfilePreferencesOperations", "operations": "Operations" - }, - "operation_mixins": { - }, - "sync_imports": "None", - "async_imports": "None" + } } \ No newline at end of file diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_patch.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_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/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_vendor.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_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/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_version.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_version.py index dfa6ee022f154..95e84007ac637 100644 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_version.py +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0b2" +VERSION = "0.1.0-preview" diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/__init__.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/__init__.py index a724e312f9bb2..897a509976737 100644 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/__init__.py +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/__init__.py @@ -6,5 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._automanage_client_async import AutomanageClient +from ._automanage_client import AutomanageClient __all__ = ['AutomanageClient'] + +# `._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/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/_automanage_client.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/_automanage_client.py new file mode 100644 index 0000000000000..018deb9393251 --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/_automanage_client.py @@ -0,0 +1,101 @@ +# 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 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 AutomanageClientConfiguration +from .operations import AccountsOperations, ConfigurationProfileAssignmentsOperations, ConfigurationProfilePreferencesOperations, Operations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +class AutomanageClient: + """Automanage Client. + + :ivar accounts: AccountsOperations operations + :vartype accounts: automanage_client.aio.operations.AccountsOperations + :ivar configuration_profile_assignments: ConfigurationProfileAssignmentsOperations operations + :vartype configuration_profile_assignments: + automanage_client.aio.operations.ConfigurationProfileAssignmentsOperations + :ivar configuration_profile_preferences: ConfigurationProfilePreferencesOperations operations + :vartype configuration_profile_preferences: + automanage_client.aio.operations.ConfigurationProfilePreferencesOperations + :ivar operations: Operations operations + :vartype operations: automanage_client.aio.operations.Operations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = AutomanageClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.accounts = AccountsOperations(self._client, self._config, self._serialize, self._deserialize) + self.configuration_profile_assignments = ConfigurationProfileAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.configuration_profile_preferences = ConfigurationProfilePreferencesOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(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 + """ + + 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() + + async def __aenter__(self) -> "AutomanageClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/_automanage_client_async.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/_automanage_client_async.py deleted file mode 100644 index e8d0de459d55d..0000000000000 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/_automanage_client_async.py +++ /dev/null @@ -1,78 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from typing import Any, Optional, TYPE_CHECKING - -from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - -from ._configuration_async import AutomanageClientConfiguration -from .operations_async import AccountsOperations -from .operations_async import ConfigurationProfileAssignmentsOperations -from .operations_async import ConfigurationProfilePreferencesOperations -from .operations_async import Operations -from .. import models - - -class AutomanageClient(object): - """Automanage Client. - - :ivar accounts: AccountsOperations operations - :vartype accounts: automanage_client.aio.operations_async.AccountsOperations - :ivar configuration_profile_assignments: ConfigurationProfileAssignmentsOperations operations - :vartype configuration_profile_assignments: automanage_client.aio.operations_async.ConfigurationProfileAssignmentsOperations - :ivar configuration_profile_preferences: ConfigurationProfilePreferencesOperations operations - :vartype configuration_profile_preferences: automanage_client.aio.operations_async.ConfigurationProfilePreferencesOperations - :ivar operations: Operations operations - :vartype operations: automanage_client.aio.operations_async.Operations - :param credential: Credential needed for the client to connect to Azure. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. - :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: Optional[str] = None, - **kwargs: Any - ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = AutomanageClientConfiguration(credential, subscription_id, **kwargs) - self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) - - self.accounts = AccountsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.configuration_profile_assignments = ConfigurationProfileAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.configuration_profile_preferences = ConfigurationProfilePreferencesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "AutomanageClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/_configuration_async.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/_configuration.py similarity index 86% rename from sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/_configuration_async.py rename to sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/_configuration.py index 7c433b80ceb52..1b69560f2650b 100644 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/_configuration_async.py +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/_configuration.py @@ -10,6 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -36,17 +37,16 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(AutomanageClientConfiguration, 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(AutomanageClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id self.api_version = "2020-06-30-preview" - self.credential_scopes = ['https://management.azure.com/.default'] - self.credential_scopes.extend(kwargs.pop('credential_scopes', [])) + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-automanage/{}'.format(VERSION)) self._configure(**kwargs) @@ -58,9 +58,10 @@ def _configure( self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) 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/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/_patch.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/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/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations_async/__init__.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/__init__.py similarity index 66% rename from sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations_async/__init__.py rename to sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/__init__.py index 6f24ade3b7394..9520dfd09e18a 100644 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations_async/__init__.py +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/__init__.py @@ -6,10 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._accounts_operations_async import AccountsOperations -from ._configuration_profile_assignments_operations_async import ConfigurationProfileAssignmentsOperations -from ._configuration_profile_preferences_operations_async import ConfigurationProfilePreferencesOperations -from ._operations_async import Operations +from ._accounts_operations import AccountsOperations +from ._configuration_profile_assignments_operations import ConfigurationProfileAssignmentsOperations +from ._configuration_profile_preferences_operations import ConfigurationProfilePreferencesOperations +from ._operations import Operations __all__ = [ 'AccountsOperations', diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations_async/_accounts_operations_async.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_accounts_operations.py similarity index 55% rename from sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations_async/_accounts_operations_async.py rename to sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_accounts_operations.py index f589ce7b5e540..31948dde17209 100644 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations_async/_accounts_operations_async.py +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_accounts_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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 - +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._accounts_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -33,7 +38,7 @@ class AccountsOperations: :param deserializer: An object model deserializer. """ - models = models + models = _models def __init__(self, client, config, serializer, deserializer) -> None: self._client = client @@ -41,13 +46,14 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create_or_update( self, account_name: str, resource_group_name: str, - parameters: "models.Account", - **kwargs - ) -> "models.Account": + parameters: "_models.Account", + **kwargs: Any + ) -> "_models.Account": """Creates an Automanage Account. :param account_name: Name of the Automanage account. @@ -61,41 +67,33 @@ async def create_or_update( :rtype: ~automanage_client.models.Account :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.Account"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'accountName': self._serialize.url("account_name", account_name, 'str'), - 'subscriptionId': self._serialize.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\._\(\)]+$'), + cls = kwargs.pop('cls', None) # type: ClsType["_models.Account"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {})) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = 'application/json' + _json = self._serialize.body(parameters, 'Account') - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Account') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + request = build_create_or_update_request( + account_name=account_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -108,14 +106,17 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/accounts/{accountName}'} # type: ignore + + @distributed_trace_async async def get( self, account_name: str, resource_group_name: str, - **kwargs - ) -> "models.Account": + **kwargs: Any + ) -> "_models.Account": """Get information about a Automanage account. :param account_name: The Automanage account name. @@ -127,35 +128,28 @@ async def get( :rtype: ~automanage_client.models.Account :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.Account"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'accountName': self._serialize.url("account_name", account_name, 'str'), - 'subscriptionId': self._serialize.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\._\(\)]+$'), + cls = kwargs.pop('cls', None) # type: ClsType["_models.Account"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop('error_map', {})) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' + + request = build_get_request( + account_name=account_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Account', pipeline_response) @@ -164,13 +158,16 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/accounts/{accountName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, account_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete a Automanage account. @@ -184,33 +181,27 @@ async def delete( :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'accountName': self._serialize.url("account_name", account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop('error_map', {})) - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -218,13 +209,15 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/accounts/{accountName}'} # type: ignore + + @distributed_trace_async async def update( self, account_name: str, resource_group_name: str, - parameters: "models.AccountUpdate", - **kwargs - ) -> "models.Account": + parameters: "_models.AccountUpdate", + **kwargs: Any + ) -> "_models.Account": """Updates an Automanage Account. :param account_name: Name of the Automanage account. @@ -238,41 +231,33 @@ async def update( :rtype: ~automanage_client.models.Account :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.Account"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'accountName': self._serialize.url("account_name", account_name, 'str'), - 'subscriptionId': self._serialize.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\._\(\)]+$'), + cls = kwargs.pop('cls', None) # type: ClsType["_models.Account"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {})) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = 'application/json' + _json = self._serialize.body(parameters, 'AccountUpdate') - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'AccountUpdate') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + request = build_update_request( + account_name=account_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Account', pipeline_response) @@ -281,13 +266,16 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/accounts/{accountName}'} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name: str, - **kwargs - ) -> AsyncIterable["models.AccountList"]: + **kwargs: Any + ) -> AsyncIterable["_models.AccountList"]: """Retrieve a list of Automanage accounts within a given resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -297,37 +285,36 @@ def list_by_resource_group( :rtype: ~azure.core.async_paging.AsyncItemPaged[~automanage_client.models.AccountList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.AccountList"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccountList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, 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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AccountList', pipeline_response) + deserialized = self._deserialize("AccountList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -340,21 +327,23 @@ 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_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/accounts'} # type: ignore + @distributed_trace def list_by_subscription( self, - **kwargs - ) -> AsyncIterable["models.AccountList"]: + **kwargs: Any + ) -> AsyncIterable["_models.AccountList"]: """Retrieve a list of Automanage accounts within a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -362,36 +351,34 @@ def list_by_subscription( :rtype: ~azure.core.async_paging.AsyncItemPaged[~automanage_client.models.AccountList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.AccountList"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccountList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AccountList', pipeline_response) + deserialized = self._deserialize("AccountList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -404,12 +391,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/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations_async/_configuration_profile_assignments_operations_async.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_configuration_profile_assignments_operations.py similarity index 58% rename from sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations_async/_configuration_profile_assignments_operations_async.py rename to sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_configuration_profile_assignments_operations.py index 4075430759176..ba88f6b7f945a 100644 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations_async/_configuration_profile_assignments_operations_async.py +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_configuration_profile_assignments_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling -from ... import models - +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._configuration_profile_assignments_operations import build_create_or_update_request_initial, build_delete_request, build_get_request, build_list_by_subscription_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -35,7 +40,7 @@ class ConfigurationProfileAssignmentsOperations: :param deserializer: An object model deserializer. """ - models = models + models = _models def __init__(self, client, config, serializer, deserializer) -> None: self._client = client @@ -48,46 +53,37 @@ async def _create_or_update_initial( configuration_profile_assignment_name: str, resource_group_name: str, vm_name: str, - parameters: "models.ConfigurationProfileAssignment", - **kwargs - ) -> "models.ConfigurationProfileAssignment": - cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationProfileAssignment"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'configurationProfileAssignmentName': self._serialize.url("configuration_profile_assignment_name", configuration_profile_assignment_name, 'str'), - 'subscriptionId': self._serialize.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\._\(\)]+$'), - 'vmName': self._serialize.url("vm_name", vm_name, 'str'), + parameters: "_models.ConfigurationProfileAssignment", + **kwargs: Any + ) -> "_models.ConfigurationProfileAssignment": + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfileAssignment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {})) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = 'application/json' + _json = self._serialize.body(parameters, 'ConfigurationProfileAssignment') - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ConfigurationProfileAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + request = build_create_or_update_request_initial( + configuration_profile_assignment_name=configuration_profile_assignment_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vm_name=vm_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('ConfigurationProfileAssignment', pipeline_response) @@ -99,40 +95,48 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, configuration_profile_assignment_name: str, resource_group_name: str, vm_name: str, - parameters: "models.ConfigurationProfileAssignment", - **kwargs - ) -> AsyncLROPoller["models.ConfigurationProfileAssignment"]: + parameters: "_models.ConfigurationProfileAssignment", + **kwargs: Any + ) -> AsyncLROPoller["_models.ConfigurationProfileAssignment"]: """Creates an association between a VM and Automanage configuration profile. :param configuration_profile_assignment_name: Name of the configuration profile assignment. - Only default is supported. + Only default is supported. :type configuration_profile_assignment_name: str :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param vm_name: The name of the virtual machine. :type vm_name: str :param parameters: Parameters supplied to the create or update configuration profile - assignment. + assignment. :type parameters: ~automanage_client.models.ConfigurationProfileAssignment :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either ConfigurationProfileAssignment or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~automanage_client.models.ConfigurationProfileAssignment] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConfigurationProfileAssignment or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~automanage_client.models.ConfigurationProfileAssignment] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationProfileAssignment"] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfileAssignment"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval @@ -144,21 +148,21 @@ async def begin_create_or_update( resource_group_name=resource_group_name, vm_name=vm_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ConfigurationProfileAssignment', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -170,15 +174,17 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, configuration_profile_assignment_name: str, vm_name: str, - **kwargs - ) -> "models.ConfigurationProfileAssignment": + **kwargs: Any + ) -> "_models.ConfigurationProfileAssignment": """Get information about a configuration profile assignment. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -192,36 +198,29 @@ async def get( :rtype: ~automanage_client.models.ConfigurationProfileAssignment :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationProfileAssignment"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'configurationProfileAssignmentName': self._serialize.url("configuration_profile_assignment_name", configuration_profile_assignment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'vmName': self._serialize.url("vm_name", vm_name, 'str'), + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfileAssignment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop('error_map', {})) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' + + request = build_get_request( + resource_group_name=resource_group_name, + configuration_profile_assignment_name=configuration_profile_assignment_name, + subscription_id=self._config.subscription_id, + vm_name=vm_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ConfigurationProfileAssignment', pipeline_response) @@ -230,14 +229,17 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, configuration_profile_assignment_name: str, vm_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete a configuration profile assignment. @@ -253,34 +255,28 @@ async def delete( :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'configurationProfileAssignmentName': self._serialize.url("configuration_profile_assignment_name", configuration_profile_assignment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'vmName': self._serialize.url("vm_name", vm_name, 'str'), + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop('error_map', {})) - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + resource_group_name=resource_group_name, + configuration_profile_assignment_name=configuration_profile_assignment_name, + subscription_id=self._config.subscription_id, + vm_name=vm_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -288,51 +284,54 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}'} # type: ignore + + @distributed_trace def list( self, resource_group_name: str, - **kwargs - ) -> AsyncIterable["models.ConfigurationProfileAssignmentList"]: + **kwargs: Any + ) -> AsyncIterable["_models.ConfigurationProfileAssignmentList"]: """Get list of configuration profile assignments. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ConfigurationProfileAssignmentList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~automanage_client.models.ConfigurationProfileAssignmentList] + :return: An iterator like instance of either ConfigurationProfileAssignmentList or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~automanage_client.models.ConfigurationProfileAssignmentList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationProfileAssignmentList"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfileAssignmentList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ConfigurationProfileAssignmentList', pipeline_response) + deserialized = self._deserialize("ConfigurationProfileAssignmentList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -345,58 +344,60 @@ 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.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfileAssignments'} # type: ignore + @distributed_trace def list_by_subscription( self, - **kwargs - ) -> AsyncIterable["models.ConfigurationProfileAssignmentList"]: + **kwargs: Any + ) -> AsyncIterable["_models.ConfigurationProfileAssignmentList"]: """Get list of configuration profile assignments under a given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ConfigurationProfileAssignmentList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~automanage_client.models.ConfigurationProfileAssignmentList] + :return: An iterator like instance of either ConfigurationProfileAssignmentList or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~automanage_client.models.ConfigurationProfileAssignmentList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationProfileAssignmentList"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfileAssignmentList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ConfigurationProfileAssignmentList', pipeline_response) + deserialized = self._deserialize("ConfigurationProfileAssignmentList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -409,12 +410,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/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations_async/_configuration_profile_preferences_operations_async.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_configuration_profile_preferences_operations.py similarity index 54% rename from sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations_async/_configuration_profile_preferences_operations_async.py rename to sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_configuration_profile_preferences_operations.py index f4e7c2bf76db8..17f4c1dcec893 100644 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations_async/_configuration_profile_preferences_operations_async.py +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_configuration_profile_preferences_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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 - +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._configuration_profile_preferences_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -33,7 +38,7 @@ class ConfigurationProfilePreferencesOperations: :param deserializer: An object model deserializer. """ - models = models + models = _models def __init__(self, client, config, serializer, deserializer) -> None: self._client = client @@ -41,13 +46,14 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create_or_update( self, configuration_profile_preference_name: str, resource_group_name: str, - parameters: "models.ConfigurationProfilePreference", - **kwargs - ) -> "models.ConfigurationProfilePreference": + parameters: "_models.ConfigurationProfilePreference", + **kwargs: Any + ) -> "_models.ConfigurationProfilePreference": """Creates a configuration profile preference. :param configuration_profile_preference_name: Name of the configuration profile preference. @@ -61,41 +67,33 @@ async def create_or_update( :rtype: ~automanage_client.models.ConfigurationProfilePreference :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationProfilePreference"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'configurationProfilePreferenceName': self._serialize.url("configuration_profile_preference_name", configuration_profile_preference_name, 'str'), - 'subscriptionId': self._serialize.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\._\(\)]+$'), + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfilePreference"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {})) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = 'application/json' + _json = self._serialize.body(parameters, 'ConfigurationProfilePreference') - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ConfigurationProfilePreference') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + request = build_create_or_update_request( + configuration_profile_preference_name=configuration_profile_preference_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -108,14 +106,17 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfilePreferences/{configurationProfilePreferenceName}'} # type: ignore + + @distributed_trace_async async def get( self, configuration_profile_preference_name: str, resource_group_name: str, - **kwargs - ) -> "models.ConfigurationProfilePreference": + **kwargs: Any + ) -> "_models.ConfigurationProfilePreference": """Get information about a configuration profile preference. :param configuration_profile_preference_name: The configuration profile preference name. @@ -127,35 +128,28 @@ async def get( :rtype: ~automanage_client.models.ConfigurationProfilePreference :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationProfilePreference"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'configurationProfilePreferenceName': self._serialize.url("configuration_profile_preference_name", configuration_profile_preference_name, 'str'), - 'subscriptionId': self._serialize.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\._\(\)]+$'), + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfilePreference"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop('error_map', {})) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' + + request = build_get_request( + configuration_profile_preference_name=configuration_profile_preference_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ConfigurationProfilePreference', pipeline_response) @@ -164,13 +158,16 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfilePreferences/{configurationProfilePreferenceName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, configuration_profile_preference_name: str, - **kwargs + **kwargs: Any ) -> None: """Delete a configuration profile preference. @@ -184,33 +181,27 @@ async def delete( :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'configurationProfilePreferenceName': self._serialize.url("configuration_profile_preference_name", configuration_profile_preference_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop('error_map', {})) - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + resource_group_name=resource_group_name, + configuration_profile_preference_name=configuration_profile_preference_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -218,13 +209,15 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfilePreferences/{configurationProfilePreferenceName}'} # type: ignore + + @distributed_trace_async async def update( self, configuration_profile_preference_name: str, resource_group_name: str, - parameters: "models.ConfigurationProfilePreferenceUpdate", - **kwargs - ) -> "models.ConfigurationProfilePreference": + parameters: "_models.ConfigurationProfilePreferenceUpdate", + **kwargs: Any + ) -> "_models.ConfigurationProfilePreference": """Updates a configuration profile preference. :param configuration_profile_preference_name: Name of the configuration profile preference. @@ -238,41 +231,33 @@ async def update( :rtype: ~automanage_client.models.ConfigurationProfilePreference :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationProfilePreference"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'configurationProfilePreferenceName': self._serialize.url("configuration_profile_preference_name", configuration_profile_preference_name, 'str'), - 'subscriptionId': self._serialize.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\._\(\)]+$'), + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfilePreference"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {})) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = 'application/json' + _json = self._serialize.body(parameters, 'ConfigurationProfilePreferenceUpdate') - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ConfigurationProfilePreferenceUpdate') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + request = build_update_request( + configuration_profile_preference_name=configuration_profile_preference_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ConfigurationProfilePreference', pipeline_response) @@ -281,53 +266,57 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfilePreferences/{configurationProfilePreferenceName}'} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name: str, - **kwargs - ) -> AsyncIterable["models.ConfigurationProfilePreferenceList"]: + **kwargs: Any + ) -> AsyncIterable["_models.ConfigurationProfilePreferenceList"]: """Retrieve a list of configuration profile preferences within a given resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ConfigurationProfilePreferenceList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~automanage_client.models.ConfigurationProfilePreferenceList] + :return: An iterator like instance of either ConfigurationProfilePreferenceList or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~automanage_client.models.ConfigurationProfilePreferenceList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationProfilePreferenceList"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfilePreferenceList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, 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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ConfigurationProfilePreferenceList', pipeline_response) + deserialized = self._deserialize("ConfigurationProfilePreferenceList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -340,58 +329,60 @@ 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_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfilePreferences'} # type: ignore + @distributed_trace def list_by_subscription( self, - **kwargs - ) -> AsyncIterable["models.ConfigurationProfilePreferenceList"]: + **kwargs: Any + ) -> AsyncIterable["_models.ConfigurationProfilePreferenceList"]: """Retrieve a list of configuration profile preferences within a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ConfigurationProfilePreferenceList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~automanage_client.models.ConfigurationProfilePreferenceList] + :return: An iterator like instance of either ConfigurationProfilePreferenceList or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~automanage_client.models.ConfigurationProfilePreferenceList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationProfilePreferenceList"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfilePreferenceList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ConfigurationProfilePreferenceList', pipeline_response) + deserialized = self._deserialize("ConfigurationProfilePreferenceList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -404,12 +395,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/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations_async/_operations_async.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_operations.py similarity index 67% rename from sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations_async/_operations_async.py rename to sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations/_operations.py index a584b47e9553b..26c1fcac46190 100644 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/aio/operations_async/_operations_async.py +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/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 HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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 - +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]] @@ -33,7 +38,7 @@ class Operations: :param deserializer: An object model deserializer. """ - models = models + models = _models def __init__(self, client, config, serializer, deserializer) -> None: self._client = client @@ -41,10 +46,11 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs - ) -> AsyncIterable["models.OperationList"]: + **kwargs: Any + ) -> AsyncIterable["_models.OperationList"]: """Lists all of the available Automanage REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -52,32 +58,32 @@ def list( :rtype: ~azure.core.async_paging.AsyncItemPaged[~automanage_client.models.OperationList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.OperationList"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationList', pipeline_response) + deserialized = self._deserialize("OperationList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -90,12 +96,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/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/__init__.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/__init__.py index 1bce4240a9488..06c5280a6bfe1 100644 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/__init__.py +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/__init__.py @@ -6,61 +6,36 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import Account - from ._models_py3 import AccountIdentity - from ._models_py3 import AccountList - from ._models_py3 import AccountUpdate - from ._models_py3 import ConfigurationProfileAssignment - from ._models_py3 import ConfigurationProfileAssignmentCompliance - from ._models_py3 import ConfigurationProfileAssignmentList - from ._models_py3 import ConfigurationProfileAssignmentProperties - from ._models_py3 import ConfigurationProfilePreference - from ._models_py3 import ConfigurationProfilePreferenceAntiMalware - from ._models_py3 import ConfigurationProfilePreferenceList - from ._models_py3 import ConfigurationProfilePreferenceProperties - from ._models_py3 import ConfigurationProfilePreferenceUpdate - from ._models_py3 import ConfigurationProfilePreferenceVmBackup - from ._models_py3 import ErrorAdditionalInfo - from ._models_py3 import ErrorResponse - from ._models_py3 import ErrorResponseError - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationList - from ._models_py3 import ProxyResource - from ._models_py3 import Resource - from ._models_py3 import TrackedResource - from ._models_py3 import UpdateResource -except (SyntaxError, ImportError): - from ._models import Account # type: ignore - from ._models import AccountIdentity # type: ignore - from ._models import AccountList # type: ignore - from ._models import AccountUpdate # type: ignore - from ._models import ConfigurationProfileAssignment # type: ignore - from ._models import ConfigurationProfileAssignmentCompliance # type: ignore - from ._models import ConfigurationProfileAssignmentList # type: ignore - from ._models import ConfigurationProfileAssignmentProperties # type: ignore - from ._models import ConfigurationProfilePreference # type: ignore - from ._models import ConfigurationProfilePreferenceAntiMalware # type: ignore - from ._models import ConfigurationProfilePreferenceList # type: ignore - from ._models import ConfigurationProfilePreferenceProperties # type: ignore - from ._models import ConfigurationProfilePreferenceUpdate # type: ignore - from ._models import ConfigurationProfilePreferenceVmBackup # type: ignore - from ._models import ErrorAdditionalInfo # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import ErrorResponseError # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationList # type: ignore - from ._models import ProxyResource # type: ignore - from ._models import Resource # type: ignore - from ._models import TrackedResource # type: ignore - from ._models import UpdateResource # type: ignore +from ._models_py3 import Account +from ._models_py3 import AccountIdentity +from ._models_py3 import AccountList +from ._models_py3 import AccountUpdate +from ._models_py3 import ConfigurationProfileAssignment +from ._models_py3 import ConfigurationProfileAssignmentCompliance +from ._models_py3 import ConfigurationProfileAssignmentList +from ._models_py3 import ConfigurationProfileAssignmentProperties +from ._models_py3 import ConfigurationProfilePreference +from ._models_py3 import ConfigurationProfilePreferenceAntiMalware +from ._models_py3 import ConfigurationProfilePreferenceList +from ._models_py3 import ConfigurationProfilePreferenceProperties +from ._models_py3 import ConfigurationProfilePreferenceUpdate +from ._models_py3 import ConfigurationProfilePreferenceVmBackup +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationList +from ._models_py3 import ProxyResource +from ._models_py3 import Resource +from ._models_py3 import TrackedResource +from ._models_py3 import UpdateResource + from ._automanage_client_enums import ( ConfigurationProfile, EnableRealTimeProtection, - ProvisioningStatus, + ProvisioningState, ResourceIdentityType, RunScheduledScan, ScanType, @@ -83,8 +58,8 @@ 'ConfigurationProfilePreferenceUpdate', 'ConfigurationProfilePreferenceVmBackup', 'ErrorAdditionalInfo', + 'ErrorDetail', 'ErrorResponse', - 'ErrorResponseError', 'Operation', 'OperationDisplay', 'OperationList', @@ -94,7 +69,7 @@ 'UpdateResource', 'ConfigurationProfile', 'EnableRealTimeProtection', - 'ProvisioningStatus', + 'ProvisioningState', 'ResourceIdentityType', 'RunScheduledScan', 'ScanType', diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/_automanage_client_enums.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/_automanage_client_enums.py index 79304db864cda..4f170200383b0 100644 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/_automanage_client_enums.py +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/_automanage_client_enums.py @@ -7,55 +7,58 @@ # -------------------------------------------------------------------------- from enum import Enum +from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class ConfigurationProfile(str, Enum): + +class ConfigurationProfile(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """A value indicating configuration profile. """ - azure_virtual_machine_best_practices_dev_test = "Azure virtual machine best practices – Dev/Test" - azure_virtual_machine_best_practices_production = "Azure virtual machine best practices – Production" + AZURE_VIRTUAL_MACHINE_BEST_PRACTICES_DEV_TEST = "Azure virtual machine best practices – Dev/Test" + AZURE_VIRTUAL_MACHINE_BEST_PRACTICES_PRODUCTION = "Azure virtual machine best practices – Production" -class EnableRealTimeProtection(str, Enum): +class EnableRealTimeProtection(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Enables or disables Real Time Protection """ - true = "True" - false = "False" + TRUE = "True" + FALSE = "False" -class ProvisioningStatus(str, Enum): +class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The state of onboarding, which only appears in the response. """ - succeeded = "Succeeded" - failed = "Failed" - created = "Created" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + CREATED = "Created" -class ResourceIdentityType(str, Enum): +class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of identity used for the Automanage account. Currently, the only supported type is 'SystemAssigned', which implicitly creates an identity. """ - system_assigned = "SystemAssigned" - none = "None" + SYSTEM_ASSIGNED = "SystemAssigned" + NONE = "None" -class RunScheduledScan(str, Enum): +class RunScheduledScan(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Enables or disables a periodic scan for antimalware """ - true = "True" - false = "False" + TRUE = "True" + FALSE = "False" -class ScanType(str, Enum): +class ScanType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Type of scheduled scan """ - quick = "Quick" - full = "Full" + QUICK = "Quick" + FULL = "Full" -class UpdateStatus(str, Enum): +class UpdateStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The state of compliance, which only appears in the response. """ - succeeded = "Succeeded" - failed = "Failed" - created = "Created" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + CREATED = "Created" diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/_models.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/_models.py deleted file mode 100644 index 4a02132654d49..0000000000000 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/_models.py +++ /dev/null @@ -1,760 +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): - """Resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource Id for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. Ex- 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 TrackedResource(Resource): - """The resource model definition for a ARM tracked top level resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :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. Ex- Microsoft.Compute/virtualMachines or - Microsoft.Storage/storageAccounts. - :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TrackedResource, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.location = kwargs['location'] - - -class Account(TrackedResource): - """Definition of the Automanage account. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Fully qualified resource Id for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or - Microsoft.Storage/storageAccounts. - :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - :param identity: The identity of the Automanage account. - :type identity: ~automanage_client.models.AccountIdentity - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'AccountIdentity'}, - } - - def __init__( - self, - **kwargs - ): - super(Account, self).__init__(**kwargs) - self.identity = kwargs.get('identity', None) - - -class AccountIdentity(msrest.serialization.Model): - """Identity for the Automanage account. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: The principal id of Automanage account identity. - :vartype principal_id: str - :ivar tenant_id: The tenant id associated with the Automanage account. - :vartype tenant_id: str - :param type: The type of identity used for the Automanage account. Currently, the only - supported type is 'SystemAssigned', which implicitly creates an identity. Possible values - include: "SystemAssigned", "None". - :type type: str or ~automanage_client.models.ResourceIdentityType - """ - - _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - } - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AccountIdentity, self).__init__(**kwargs) - self.principal_id = None - self.tenant_id = None - self.type = kwargs.get('type', None) - - -class AccountList(msrest.serialization.Model): - """The response of the list Account operation. - - :param value: Result of the list Account operation. - :type value: list[~automanage_client.models.Account] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Account]'}, - } - - def __init__( - self, - **kwargs - ): - super(AccountList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class UpdateResource(msrest.serialization.Model): - """Represents an update resource. - - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(UpdateResource, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - - -class AccountUpdate(UpdateResource): - """Definition of the Automanage account. - - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param identity: The identity of the Automanage account. - :type identity: ~automanage_client.models.AccountIdentity - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'AccountIdentity'}, - } - - def __init__( - self, - **kwargs - ): - super(AccountUpdate, self).__init__(**kwargs) - self.identity = kwargs.get('identity', None) - - -class ConfigurationProfileAssignment(Resource): - """Configuration profile assignment is an association between a VM and automanage profile configuration. - - 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. Ex- Microsoft.Compute/virtualMachines or - Microsoft.Storage/storageAccounts. - :vartype type: str - :param properties: Properties of the configuration profile assignment. - :type properties: ~automanage_client.models.ConfigurationProfileAssignmentProperties - """ - - _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': 'ConfigurationProfileAssignmentProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(ConfigurationProfileAssignment, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - - -class ConfigurationProfileAssignmentCompliance(msrest.serialization.Model): - """The compliance status for the configuration profile assignment. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar update_status: The state of compliance, which only appears in the response. Possible - values include: "Succeeded", "Failed", "Created". - :vartype update_status: str or ~automanage_client.models.UpdateStatus - """ - - _validation = { - 'update_status': {'readonly': True}, - } - - _attribute_map = { - 'update_status': {'key': 'updateStatus', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ConfigurationProfileAssignmentCompliance, self).__init__(**kwargs) - self.update_status = None - - -class ConfigurationProfileAssignmentList(msrest.serialization.Model): - """The response of the list configuration profile assignment operation. - - :param value: Result of the list configuration profile assignment operation. - :type value: list[~automanage_client.models.ConfigurationProfileAssignment] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ConfigurationProfileAssignment]'}, - } - - def __init__( - self, - **kwargs - ): - super(ConfigurationProfileAssignmentList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class ConfigurationProfileAssignmentProperties(msrest.serialization.Model): - """Automanage configuration profile assignment properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param configuration_profile: A value indicating configuration profile. Possible values - include: "Azure virtual machine best practices – Dev/Test", "Azure virtual machine best - practices – Production". - :type configuration_profile: str or ~automanage_client.models.ConfigurationProfile - :param target_id: The target VM resource URI. - :type target_id: str - :param account_id: The Automanage account ARM Resource URI. - :type account_id: str - :param configuration_profile_preference_id: The configuration profile custom preferences ARM - resource URI. - :type configuration_profile_preference_id: str - :ivar provisioning_status: The state of onboarding, which only appears in the response. - Possible values include: "Succeeded", "Failed", "Created". - :vartype provisioning_status: str or ~automanage_client.models.ProvisioningStatus - :param compliance: The configuration setting for the configuration profile. - :type compliance: ~automanage_client.models.ConfigurationProfileAssignmentCompliance - """ - - _validation = { - 'provisioning_status': {'readonly': True}, - } - - _attribute_map = { - 'configuration_profile': {'key': 'configurationProfile', 'type': 'str'}, - 'target_id': {'key': 'targetId', 'type': 'str'}, - 'account_id': {'key': 'accountId', 'type': 'str'}, - 'configuration_profile_preference_id': {'key': 'configurationProfilePreferenceId', 'type': 'str'}, - 'provisioning_status': {'key': 'provisioningStatus', 'type': 'str'}, - 'compliance': {'key': 'compliance', 'type': 'ConfigurationProfileAssignmentCompliance'}, - } - - def __init__( - self, - **kwargs - ): - super(ConfigurationProfileAssignmentProperties, self).__init__(**kwargs) - self.configuration_profile = kwargs.get('configuration_profile', None) - self.target_id = kwargs.get('target_id', None) - self.account_id = kwargs.get('account_id', None) - self.configuration_profile_preference_id = kwargs.get('configuration_profile_preference_id', None) - self.provisioning_status = None - self.compliance = kwargs.get('compliance', None) - - -class ConfigurationProfilePreference(TrackedResource): - """Definition of the configuration profile preference. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Fully qualified resource Id for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. Ex- Microsoft.Compute/virtualMachines or - Microsoft.Storage/storageAccounts. - :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - :param properties: Properties of the configuration profile preference. - :type properties: ~automanage_client.models.ConfigurationProfilePreferenceProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'ConfigurationProfilePreferenceProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(ConfigurationProfilePreference, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - - -class ConfigurationProfilePreferenceAntiMalware(msrest.serialization.Model): - """Automanage configuration profile Antimalware preferences. - - :param enable_real_time_protection: Enables or disables Real Time Protection. Possible values - include: "True", "False". - :type enable_real_time_protection: str or ~automanage_client.models.EnableRealTimeProtection - :param exclusions: Extensions, Paths and Processes that must be excluded from scan. - :type exclusions: object - :param run_scheduled_scan: Enables or disables a periodic scan for antimalware. Possible values - include: "True", "False". - :type run_scheduled_scan: str or ~automanage_client.models.RunScheduledScan - :param scan_type: Type of scheduled scan. Possible values include: "Quick", "Full". - :type scan_type: str or ~automanage_client.models.ScanType - :param scan_day: Schedule scan settings day. - :type scan_day: str - :param scan_time_in_minutes: Schedule scan settings time. - :type scan_time_in_minutes: str - """ - - _attribute_map = { - 'enable_real_time_protection': {'key': 'enableRealTimeProtection', 'type': 'str'}, - 'exclusions': {'key': 'exclusions', 'type': 'object'}, - 'run_scheduled_scan': {'key': 'runScheduledScan', 'type': 'str'}, - 'scan_type': {'key': 'scanType', 'type': 'str'}, - 'scan_day': {'key': 'scanDay', 'type': 'str'}, - 'scan_time_in_minutes': {'key': 'scanTimeInMinutes', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ConfigurationProfilePreferenceAntiMalware, self).__init__(**kwargs) - self.enable_real_time_protection = kwargs.get('enable_real_time_protection', None) - self.exclusions = kwargs.get('exclusions', None) - self.run_scheduled_scan = kwargs.get('run_scheduled_scan', None) - self.scan_type = kwargs.get('scan_type', None) - self.scan_day = kwargs.get('scan_day', None) - self.scan_time_in_minutes = kwargs.get('scan_time_in_minutes', None) - - -class ConfigurationProfilePreferenceList(msrest.serialization.Model): - """The response of the list ConfigurationProfilePreference operation. - - :param value: Result of the list ConfigurationProfilePreference operation. - :type value: list[~automanage_client.models.ConfigurationProfilePreference] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ConfigurationProfilePreference]'}, - } - - def __init__( - self, - **kwargs - ): - super(ConfigurationProfilePreferenceList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class ConfigurationProfilePreferenceProperties(msrest.serialization.Model): - """Automanage configuration profile preference properties. - - :param vm_backup: The custom preferences for Azure VM Backup. - :type vm_backup: ~automanage_client.models.ConfigurationProfilePreferenceVmBackup - :param anti_malware: The custom preferences for Azure Antimalware. - :type anti_malware: ~automanage_client.models.ConfigurationProfilePreferenceAntiMalware - """ - - _attribute_map = { - 'vm_backup': {'key': 'vmBackup', 'type': 'ConfigurationProfilePreferenceVmBackup'}, - 'anti_malware': {'key': 'antiMalware', 'type': 'ConfigurationProfilePreferenceAntiMalware'}, - } - - def __init__( - self, - **kwargs - ): - super(ConfigurationProfilePreferenceProperties, self).__init__(**kwargs) - self.vm_backup = kwargs.get('vm_backup', None) - self.anti_malware = kwargs.get('anti_malware', None) - - -class ConfigurationProfilePreferenceUpdate(UpdateResource): - """Definition of the configuration profile preference. - - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param properties: Properties of the configuration profile preference. - :type properties: ~automanage_client.models.ConfigurationProfilePreferenceProperties - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'properties': {'key': 'properties', 'type': 'ConfigurationProfilePreferenceProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(ConfigurationProfilePreferenceUpdate, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - - -class ConfigurationProfilePreferenceVmBackup(msrest.serialization.Model): - """Automanage configuration profile VM Backup preferences. - - :param time_zone: TimeZone optional input as string. For example: Pacific Standard Time. - :type time_zone: str - :param instant_rp_retention_range_in_days: Instant RP retention policy range in days. - :type instant_rp_retention_range_in_days: int - :param retention_policy: Retention policy with the details on backup copy retention ranges. - :type retention_policy: str - :param schedule_policy: Backup schedule specified as part of backup policy. - :type schedule_policy: str - """ - - _attribute_map = { - 'time_zone': {'key': 'timeZone', 'type': 'str'}, - 'instant_rp_retention_range_in_days': {'key': 'instantRpRetentionRangeInDays', 'type': 'int'}, - 'retention_policy': {'key': 'retentionPolicy', 'type': 'str'}, - 'schedule_policy': {'key': 'schedulePolicy', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ConfigurationProfilePreferenceVmBackup, self).__init__(**kwargs) - self.time_zone = kwargs.get('time_zone', None) - self.instant_rp_retention_range_in_days = kwargs.get('instant_rp_retention_range_in_days', None) - self.retention_policy = kwargs.get('retention_policy', None) - self.schedule_policy = kwargs.get('schedule_policy', 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 ErrorResponse(msrest.serialization.Model): - """The resource management error response. - - :param error: The error object. - :type error: ~automanage_client.models.ErrorResponseError - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponseError'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class ErrorResponseError(msrest.serialization.Model): - """The error object. - - 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[~automanage_client.models.ErrorResponse] - :ivar additional_info: The error additional info. - :vartype additional_info: list[~automanage_client.models.ErrorAdditionalInfo] - """ - - _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponse]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponseError, self).__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class Operation(msrest.serialization.Model): - """Automanage REST API operation. - - :param name: Operation name: For ex. - providers/Microsoft.Automanage/configurationProfileAssignments/write or read. - :type name: str - :param is_data_action: Indicates whether the operation is a data action. - :type is_data_action: str - :param display: Provider, Resource, Operation and description values. - :type display: ~automanage_client.models.OperationDisplay - :param status_code: Service provider: Microsoft.Automanage. - :type status_code: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'status_code': {'key': 'properties.statusCode', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.is_data_action = kwargs.get('is_data_action', None) - self.display = kwargs.get('display', None) - self.status_code = kwargs.get('status_code', None) - - -class OperationDisplay(msrest.serialization.Model): - """Provider, Resource, Operation and description values. - - :param provider: Service provider: Microsoft.Automanage. - :type provider: str - :param resource: Resource on which the operation is performed: For ex. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - :param description: Description about operation. - :type description: str - """ - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = kwargs.get('provider', None) - self.resource = kwargs.get('resource', None) - self.operation = kwargs.get('operation', None) - self.description = kwargs.get('description', None) - - -class OperationList(msrest.serialization.Model): - """The response model for the list of Automanage operations. - - :param value: List of Automanage operations supported by the Automanage resource provider. - :type value: list[~automanage_client.models.Operation] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class ProxyResource(Resource): - """The resource model definition for a ARM proxy resource. It will have everything other than required location and tags. - - 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. Ex- 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) diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/_models_py3.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/_models_py3.py index 733188416af66..bed19f1c6e97b 100644 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/_models_py3.py +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/models/_models_py3.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Dict, List, Optional, Union +from typing import Any, Dict, List, Optional, Union from azure.core.exceptions import HttpResponseError import msrest.serialization @@ -15,17 +15,17 @@ class Resource(msrest.serialization.Model): - """Resource. + """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 - + :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. Ex- Microsoft.Compute/virtualMachines or - Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str """ @@ -45,6 +45,8 @@ def __init__( self, **kwargs ): + """ + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -52,24 +54,24 @@ def __init__( class TrackedResource(Resource): - """The resource model definition for a ARM tracked top level resource. + """The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar id: Fully qualified resource Id for the resource. Ex - + :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. Ex- Microsoft.Compute/virtualMachines or - Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str """ _validation = { @@ -94,6 +96,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + """ super(TrackedResource, self).__init__(**kwargs) self.tags = tags self.location = location @@ -106,20 +114,20 @@ class Account(TrackedResource): All required parameters must be populated in order to send to Azure. - :ivar id: Fully qualified resource Id for the resource. Ex - + :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. Ex- Microsoft.Compute/virtualMachines or - Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - :param identity: The identity of the Automanage account. - :type identity: ~automanage_client.models.AccountIdentity + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str + :ivar identity: The identity of the Automanage account. + :vartype identity: ~automanage_client.models.AccountIdentity """ _validation = { @@ -146,6 +154,14 @@ def __init__( identity: Optional["AccountIdentity"] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + :keyword identity: The identity of the Automanage account. + :paramtype identity: ~automanage_client.models.AccountIdentity + """ super(Account, self).__init__(tags=tags, location=location, **kwargs) self.identity = identity @@ -159,10 +175,10 @@ class AccountIdentity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant id associated with the Automanage account. :vartype tenant_id: str - :param type: The type of identity used for the Automanage account. Currently, the only - supported type is 'SystemAssigned', which implicitly creates an identity. Possible values - include: "SystemAssigned", "None". - :type type: str or ~automanage_client.models.ResourceIdentityType + :ivar type: The type of identity used for the Automanage account. Currently, the only supported + type is 'SystemAssigned', which implicitly creates an identity. Possible values include: + "SystemAssigned", "None". + :vartype type: str or ~automanage_client.models.ResourceIdentityType """ _validation = { @@ -182,6 +198,12 @@ def __init__( type: Optional[Union[str, "ResourceIdentityType"]] = None, **kwargs ): + """ + :keyword type: The type of identity used for the Automanage account. Currently, the only + supported type is 'SystemAssigned', which implicitly creates an identity. Possible values + include: "SystemAssigned", "None". + :paramtype type: str or ~automanage_client.models.ResourceIdentityType + """ super(AccountIdentity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -191,8 +213,8 @@ def __init__( class AccountList(msrest.serialization.Model): """The response of the list Account operation. - :param value: Result of the list Account operation. - :type value: list[~automanage_client.models.Account] + :ivar value: Result of the list Account operation. + :vartype value: list[~automanage_client.models.Account] """ _attribute_map = { @@ -205,6 +227,10 @@ def __init__( value: Optional[List["Account"]] = None, **kwargs ): + """ + :keyword value: Result of the list Account operation. + :paramtype value: list[~automanage_client.models.Account] + """ super(AccountList, self).__init__(**kwargs) self.value = value @@ -212,8 +238,8 @@ def __init__( class UpdateResource(msrest.serialization.Model): """Represents an update resource. - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] + :ivar tags: A set of tags. The tags of the resource. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -226,6 +252,10 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. The tags of the resource. + :paramtype tags: dict[str, str] + """ super(UpdateResource, self).__init__(**kwargs) self.tags = tags @@ -233,10 +263,10 @@ def __init__( class AccountUpdate(UpdateResource): """Definition of the Automanage account. - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param identity: The identity of the Automanage account. - :type identity: ~automanage_client.models.AccountIdentity + :ivar tags: A set of tags. The tags of the resource. + :vartype tags: dict[str, str] + :ivar identity: The identity of the Automanage account. + :vartype identity: ~automanage_client.models.AccountIdentity """ _attribute_map = { @@ -251,25 +281,67 @@ def __init__( identity: Optional["AccountIdentity"] = None, **kwargs ): + """ + :keyword tags: A set of tags. The tags of the resource. + :paramtype tags: dict[str, str] + :keyword identity: The identity of the Automanage account. + :paramtype identity: ~automanage_client.models.AccountIdentity + """ super(AccountUpdate, self).__init__(tags=tags, **kwargs) self.identity = identity -class ConfigurationProfileAssignment(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 ConfigurationProfileAssignment(ProxyResource): """Configuration profile assignment is an association between a VM and automanage profile configuration. 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 - + :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. Ex- Microsoft.Compute/virtualMachines or - Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param properties: Properties of the configuration profile assignment. - :type properties: ~automanage_client.models.ConfigurationProfileAssignmentProperties + :ivar properties: Properties of the configuration profile assignment. + :vartype properties: ~automanage_client.models.ConfigurationProfileAssignmentProperties """ _validation = { @@ -291,6 +363,10 @@ def __init__( properties: Optional["ConfigurationProfileAssignmentProperties"] = None, **kwargs ): + """ + :keyword properties: Properties of the configuration profile assignment. + :paramtype properties: ~automanage_client.models.ConfigurationProfileAssignmentProperties + """ super(ConfigurationProfileAssignment, self).__init__(**kwargs) self.properties = properties @@ -317,6 +393,8 @@ def __init__( self, **kwargs ): + """ + """ super(ConfigurationProfileAssignmentCompliance, self).__init__(**kwargs) self.update_status = None @@ -324,8 +402,8 @@ def __init__( class ConfigurationProfileAssignmentList(msrest.serialization.Model): """The response of the list configuration profile assignment operation. - :param value: Result of the list configuration profile assignment operation. - :type value: list[~automanage_client.models.ConfigurationProfileAssignment] + :ivar value: Result of the list configuration profile assignment operation. + :vartype value: list[~automanage_client.models.ConfigurationProfileAssignment] """ _attribute_map = { @@ -338,6 +416,10 @@ def __init__( value: Optional[List["ConfigurationProfileAssignment"]] = None, **kwargs ): + """ + :keyword value: Result of the list configuration profile assignment operation. + :paramtype value: list[~automanage_client.models.ConfigurationProfileAssignment] + """ super(ConfigurationProfileAssignmentList, self).__init__(**kwargs) self.value = value @@ -347,26 +429,26 @@ class ConfigurationProfileAssignmentProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param configuration_profile: A value indicating configuration profile. Possible values - include: "Azure virtual machine best practices – Dev/Test", "Azure virtual machine best - practices – Production". - :type configuration_profile: str or ~automanage_client.models.ConfigurationProfile - :param target_id: The target VM resource URI. - :type target_id: str - :param account_id: The Automanage account ARM Resource URI. - :type account_id: str - :param configuration_profile_preference_id: The configuration profile custom preferences ARM + :ivar configuration_profile: A value indicating configuration profile. Possible values include: + "Azure virtual machine best practices – Dev/Test", "Azure virtual machine best practices – + Production". + :vartype configuration_profile: str or ~automanage_client.models.ConfigurationProfile + :ivar target_id: The target VM resource URI. + :vartype target_id: str + :ivar account_id: The Automanage account ARM Resource URI. + :vartype account_id: str + :ivar configuration_profile_preference_id: The configuration profile custom preferences ARM resource URI. - :type configuration_profile_preference_id: str - :ivar provisioning_status: The state of onboarding, which only appears in the response. - Possible values include: "Succeeded", "Failed", "Created". - :vartype provisioning_status: str or ~automanage_client.models.ProvisioningStatus - :param compliance: The configuration setting for the configuration profile. - :type compliance: ~automanage_client.models.ConfigurationProfileAssignmentCompliance + :vartype configuration_profile_preference_id: str + :ivar provisioning_state: The state of onboarding, which only appears in the response. Possible + values include: "Succeeded", "Failed", "Created". + :vartype provisioning_state: str or ~automanage_client.models.ProvisioningState + :ivar compliance: The configuration setting for the configuration profile. + :vartype compliance: ~automanage_client.models.ConfigurationProfileAssignmentCompliance """ _validation = { - 'provisioning_status': {'readonly': True}, + 'provisioning_state': {'readonly': True}, } _attribute_map = { @@ -374,7 +456,7 @@ class ConfigurationProfileAssignmentProperties(msrest.serialization.Model): 'target_id': {'key': 'targetId', 'type': 'str'}, 'account_id': {'key': 'accountId', 'type': 'str'}, 'configuration_profile_preference_id': {'key': 'configurationProfilePreferenceId', 'type': 'str'}, - 'provisioning_status': {'key': 'provisioningStatus', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, 'compliance': {'key': 'compliance', 'type': 'ConfigurationProfileAssignmentCompliance'}, } @@ -388,12 +470,27 @@ def __init__( compliance: Optional["ConfigurationProfileAssignmentCompliance"] = None, **kwargs ): + """ + :keyword configuration_profile: A value indicating configuration profile. Possible values + include: "Azure virtual machine best practices – Dev/Test", "Azure virtual machine best + practices – Production". + :paramtype configuration_profile: str or ~automanage_client.models.ConfigurationProfile + :keyword target_id: The target VM resource URI. + :paramtype target_id: str + :keyword account_id: The Automanage account ARM Resource URI. + :paramtype account_id: str + :keyword configuration_profile_preference_id: The configuration profile custom preferences ARM + resource URI. + :paramtype configuration_profile_preference_id: str + :keyword compliance: The configuration setting for the configuration profile. + :paramtype compliance: ~automanage_client.models.ConfigurationProfileAssignmentCompliance + """ super(ConfigurationProfileAssignmentProperties, self).__init__(**kwargs) self.configuration_profile = configuration_profile self.target_id = target_id self.account_id = account_id self.configuration_profile_preference_id = configuration_profile_preference_id - self.provisioning_status = None + self.provisioning_state = None self.compliance = compliance @@ -404,20 +501,20 @@ class ConfigurationProfilePreference(TrackedResource): All required parameters must be populated in order to send to Azure. - :ivar id: Fully qualified resource Id for the resource. Ex - + :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. Ex- Microsoft.Compute/virtualMachines or - Microsoft.Storage/storageAccounts. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - :param properties: Properties of the configuration profile preference. - :type properties: ~automanage_client.models.ConfigurationProfilePreferenceProperties + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str + :ivar properties: Properties of the configuration profile preference. + :vartype properties: ~automanage_client.models.ConfigurationProfilePreferenceProperties """ _validation = { @@ -444,6 +541,14 @@ def __init__( properties: Optional["ConfigurationProfilePreferenceProperties"] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + :keyword properties: Properties of the configuration profile preference. + :paramtype properties: ~automanage_client.models.ConfigurationProfilePreferenceProperties + """ super(ConfigurationProfilePreference, self).__init__(tags=tags, location=location, **kwargs) self.properties = properties @@ -451,20 +556,20 @@ def __init__( class ConfigurationProfilePreferenceAntiMalware(msrest.serialization.Model): """Automanage configuration profile Antimalware preferences. - :param enable_real_time_protection: Enables or disables Real Time Protection. Possible values + :ivar enable_real_time_protection: Enables or disables Real Time Protection. Possible values include: "True", "False". - :type enable_real_time_protection: str or ~automanage_client.models.EnableRealTimeProtection - :param exclusions: Extensions, Paths and Processes that must be excluded from scan. - :type exclusions: object - :param run_scheduled_scan: Enables or disables a periodic scan for antimalware. Possible values + :vartype enable_real_time_protection: str or ~automanage_client.models.EnableRealTimeProtection + :ivar exclusions: Extensions, Paths and Processes that must be excluded from scan. + :vartype exclusions: any + :ivar run_scheduled_scan: Enables or disables a periodic scan for antimalware. Possible values include: "True", "False". - :type run_scheduled_scan: str or ~automanage_client.models.RunScheduledScan - :param scan_type: Type of scheduled scan. Possible values include: "Quick", "Full". - :type scan_type: str or ~automanage_client.models.ScanType - :param scan_day: Schedule scan settings day. - :type scan_day: str - :param scan_time_in_minutes: Schedule scan settings time. - :type scan_time_in_minutes: str + :vartype run_scheduled_scan: str or ~automanage_client.models.RunScheduledScan + :ivar scan_type: Type of scheduled scan. Possible values include: "Quick", "Full". + :vartype scan_type: str or ~automanage_client.models.ScanType + :ivar scan_day: Schedule scan settings day. + :vartype scan_day: str + :ivar scan_time_in_minutes: Schedule scan settings time. + :vartype scan_time_in_minutes: str """ _attribute_map = { @@ -480,13 +585,30 @@ def __init__( self, *, enable_real_time_protection: Optional[Union[str, "EnableRealTimeProtection"]] = None, - exclusions: Optional[object] = None, + exclusions: Optional[Any] = None, run_scheduled_scan: Optional[Union[str, "RunScheduledScan"]] = None, scan_type: Optional[Union[str, "ScanType"]] = None, scan_day: Optional[str] = None, scan_time_in_minutes: Optional[str] = None, **kwargs ): + """ + :keyword enable_real_time_protection: Enables or disables Real Time Protection. Possible values + include: "True", "False". + :paramtype enable_real_time_protection: str or + ~automanage_client.models.EnableRealTimeProtection + :keyword exclusions: Extensions, Paths and Processes that must be excluded from scan. + :paramtype exclusions: any + :keyword run_scheduled_scan: Enables or disables a periodic scan for antimalware. Possible + values include: "True", "False". + :paramtype run_scheduled_scan: str or ~automanage_client.models.RunScheduledScan + :keyword scan_type: Type of scheduled scan. Possible values include: "Quick", "Full". + :paramtype scan_type: str or ~automanage_client.models.ScanType + :keyword scan_day: Schedule scan settings day. + :paramtype scan_day: str + :keyword scan_time_in_minutes: Schedule scan settings time. + :paramtype scan_time_in_minutes: str + """ super(ConfigurationProfilePreferenceAntiMalware, self).__init__(**kwargs) self.enable_real_time_protection = enable_real_time_protection self.exclusions = exclusions @@ -499,8 +621,8 @@ def __init__( class ConfigurationProfilePreferenceList(msrest.serialization.Model): """The response of the list ConfigurationProfilePreference operation. - :param value: Result of the list ConfigurationProfilePreference operation. - :type value: list[~automanage_client.models.ConfigurationProfilePreference] + :ivar value: Result of the list ConfigurationProfilePreference operation. + :vartype value: list[~automanage_client.models.ConfigurationProfilePreference] """ _attribute_map = { @@ -513,6 +635,10 @@ def __init__( value: Optional[List["ConfigurationProfilePreference"]] = None, **kwargs ): + """ + :keyword value: Result of the list ConfigurationProfilePreference operation. + :paramtype value: list[~automanage_client.models.ConfigurationProfilePreference] + """ super(ConfigurationProfilePreferenceList, self).__init__(**kwargs) self.value = value @@ -520,10 +646,10 @@ def __init__( class ConfigurationProfilePreferenceProperties(msrest.serialization.Model): """Automanage configuration profile preference properties. - :param vm_backup: The custom preferences for Azure VM Backup. - :type vm_backup: ~automanage_client.models.ConfigurationProfilePreferenceVmBackup - :param anti_malware: The custom preferences for Azure Antimalware. - :type anti_malware: ~automanage_client.models.ConfigurationProfilePreferenceAntiMalware + :ivar vm_backup: The custom preferences for Azure VM Backup. + :vartype vm_backup: ~automanage_client.models.ConfigurationProfilePreferenceVmBackup + :ivar anti_malware: The custom preferences for Azure Antimalware. + :vartype anti_malware: ~automanage_client.models.ConfigurationProfilePreferenceAntiMalware """ _attribute_map = { @@ -538,6 +664,12 @@ def __init__( anti_malware: Optional["ConfigurationProfilePreferenceAntiMalware"] = None, **kwargs ): + """ + :keyword vm_backup: The custom preferences for Azure VM Backup. + :paramtype vm_backup: ~automanage_client.models.ConfigurationProfilePreferenceVmBackup + :keyword anti_malware: The custom preferences for Azure Antimalware. + :paramtype anti_malware: ~automanage_client.models.ConfigurationProfilePreferenceAntiMalware + """ super(ConfigurationProfilePreferenceProperties, self).__init__(**kwargs) self.vm_backup = vm_backup self.anti_malware = anti_malware @@ -546,10 +678,10 @@ def __init__( class ConfigurationProfilePreferenceUpdate(UpdateResource): """Definition of the configuration profile preference. - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param properties: Properties of the configuration profile preference. - :type properties: ~automanage_client.models.ConfigurationProfilePreferenceProperties + :ivar tags: A set of tags. The tags of the resource. + :vartype tags: dict[str, str] + :ivar properties: Properties of the configuration profile preference. + :vartype properties: ~automanage_client.models.ConfigurationProfilePreferenceProperties """ _attribute_map = { @@ -564,6 +696,12 @@ def __init__( properties: Optional["ConfigurationProfilePreferenceProperties"] = None, **kwargs ): + """ + :keyword tags: A set of tags. The tags of the resource. + :paramtype tags: dict[str, str] + :keyword properties: Properties of the configuration profile preference. + :paramtype properties: ~automanage_client.models.ConfigurationProfilePreferenceProperties + """ super(ConfigurationProfilePreferenceUpdate, self).__init__(tags=tags, **kwargs) self.properties = properties @@ -571,14 +709,14 @@ def __init__( class ConfigurationProfilePreferenceVmBackup(msrest.serialization.Model): """Automanage configuration profile VM Backup preferences. - :param time_zone: TimeZone optional input as string. For example: Pacific Standard Time. - :type time_zone: str - :param instant_rp_retention_range_in_days: Instant RP retention policy range in days. - :type instant_rp_retention_range_in_days: int - :param retention_policy: Retention policy with the details on backup copy retention ranges. - :type retention_policy: str - :param schedule_policy: Backup schedule specified as part of backup policy. - :type schedule_policy: str + :ivar time_zone: TimeZone optional input as string. For example: Pacific Standard Time. + :vartype time_zone: str + :ivar instant_rp_retention_range_in_days: Instant RP retention policy range in days. + :vartype instant_rp_retention_range_in_days: int + :ivar retention_policy: Retention policy with the details on backup copy retention ranges. + :vartype retention_policy: str + :ivar schedule_policy: Backup schedule specified as part of backup policy. + :vartype schedule_policy: str """ _attribute_map = { @@ -597,6 +735,16 @@ def __init__( schedule_policy: Optional[str] = None, **kwargs ): + """ + :keyword time_zone: TimeZone optional input as string. For example: Pacific Standard Time. + :paramtype time_zone: str + :keyword instant_rp_retention_range_in_days: Instant RP retention policy range in days. + :paramtype instant_rp_retention_range_in_days: int + :keyword retention_policy: Retention policy with the details on backup copy retention ranges. + :paramtype retention_policy: str + :keyword schedule_policy: Backup schedule specified as part of backup policy. + :paramtype schedule_policy: str + """ super(ConfigurationProfilePreferenceVmBackup, self).__init__(**kwargs) self.time_zone = time_zone self.instant_rp_retention_range_in_days = instant_rp_retention_range_in_days @@ -612,7 +760,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 = { @@ -629,34 +777,15 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(msrest.serialization.Model): - """The resource management error response. - - :param error: The error object. - :type error: ~automanage_client.models.ErrorResponseError - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponseError'}, - } - - def __init__( - self, - *, - error: Optional["ErrorResponseError"] = None, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.error = error - - -class ErrorResponseError(msrest.serialization.Model): - """The error object. +class ErrorDetail(msrest.serialization.Model): + """The error detail. Variables are only populated by the server, and will be ignored when sending a request. @@ -667,7 +796,7 @@ class ErrorResponseError(msrest.serialization.Model): :ivar target: The error target. :vartype target: str :ivar details: The error details. - :vartype details: list[~automanage_client.models.ErrorResponse] + :vartype details: list[~automanage_client.models.ErrorDetail] :ivar additional_info: The error additional info. :vartype additional_info: list[~automanage_client.models.ErrorAdditionalInfo] """ @@ -684,7 +813,7 @@ class ErrorResponseError(msrest.serialization.Model): 'code': {'key': 'code', 'type': 'str'}, 'message': {'key': 'message', 'type': 'str'}, 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponse]'}, + 'details': {'key': 'details', 'type': '[ErrorDetail]'}, 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, } @@ -692,7 +821,9 @@ def __init__( self, **kwargs ): - super(ErrorResponseError, self).__init__(**kwargs) + """ + """ + super(ErrorDetail, self).__init__(**kwargs) self.code = None self.message = None self.target = None @@ -700,18 +831,43 @@ def __init__( 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.). + + :ivar error: The error object. + :vartype error: ~automanage_client.models.ErrorDetail + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDetail'}, + } + + def __init__( + self, + *, + error: Optional["ErrorDetail"] = None, + **kwargs + ): + """ + :keyword error: The error object. + :paramtype error: ~automanage_client.models.ErrorDetail + """ + super(ErrorResponse, self).__init__(**kwargs) + self.error = error + + class Operation(msrest.serialization.Model): """Automanage REST API operation. - :param name: Operation name: For ex. + :ivar name: Operation name: For ex. providers/Microsoft.Automanage/configurationProfileAssignments/write or read. - :type name: str - :param is_data_action: Indicates whether the operation is a data action. - :type is_data_action: str - :param display: Provider, Resource, Operation and description values. - :type display: ~automanage_client.models.OperationDisplay - :param status_code: Service provider: Microsoft.Automanage. - :type status_code: str + :vartype name: str + :ivar is_data_action: Indicates whether the operation is a data action. + :vartype is_data_action: str + :ivar display: Provider, Resource, Operation and description values. + :vartype display: ~automanage_client.models.OperationDisplay + :ivar status_code: Service provider: Microsoft.Automanage. + :vartype status_code: str """ _attribute_map = { @@ -730,6 +886,17 @@ def __init__( status_code: Optional[str] = None, **kwargs ): + """ + :keyword name: Operation name: For ex. + providers/Microsoft.Automanage/configurationProfileAssignments/write or read. + :paramtype name: str + :keyword is_data_action: Indicates whether the operation is a data action. + :paramtype is_data_action: str + :keyword display: Provider, Resource, Operation and description values. + :paramtype display: ~automanage_client.models.OperationDisplay + :keyword status_code: Service provider: Microsoft.Automanage. + :paramtype status_code: str + """ super(Operation, self).__init__(**kwargs) self.name = name self.is_data_action = is_data_action @@ -740,14 +907,14 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """Provider, Resource, Operation and description values. - :param provider: Service provider: Microsoft.Automanage. - :type provider: str - :param resource: Resource on which the operation is performed: For ex. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - :param description: Description about operation. - :type description: str + :ivar provider: Service provider: Microsoft.Automanage. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: For ex. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + :ivar description: Description about operation. + :vartype description: str """ _attribute_map = { @@ -766,6 +933,16 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword provider: Service provider: Microsoft.Automanage. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: For ex. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + :keyword description: Description about operation. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -776,8 +953,8 @@ def __init__( class OperationList(msrest.serialization.Model): """The response model for the list of Automanage operations. - :param value: List of Automanage operations supported by the Automanage resource provider. - :type value: list[~automanage_client.models.Operation] + :ivar value: List of Automanage operations supported by the Automanage resource provider. + :vartype value: list[~automanage_client.models.Operation] """ _attribute_map = { @@ -790,39 +967,9 @@ def __init__( value: Optional[List["Operation"]] = None, **kwargs ): + """ + :keyword value: List of Automanage operations supported by the Automanage resource provider. + :paramtype value: list[~automanage_client.models.Operation] + """ super(OperationList, self).__init__(**kwargs) self.value = value - - -class ProxyResource(Resource): - """The resource model definition for a ARM proxy resource. It will have everything other than required location and tags. - - 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. Ex- 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) diff --git a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_accounts_operations.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_accounts_operations.py index d97b79a4a8b1d..db04cee6add91 100644 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_accounts_operations.py +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_accounts_operations.py @@ -5,23 +5,248 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings -from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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 .. import models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_or_update_request( + account_name: str, + subscription_id: str, + resource_group_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-06-30-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/accounts/{accountName}') + path_format_arguments = { + "accountName": _SERIALIZER.url("account_name", account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + account_name: str, + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-06-30-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/accounts/{accountName}') + path_format_arguments = { + "accountName": _SERIALIZER.url("account_name", account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-06-30-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/accounts/{accountName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "accountName": _SERIALIZER.url("account_name", account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_request( + account_name: str, + subscription_id: str, + resource_group_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-06-30-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/accounts/{accountName}') + path_format_arguments = { + "accountName": _SERIALIZER.url("account_name", account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-06-30-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/accounts') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-06-30-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Automanage/accounts') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class AccountsOperations(object): """AccountsOperations operations. @@ -37,7 +262,7 @@ class AccountsOperations(object): :param deserializer: An object model deserializer. """ - models = models + models = _models def __init__(self, client, config, serializer, deserializer): self._client = client @@ -45,14 +270,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def create_or_update( self, - account_name, # type: str - resource_group_name, # type: str - parameters, # type: "models.Account" - **kwargs # type: Any - ): - # type: (...) -> "models.Account" + account_name: str, + resource_group_name: str, + parameters: "_models.Account", + **kwargs: Any + ) -> "_models.Account": """Creates an Automanage Account. :param account_name: Name of the Automanage account. @@ -66,41 +291,33 @@ def create_or_update( :rtype: ~automanage_client.models.Account :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.Account"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'accountName': self._serialize.url("account_name", account_name, 'str'), - 'subscriptionId': self._serialize.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\._\(\)]+$'), + cls = kwargs.pop('cls', None) # type: ClsType["_models.Account"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {})) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = 'application/json' + _json = self._serialize.body(parameters, 'Account') - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Account') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + request = build_create_or_update_request( + account_name=account_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -113,15 +330,17 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/accounts/{accountName}'} # type: ignore + + @distributed_trace def get( self, - account_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "models.Account" + account_name: str, + resource_group_name: str, + **kwargs: Any + ) -> "_models.Account": """Get information about a Automanage account. :param account_name: The Automanage account name. @@ -133,35 +352,28 @@ def get( :rtype: ~automanage_client.models.Account :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.Account"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'accountName': self._serialize.url("account_name", account_name, 'str'), - 'subscriptionId': self._serialize.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\._\(\)]+$'), + cls = kwargs.pop('cls', None) # type: ClsType["_models.Account"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop('error_map', {})) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' + + request = build_get_request( + account_name=account_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Account', pipeline_response) @@ -170,15 +382,17 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/accounts/{accountName}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> None: """Delete a Automanage account. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -191,33 +405,27 @@ def delete( :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'accountName': self._serialize.url("account_name", account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop('error_map', {})) - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -225,14 +433,15 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/accounts/{accountName}'} # type: ignore + + @distributed_trace def update( self, - account_name, # type: str - resource_group_name, # type: str - parameters, # type: "models.AccountUpdate" - **kwargs # type: Any - ): - # type: (...) -> "models.Account" + account_name: str, + resource_group_name: str, + parameters: "_models.AccountUpdate", + **kwargs: Any + ) -> "_models.Account": """Updates an Automanage Account. :param account_name: Name of the Automanage account. @@ -246,41 +455,33 @@ def update( :rtype: ~automanage_client.models.Account :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.Account"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'accountName': self._serialize.url("account_name", account_name, 'str'), - 'subscriptionId': self._serialize.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\._\(\)]+$'), + cls = kwargs.pop('cls', None) # type: ClsType["_models.Account"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {})) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = 'application/json' + _json = self._serialize.body(parameters, 'AccountUpdate') - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'AccountUpdate') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + request = build_update_request( + account_name=account_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Account', pipeline_response) @@ -289,14 +490,16 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/accounts/{accountName}'} # type: ignore + + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["models.AccountList"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.AccountList"]: """Retrieve a list of Automanage accounts within a given resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -306,37 +509,36 @@ def list_by_resource_group( :rtype: ~azure.core.paging.ItemPaged[~automanage_client.models.AccountList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.AccountList"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccountList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, 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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AccountList', pipeline_response) + deserialized = self._deserialize("AccountList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -349,22 +551,23 @@ 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_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/accounts'} # type: ignore + @distributed_trace def list_by_subscription( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["models.AccountList"] + **kwargs: Any + ) -> Iterable["_models.AccountList"]: """Retrieve a list of Automanage accounts within a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -372,36 +575,34 @@ def list_by_subscription( :rtype: ~azure.core.paging.ItemPaged[~automanage_client.models.AccountList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.AccountList"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccountList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AccountList', pipeline_response) + deserialized = self._deserialize("AccountList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -414,12 +615,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/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_configuration_profile_assignments_operations.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_configuration_profile_assignments_operations.py index 3ce28d9f8d6fb..3c6873ddbc54d 100644 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_configuration_profile_assignments_operations.py +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_configuration_profile_assignments_operations.py @@ -5,25 +5,212 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings -from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_or_update_request_initial( + configuration_profile_assignment_name: str, + subscription_id: str, + resource_group_name: str, + vm_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-06-30-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}') + path_format_arguments = { + "configurationProfileAssignmentName": _SERIALIZER.url("configuration_profile_assignment_name", configuration_profile_assignment_name, 'str'), + "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), + "vmName": _SERIALIZER.url("vm_name", vm_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + configuration_profile_assignment_name: str, + subscription_id: str, + vm_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-06-30-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "configurationProfileAssignmentName": _SERIALIZER.url("configuration_profile_assignment_name", configuration_profile_assignment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "vmName": _SERIALIZER.url("vm_name", vm_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + configuration_profile_assignment_name: str, + subscription_id: str, + vm_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-06-30-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "configurationProfileAssignmentName": _SERIALIZER.url("configuration_profile_assignment_name", configuration_profile_assignment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "vmName": _SERIALIZER.url("vm_name", vm_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-06-30-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfileAssignments') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-06-30-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Automanage/configurationProfileAssignments') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ConfigurationProfileAssignmentsOperations(object): """ConfigurationProfileAssignmentsOperations operations. @@ -39,7 +226,7 @@ class ConfigurationProfileAssignmentsOperations(object): :param deserializer: An object model deserializer. """ - models = models + models = _models def __init__(self, client, config, serializer, deserializer): self._client = client @@ -49,50 +236,40 @@ def __init__(self, client, config, serializer, deserializer): def _create_or_update_initial( self, - configuration_profile_assignment_name, # type: str - resource_group_name, # type: str - vm_name, # type: str - parameters, # type: "models.ConfigurationProfileAssignment" - **kwargs # type: Any - ): - # type: (...) -> "models.ConfigurationProfileAssignment" - cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationProfileAssignment"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'configurationProfileAssignmentName': self._serialize.url("configuration_profile_assignment_name", configuration_profile_assignment_name, 'str'), - 'subscriptionId': self._serialize.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\._\(\)]+$'), - 'vmName': self._serialize.url("vm_name", vm_name, 'str'), + configuration_profile_assignment_name: str, + resource_group_name: str, + vm_name: str, + parameters: "_models.ConfigurationProfileAssignment", + **kwargs: Any + ) -> "_models.ConfigurationProfileAssignment": + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfileAssignment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {})) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = 'application/json' + _json = self._serialize.body(parameters, 'ConfigurationProfileAssignment') - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ConfigurationProfileAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + request = build_create_or_update_request_initial( + configuration_profile_assignment_name=configuration_profile_assignment_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vm_name=vm_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('ConfigurationProfileAssignment', pipeline_response) @@ -104,41 +281,47 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - configuration_profile_assignment_name, # type: str - resource_group_name, # type: str - vm_name, # type: str - parameters, # type: "models.ConfigurationProfileAssignment" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["models.ConfigurationProfileAssignment"] + configuration_profile_assignment_name: str, + resource_group_name: str, + vm_name: str, + parameters: "_models.ConfigurationProfileAssignment", + **kwargs: Any + ) -> LROPoller["_models.ConfigurationProfileAssignment"]: """Creates an association between a VM and Automanage configuration profile. :param configuration_profile_assignment_name: Name of the configuration profile assignment. - Only default is supported. + Only default is supported. :type configuration_profile_assignment_name: str :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param vm_name: The name of the virtual machine. :type vm_name: str :param parameters: Parameters supplied to the create or update configuration profile - assignment. + assignment. :type parameters: ~automanage_client.models.ConfigurationProfileAssignment :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either ConfigurationProfileAssignment or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConfigurationProfileAssignment or the + result of cls(response) :rtype: ~azure.core.polling.LROPoller[~automanage_client.models.ConfigurationProfileAssignment] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationProfileAssignment"] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfileAssignment"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval @@ -150,21 +333,21 @@ def begin_create_or_update( resource_group_name=resource_group_name, vm_name=vm_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ConfigurationProfileAssignment', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -176,16 +359,17 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - configuration_profile_assignment_name, # type: str - vm_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "models.ConfigurationProfileAssignment" + resource_group_name: str, + configuration_profile_assignment_name: str, + vm_name: str, + **kwargs: Any + ) -> "_models.ConfigurationProfileAssignment": """Get information about a configuration profile assignment. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -199,36 +383,29 @@ def get( :rtype: ~automanage_client.models.ConfigurationProfileAssignment :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationProfileAssignment"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'configurationProfileAssignmentName': self._serialize.url("configuration_profile_assignment_name", configuration_profile_assignment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'vmName': self._serialize.url("vm_name", vm_name, 'str'), + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfileAssignment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop('error_map', {})) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' + + request = build_get_request( + resource_group_name=resource_group_name, + configuration_profile_assignment_name=configuration_profile_assignment_name, + subscription_id=self._config.subscription_id, + vm_name=vm_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ConfigurationProfileAssignment', pipeline_response) @@ -237,16 +414,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - configuration_profile_assignment_name, # type: str - vm_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + configuration_profile_assignment_name: str, + vm_name: str, + **kwargs: Any + ) -> None: """Delete a configuration profile assignment. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -261,34 +440,28 @@ def delete( :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'configurationProfileAssignmentName': self._serialize.url("configuration_profile_assignment_name", configuration_profile_assignment_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'vmName': self._serialize.url("vm_name", vm_name, 'str'), + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop('error_map', {})) - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + resource_group_name=resource_group_name, + configuration_profile_assignment_name=configuration_profile_assignment_name, + subscription_id=self._config.subscription_id, + vm_name=vm_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -296,52 +469,54 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/providers/Microsoft.Automanage/configurationProfileAssignments/{configurationProfileAssignmentName}'} # type: ignore + + @distributed_trace def list( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["models.ConfigurationProfileAssignmentList"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.ConfigurationProfileAssignmentList"]: """Get list of configuration profile assignments. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ConfigurationProfileAssignmentList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~automanage_client.models.ConfigurationProfileAssignmentList] + :return: An iterator like instance of either ConfigurationProfileAssignmentList or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~automanage_client.models.ConfigurationProfileAssignmentList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationProfileAssignmentList"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfileAssignmentList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ConfigurationProfileAssignmentList', pipeline_response) + deserialized = self._deserialize("ConfigurationProfileAssignmentList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -354,59 +529,60 @@ 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.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfileAssignments'} # type: ignore + @distributed_trace def list_by_subscription( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["models.ConfigurationProfileAssignmentList"] + **kwargs: Any + ) -> Iterable["_models.ConfigurationProfileAssignmentList"]: """Get list of configuration profile assignments under a given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ConfigurationProfileAssignmentList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~automanage_client.models.ConfigurationProfileAssignmentList] + :return: An iterator like instance of either ConfigurationProfileAssignmentList or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~automanage_client.models.ConfigurationProfileAssignmentList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationProfileAssignmentList"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfileAssignmentList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ConfigurationProfileAssignmentList', pipeline_response) + deserialized = self._deserialize("ConfigurationProfileAssignmentList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -419,12 +595,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/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_configuration_profile_preferences_operations.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_configuration_profile_preferences_operations.py index 094cc67131d5a..edbce947eebca 100644 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_configuration_profile_preferences_operations.py +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_configuration_profile_preferences_operations.py @@ -5,23 +5,248 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings -from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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 .. import models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_or_update_request( + configuration_profile_preference_name: str, + subscription_id: str, + resource_group_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-06-30-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfilePreferences/{configurationProfilePreferenceName}') + path_format_arguments = { + "configurationProfilePreferenceName": _SERIALIZER.url("configuration_profile_preference_name", configuration_profile_preference_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + configuration_profile_preference_name: str, + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-06-30-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfilePreferences/{configurationProfilePreferenceName}') + path_format_arguments = { + "configurationProfilePreferenceName": _SERIALIZER.url("configuration_profile_preference_name", configuration_profile_preference_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + configuration_profile_preference_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-06-30-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfilePreferences/{configurationProfilePreferenceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "configurationProfilePreferenceName": _SERIALIZER.url("configuration_profile_preference_name", configuration_profile_preference_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_request( + configuration_profile_preference_name: str, + subscription_id: str, + resource_group_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-06-30-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfilePreferences/{configurationProfilePreferenceName}') + path_format_arguments = { + "configurationProfilePreferenceName": _SERIALIZER.url("configuration_profile_preference_name", configuration_profile_preference_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-06-30-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfilePreferences') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-06-30-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Automanage/configurationProfilePreferences') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ConfigurationProfilePreferencesOperations(object): """ConfigurationProfilePreferencesOperations operations. @@ -37,7 +262,7 @@ class ConfigurationProfilePreferencesOperations(object): :param deserializer: An object model deserializer. """ - models = models + models = _models def __init__(self, client, config, serializer, deserializer): self._client = client @@ -45,14 +270,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def create_or_update( self, - configuration_profile_preference_name, # type: str - resource_group_name, # type: str - parameters, # type: "models.ConfigurationProfilePreference" - **kwargs # type: Any - ): - # type: (...) -> "models.ConfigurationProfilePreference" + configuration_profile_preference_name: str, + resource_group_name: str, + parameters: "_models.ConfigurationProfilePreference", + **kwargs: Any + ) -> "_models.ConfigurationProfilePreference": """Creates a configuration profile preference. :param configuration_profile_preference_name: Name of the configuration profile preference. @@ -66,41 +291,33 @@ def create_or_update( :rtype: ~automanage_client.models.ConfigurationProfilePreference :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationProfilePreference"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'configurationProfilePreferenceName': self._serialize.url("configuration_profile_preference_name", configuration_profile_preference_name, 'str'), - 'subscriptionId': self._serialize.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\._\(\)]+$'), + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfilePreference"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {})) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = 'application/json' + _json = self._serialize.body(parameters, 'ConfigurationProfilePreference') - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ConfigurationProfilePreference') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + request = build_create_or_update_request( + configuration_profile_preference_name=configuration_profile_preference_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -113,15 +330,17 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfilePreferences/{configurationProfilePreferenceName}'} # type: ignore + + @distributed_trace def get( self, - configuration_profile_preference_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "models.ConfigurationProfilePreference" + configuration_profile_preference_name: str, + resource_group_name: str, + **kwargs: Any + ) -> "_models.ConfigurationProfilePreference": """Get information about a configuration profile preference. :param configuration_profile_preference_name: The configuration profile preference name. @@ -133,35 +352,28 @@ def get( :rtype: ~automanage_client.models.ConfigurationProfilePreference :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationProfilePreference"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'configurationProfilePreferenceName': self._serialize.url("configuration_profile_preference_name", configuration_profile_preference_name, 'str'), - 'subscriptionId': self._serialize.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\._\(\)]+$'), + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfilePreference"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop('error_map', {})) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' + + request = build_get_request( + configuration_profile_preference_name=configuration_profile_preference_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ConfigurationProfilePreference', pipeline_response) @@ -170,15 +382,17 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfilePreferences/{configurationProfilePreferenceName}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - configuration_profile_preference_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + configuration_profile_preference_name: str, + **kwargs: Any + ) -> None: """Delete a configuration profile preference. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -191,33 +405,27 @@ def delete( :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - 'configurationProfilePreferenceName': self._serialize.url("configuration_profile_preference_name", configuration_profile_preference_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop('error_map', {})) - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + resource_group_name=resource_group_name, + configuration_profile_preference_name=configuration_profile_preference_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -225,14 +433,15 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfilePreferences/{configurationProfilePreferenceName}'} # type: ignore + + @distributed_trace def update( self, - configuration_profile_preference_name, # type: str - resource_group_name, # type: str - parameters, # type: "models.ConfigurationProfilePreferenceUpdate" - **kwargs # type: Any - ): - # type: (...) -> "models.ConfigurationProfilePreference" + configuration_profile_preference_name: str, + resource_group_name: str, + parameters: "_models.ConfigurationProfilePreferenceUpdate", + **kwargs: Any + ) -> "_models.ConfigurationProfilePreference": """Updates a configuration profile preference. :param configuration_profile_preference_name: Name of the configuration profile preference. @@ -246,41 +455,33 @@ def update( :rtype: ~automanage_client.models.ConfigurationProfilePreference :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationProfilePreference"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - content_type = kwargs.pop("content_type", "application/json") - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'configurationProfilePreferenceName': self._serialize.url("configuration_profile_preference_name", configuration_profile_preference_name, 'str'), - 'subscriptionId': self._serialize.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\._\(\)]+$'), + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfilePreference"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop('error_map', {})) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = 'application/json' + _json = self._serialize.body(parameters, 'ConfigurationProfilePreferenceUpdate') - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ConfigurationProfilePreferenceUpdate') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + request = build_update_request( + configuration_profile_preference_name=configuration_profile_preference_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ConfigurationProfilePreference', pipeline_response) @@ -289,54 +490,57 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfilePreferences/{configurationProfilePreferenceName}'} # type: ignore + + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["models.ConfigurationProfilePreferenceList"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.ConfigurationProfilePreferenceList"]: """Retrieve a list of configuration profile preferences within a given resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ConfigurationProfilePreferenceList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~automanage_client.models.ConfigurationProfilePreferenceList] + :return: An iterator like instance of either ConfigurationProfilePreferenceList or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~automanage_client.models.ConfigurationProfilePreferenceList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationProfilePreferenceList"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfilePreferenceList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, 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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ConfigurationProfilePreferenceList', pipeline_response) + deserialized = self._deserialize("ConfigurationProfilePreferenceList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -349,59 +553,60 @@ 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_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automanage/configurationProfilePreferences'} # type: ignore + @distributed_trace def list_by_subscription( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["models.ConfigurationProfilePreferenceList"] + **kwargs: Any + ) -> Iterable["_models.ConfigurationProfilePreferenceList"]: """Retrieve a list of configuration profile preferences within a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ConfigurationProfilePreferenceList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~automanage_client.models.ConfigurationProfilePreferenceList] + :return: An iterator like instance of either ConfigurationProfilePreferenceList or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~automanage_client.models.ConfigurationProfilePreferenceList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.ConfigurationProfilePreferenceList"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationProfilePreferenceList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ConfigurationProfilePreferenceList', pipeline_response) + deserialized = self._deserialize("ConfigurationProfilePreferenceList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -414,12 +619,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/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_operations.py b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_operations.py index 7aac97cd377a9..559532a2184a5 100644 --- a/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_operations.py +++ b/sdk/automanage/azure-mgmt-automanage/azure/mgmt/automanage/operations/_operations.py @@ -5,23 +5,50 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings -from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +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 .. import 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 msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = "2020-06-30-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Automanage/operations') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class Operations(object): """Operations operations. @@ -37,7 +64,7 @@ class Operations(object): :param deserializer: An object model deserializer. """ - models = models + models = _models def __init__(self, client, config, serializer, deserializer): self._client = client @@ -45,11 +72,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["models.OperationList"] + **kwargs: Any + ) -> Iterable["_models.OperationList"]: """Lists all of the available Automanage REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -57,32 +84,32 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~automanage_client.models.OperationList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.OperationList"] - error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-06-30-preview" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = 'application/json' - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationList', pipeline_response) + deserialized = self._deserialize("OperationList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -95,12 +122,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 )