diff --git a/sdk/connectedvmware/azure-mgmt-connectedvmware/_meta.json b/sdk/connectedvmware/azure-mgmt-connectedvmware/_meta.json index 63c837f6b944..89df7c0bf10a 100644 --- a/sdk/connectedvmware/azure-mgmt-connectedvmware/_meta.json +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.4.5", + "autorest": "3.7.2", "use": [ - "@autorest/python@5.8.4", - "@autorest/modelerfour@4.19.2" + "@autorest/python@5.12.0", + "@autorest/modelerfour@4.19.3" ], - "commit": "bd288bec4a31b114a29630cebc9b0c6c4c0686ed", + "commit": "c76db05c209e7e3273990521da05e77fd774174b", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/connectedvmware/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.8.4 --use=@autorest/modelerfour@4.19.2 --version=3.4.5", + "autorest_command": "autorest specification/connectedvmware/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/connectedvmware/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/__init__.py b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/__init__.py index 6e74ac1787a5..11059dcb4dc5 100644 --- a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/__init__.py +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['AzureArcVMwareManagementServiceAPI'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/_azure_arc_vmware_management_service_api.py b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/_azure_arc_vmware_management_service_api.py index 20aef933deee..35f1ffa124e1 100644 --- a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/_azure_arc_vmware_management_service_api.py +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/_azure_arc_vmware_management_service_api.py @@ -6,36 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import AzureArcVMwareManagementServiceAPIConfiguration +from .operations import ClustersOperations, DatastoresOperations, GuestAgentsOperations, HostsOperations, HybridIdentityMetadataOperations, InventoryItemsOperations, MachineExtensionsOperations, Operations, ResourcePoolsOperations, VCentersOperations, VirtualMachineTemplatesOperations, VirtualMachinesOperations, VirtualNetworksOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import AzureArcVMwareManagementServiceAPIConfiguration -from .operations import Operations -from .operations import ResourcePoolsOperations -from .operations import ClustersOperations -from .operations import HostsOperations -from .operations import DatastoresOperations -from .operations import VCentersOperations -from .operations import VirtualMachinesOperations -from .operations import VirtualMachineTemplatesOperations -from .operations import VirtualNetworksOperations -from .operations import InventoryItemsOperations -from .operations import HybridIdentityMetadataOperations -from .operations import MachineExtensionsOperations -from .operations import GuestAgentsOperations -from . import models - -class AzureArcVMwareManagementServiceAPI(object): +class AzureArcVMwareManagementServiceAPI: """Self service experience for VMware. :ivar operations: Operations operations @@ -53,13 +39,15 @@ class AzureArcVMwareManagementServiceAPI(object): :ivar virtual_machines: VirtualMachinesOperations operations :vartype virtual_machines: azure.mgmt.connectedvmware.operations.VirtualMachinesOperations :ivar virtual_machine_templates: VirtualMachineTemplatesOperations operations - :vartype virtual_machine_templates: azure.mgmt.connectedvmware.operations.VirtualMachineTemplatesOperations + :vartype virtual_machine_templates: + azure.mgmt.connectedvmware.operations.VirtualMachineTemplatesOperations :ivar virtual_networks: VirtualNetworksOperations operations :vartype virtual_networks: azure.mgmt.connectedvmware.operations.VirtualNetworksOperations :ivar inventory_items: InventoryItemsOperations operations :vartype inventory_items: azure.mgmt.connectedvmware.operations.InventoryItemsOperations :ivar hybrid_identity_metadata: HybridIdentityMetadataOperations operations - :vartype hybrid_identity_metadata: azure.mgmt.connectedvmware.operations.HybridIdentityMetadataOperations + :vartype hybrid_identity_metadata: + azure.mgmt.connectedvmware.operations.HybridIdentityMetadataOperations :ivar machine_extensions: MachineExtensionsOperations operations :vartype machine_extensions: azure.mgmt.connectedvmware.operations.MachineExtensionsOperations :ivar guest_agents: GuestAgentsOperations operations @@ -68,72 +56,66 @@ class AzureArcVMwareManagementServiceAPI(object): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The Subscription ID. :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 = AzureArcVMwareManagementServiceAPIConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = AzureArcVMwareManagementServiceAPIConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.resource_pools = ResourcePoolsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.clusters = ClustersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.hosts = HostsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.datastores = DatastoresOperations( - self._client, self._config, self._serialize, self._deserialize) - self.vcenters = VCentersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.virtual_machines = VirtualMachinesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_templates = VirtualMachineTemplatesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.virtual_networks = VirtualNetworksOperations( - self._client, self._config, self._serialize, self._deserialize) - self.inventory_items = InventoryItemsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.hybrid_identity_metadata = HybridIdentityMetadataOperations( - self._client, self._config, self._serialize, self._deserialize) - self.machine_extensions = MachineExtensionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.guest_agents = GuestAgentsOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.resource_pools = ResourcePoolsOperations(self._client, self._config, self._serialize, self._deserialize) + self.clusters = ClustersOperations(self._client, self._config, self._serialize, self._deserialize) + self.hosts = HostsOperations(self._client, self._config, self._serialize, self._deserialize) + self.datastores = DatastoresOperations(self._client, self._config, self._serialize, self._deserialize) + self.vcenters = VCentersOperations(self._client, self._config, self._serialize, self._deserialize) + self.virtual_machines = VirtualMachinesOperations(self._client, self._config, self._serialize, self._deserialize) + self.virtual_machine_templates = VirtualMachineTemplatesOperations(self._client, self._config, self._serialize, self._deserialize) + self.virtual_networks = VirtualNetworksOperations(self._client, self._config, self._serialize, self._deserialize) + self.inventory_items = InventoryItemsOperations(self._client, self._config, self._serialize, self._deserialize) + self.hybrid_identity_metadata = HybridIdentityMetadataOperations(self._client, self._config, self._serialize, self._deserialize) + self.machine_extensions = MachineExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.guest_agents = GuestAgentsOperations(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. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/_configuration.py b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/_configuration.py index 34eaaa582006..27200377be66 100644 --- a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/_configuration.py +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/_configuration.py @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class AzureArcVMwareManagementServiceAPIConfiguration(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(AzureArcVMwareManagementServiceAPIConfiguration, 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(AzureArcVMwareManagementServiceAPIConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +65,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/_metadata.json b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/_metadata.json index 3fe1d23163dd..b38a667c02e0 100644 --- a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/_metadata.json +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/_metadata.json @@ -5,13 +5,13 @@ "name": "AzureArcVMwareManagementServiceAPI", "filename": "_azure_arc_vmware_management_service_api", "description": "Self service experience for VMware.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AzureArcVMwareManagementServiceAPIConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AzureArcVMwareManagementServiceAPIConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AzureArcVMwareManagementServiceAPIConfiguration\"]}}, \"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\": [\"AzureArcVMwareManagementServiceAPIConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/_patch.py b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/_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/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/_vendor.py b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/_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/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/_version.py b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/_version.py index e5754a47ce68..8761a6c8ec5b 100644 --- a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/_version.py +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0b1" +VERSION = "0.1.1" diff --git a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/__init__.py b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/__init__.py index 9bee3ede0ebd..76f7deaaea6d 100644 --- a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/__init__.py +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/__init__.py @@ -8,3 +8,8 @@ from ._azure_arc_vmware_management_service_api import AzureArcVMwareManagementServiceAPI __all__ = ['AzureArcVMwareManagementServiceAPI'] + +# `._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/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/_azure_arc_vmware_management_service_api.py b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/_azure_arc_vmware_management_service_api.py index af1a589c110e..4dc3213dcde5 100644 --- a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/_azure_arc_vmware_management_service_api.py +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/_azure_arc_vmware_management_service_api.py @@ -6,34 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import AzureArcVMwareManagementServiceAPIConfiguration +from .operations import ClustersOperations, DatastoresOperations, GuestAgentsOperations, HostsOperations, HybridIdentityMetadataOperations, InventoryItemsOperations, MachineExtensionsOperations, Operations, ResourcePoolsOperations, VCentersOperations, VirtualMachineTemplatesOperations, VirtualMachinesOperations, VirtualNetworksOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import AzureArcVMwareManagementServiceAPIConfiguration -from .operations import Operations -from .operations import ResourcePoolsOperations -from .operations import ClustersOperations -from .operations import HostsOperations -from .operations import DatastoresOperations -from .operations import VCentersOperations -from .operations import VirtualMachinesOperations -from .operations import VirtualMachineTemplatesOperations -from .operations import VirtualNetworksOperations -from .operations import InventoryItemsOperations -from .operations import HybridIdentityMetadataOperations -from .operations import MachineExtensionsOperations -from .operations import GuestAgentsOperations -from .. import models - - -class AzureArcVMwareManagementServiceAPI(object): +class AzureArcVMwareManagementServiceAPI: """Self service experience for VMware. :ivar operations: Operations operations @@ -51,85 +39,84 @@ class AzureArcVMwareManagementServiceAPI(object): :ivar virtual_machines: VirtualMachinesOperations operations :vartype virtual_machines: azure.mgmt.connectedvmware.aio.operations.VirtualMachinesOperations :ivar virtual_machine_templates: VirtualMachineTemplatesOperations operations - :vartype virtual_machine_templates: azure.mgmt.connectedvmware.aio.operations.VirtualMachineTemplatesOperations + :vartype virtual_machine_templates: + azure.mgmt.connectedvmware.aio.operations.VirtualMachineTemplatesOperations :ivar virtual_networks: VirtualNetworksOperations operations :vartype virtual_networks: azure.mgmt.connectedvmware.aio.operations.VirtualNetworksOperations :ivar inventory_items: InventoryItemsOperations operations :vartype inventory_items: azure.mgmt.connectedvmware.aio.operations.InventoryItemsOperations :ivar hybrid_identity_metadata: HybridIdentityMetadataOperations operations - :vartype hybrid_identity_metadata: azure.mgmt.connectedvmware.aio.operations.HybridIdentityMetadataOperations + :vartype hybrid_identity_metadata: + azure.mgmt.connectedvmware.aio.operations.HybridIdentityMetadataOperations :ivar machine_extensions: MachineExtensionsOperations operations - :vartype machine_extensions: azure.mgmt.connectedvmware.aio.operations.MachineExtensionsOperations + :vartype machine_extensions: + azure.mgmt.connectedvmware.aio.operations.MachineExtensionsOperations :ivar guest_agents: GuestAgentsOperations operations :vartype guest_agents: azure.mgmt.connectedvmware.aio.operations.GuestAgentsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The Subscription ID. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = AzureArcVMwareManagementServiceAPIConfiguration(credential, subscription_id, **kwargs) + self._config = AzureArcVMwareManagementServiceAPIConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.resource_pools = ResourcePoolsOperations(self._client, self._config, self._serialize, self._deserialize) + self.clusters = ClustersOperations(self._client, self._config, self._serialize, self._deserialize) + self.hosts = HostsOperations(self._client, self._config, self._serialize, self._deserialize) + self.datastores = DatastoresOperations(self._client, self._config, self._serialize, self._deserialize) + self.vcenters = VCentersOperations(self._client, self._config, self._serialize, self._deserialize) + self.virtual_machines = VirtualMachinesOperations(self._client, self._config, self._serialize, self._deserialize) + self.virtual_machine_templates = VirtualMachineTemplatesOperations(self._client, self._config, self._serialize, self._deserialize) + self.virtual_networks = VirtualNetworksOperations(self._client, self._config, self._serialize, self._deserialize) + self.inventory_items = InventoryItemsOperations(self._client, self._config, self._serialize, self._deserialize) + self.hybrid_identity_metadata = HybridIdentityMetadataOperations(self._client, self._config, self._serialize, self._deserialize) + self.machine_extensions = MachineExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.guest_agents = GuestAgentsOperations(self._client, self._config, self._serialize, self._deserialize) + - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.resource_pools = ResourcePoolsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.clusters = ClustersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.hosts = HostsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.datastores = DatastoresOperations( - self._client, self._config, self._serialize, self._deserialize) - self.vcenters = VCentersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.virtual_machines = VirtualMachinesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.virtual_machine_templates = VirtualMachineTemplatesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.virtual_networks = VirtualNetworksOperations( - self._client, self._config, self._serialize, self._deserialize) - self.inventory_items = InventoryItemsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.hybrid_identity_metadata = HybridIdentityMetadataOperations( - self._client, self._config, self._serialize, self._deserialize) - self.machine_extensions = MachineExtensionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.guest_agents = GuestAgentsOperations( - self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/_configuration.py b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/_configuration.py index bd68e0905e76..4866173b3dcf 100644 --- a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/_configuration.py +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(AzureArcVMwareManagementServiceAPIConfiguration, 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(AzureArcVMwareManagementServiceAPIConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,4 +64,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/_patch.py b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/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/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_clusters_operations.py b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_clusters_operations.py index 2759532e00ee..ebbcf1692ead 100644 --- a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_clusters_operations.py +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_clusters_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._clusters_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -55,42 +60,31 @@ async def _create_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'Cluster') + _json = self._serialize.body(body, 'Cluster') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('Cluster', pipeline_response) @@ -102,8 +96,11 @@ async def _create_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters/{clusterName}'} # type: ignore + + @distributed_trace_async async def begin_create( self, resource_group_name: str, @@ -123,15 +120,19 @@ async def begin_create( :type body: ~azure.mgmt.connectedvmware.models.Cluster :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Cluster or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Cluster or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.Cluster] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Cluster"] lro_delay = kwargs.pop( 'polling_interval', @@ -143,27 +144,21 @@ async def begin_create( resource_group_name=resource_group_name, cluster_name=cluster_name, body=body, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('Cluster', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -175,8 +170,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters/{clusterName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -201,33 +198,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Cluster', pipeline_response) @@ -236,8 +223,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters/{clusterName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -265,41 +255,31 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'ResourcePatch') + _json = self._serialize.body(body, 'ResourcePatch') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Cluster', pipeline_response) @@ -308,8 +288,10 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters/{clusterName}'} # type: ignore + async def _delete_initial( self, resource_group_name: str, @@ -322,42 +304,32 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if force is not None: - query_parameters['force'] = self._serialize.query("force", force, 'bool') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + force=force, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters/{clusterName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -377,15 +349,17 @@ async def begin_delete( :type force: bool :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -400,21 +374,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -426,8 +393,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters/{clusterName}'} # type: ignore + @distributed_trace def list( self, **kwargs: Any @@ -438,7 +407,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ClustersList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.ClustersList] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.ClustersList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ClustersList"] @@ -446,34 +416,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ClustersList', pipeline_response) + deserialized = self._deserialize("ClustersList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -486,17 +451,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/clusters'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -510,7 +477,8 @@ def list_by_resource_group( :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ClustersList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.ClustersList] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.ClustersList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ClustersList"] @@ -518,35 +486,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ClustersList', pipeline_response) + deserialized = self._deserialize("ClustersList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -559,12 +523,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_datastores_operations.py b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_datastores_operations.py index 2bc7a9fe757f..208128f1a4a2 100644 --- a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_datastores_operations.py +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_datastores_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._datastores_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -55,42 +60,31 @@ async def _create_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'datastoreName': self._serialize.url("datastore_name", datastore_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'Datastore') + _json = self._serialize.body(body, 'Datastore') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + datastore_name=datastore_name, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('Datastore', pipeline_response) @@ -102,8 +96,11 @@ async def _create_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores/{datastoreName}'} # type: ignore + + @distributed_trace_async async def begin_create( self, resource_group_name: str, @@ -123,15 +120,19 @@ async def begin_create( :type body: ~azure.mgmt.connectedvmware.models.Datastore :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Datastore or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Datastore or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.Datastore] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Datastore"] lro_delay = kwargs.pop( 'polling_interval', @@ -143,27 +144,21 @@ async def begin_create( resource_group_name=resource_group_name, datastore_name=datastore_name, body=body, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('Datastore', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'datastoreName': self._serialize.url("datastore_name", datastore_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -175,8 +170,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores/{datastoreName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -201,33 +198,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'datastoreName': self._serialize.url("datastore_name", datastore_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + datastore_name=datastore_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Datastore', pipeline_response) @@ -236,8 +223,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores/{datastoreName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -265,41 +255,31 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'datastoreName': self._serialize.url("datastore_name", datastore_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'ResourcePatch') + _json = self._serialize.body(body, 'ResourcePatch') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + datastore_name=datastore_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Datastore', pipeline_response) @@ -308,8 +288,10 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores/{datastoreName}'} # type: ignore + async def _delete_initial( self, resource_group_name: str, @@ -322,42 +304,32 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'datastoreName': self._serialize.url("datastore_name", datastore_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if force is not None: - query_parameters['force'] = self._serialize.query("force", force, 'bool') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + datastore_name=datastore_name, + force=force, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores/{datastoreName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -377,15 +349,17 @@ async def begin_delete( :type force: bool :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -400,21 +374,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'datastoreName': self._serialize.url("datastore_name", datastore_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -426,8 +393,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores/{datastoreName}'} # type: ignore + @distributed_trace def list( self, **kwargs: Any @@ -438,7 +407,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DatastoresList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.DatastoresList] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.DatastoresList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DatastoresList"] @@ -446,34 +416,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DatastoresList', pipeline_response) + deserialized = self._deserialize("DatastoresList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -486,17 +451,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/datastores'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -510,7 +477,8 @@ def list_by_resource_group( :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either DatastoresList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.DatastoresList] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.DatastoresList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DatastoresList"] @@ -518,35 +486,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DatastoresList', pipeline_response) + deserialized = self._deserialize("DatastoresList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -559,12 +523,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_guest_agents_operations.py b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_guest_agents_operations.py index 3f25196fc2f8..5a0e27899886 100644 --- a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_guest_agents_operations.py +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_guest_agents_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._guest_agents_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_by_vm_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -56,43 +61,32 @@ async def _create_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'GuestAgent') + _json = self._serialize.body(body, 'GuestAgent') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + name=name, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('GuestAgent', pipeline_response) @@ -104,8 +98,11 @@ async def _create_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/guestAgents/{name}'} # type: ignore + + @distributed_trace_async async def begin_create( self, resource_group_name: str, @@ -128,15 +125,19 @@ async def begin_create( :type body: ~azure.mgmt.connectedvmware.models.GuestAgent :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either GuestAgent or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GuestAgent or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.GuestAgent] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestAgent"] lro_delay = kwargs.pop( 'polling_interval', @@ -149,28 +150,21 @@ async def begin_create( virtual_machine_name=virtual_machine_name, name=name, body=body, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GuestAgent', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -182,8 +176,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/guestAgents/{name}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -211,34 +207,24 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + name=name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('GuestAgent', pipeline_response) @@ -247,8 +233,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/guestAgents/{name}'} # type: ignore + async def _delete_initial( self, resource_group_name: str, @@ -261,41 +249,32 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + name=name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/guestAgents/{name}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -315,15 +294,17 @@ async def begin_delete( :type name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -338,22 +319,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -365,8 +338,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/guestAgents/{name}'} # type: ignore + @distributed_trace def list_by_vm( self, resource_group_name: str, @@ -383,7 +358,8 @@ def list_by_vm( :type virtual_machine_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either GuestAgentList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.GuestAgentList] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.GuestAgentList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestAgentList"] @@ -391,36 +367,33 @@ def list_by_vm( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_vm.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - 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_vm_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + template_url=self.list_by_vm.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(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_vm_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_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('GuestAgentList', pipeline_response) + deserialized = self._deserialize("GuestAgentList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -433,12 +406,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_hosts_operations.py b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_hosts_operations.py index 342b008d0b40..5475ec7ff4bf 100644 --- a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_hosts_operations.py +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_hosts_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._hosts_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -55,42 +60,31 @@ async def _create_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'hostName': self._serialize.url("host_name", host_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'Host') + _json = self._serialize.body(body, 'Host') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + host_name=host_name, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('Host', pipeline_response) @@ -102,8 +96,11 @@ async def _create_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts/{hostName}'} # type: ignore + + @distributed_trace_async async def begin_create( self, resource_group_name: str, @@ -123,15 +120,18 @@ async def begin_create( :type body: ~azure.mgmt.connectedvmware.models.Host :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Host or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.Host] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Host"] lro_delay = kwargs.pop( 'polling_interval', @@ -143,27 +143,21 @@ async def begin_create( resource_group_name=resource_group_name, host_name=host_name, body=body, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('Host', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'hostName': self._serialize.url("host_name", host_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -175,8 +169,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts/{hostName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -201,33 +197,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'hostName': self._serialize.url("host_name", host_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + host_name=host_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Host', pipeline_response) @@ -236,8 +222,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts/{hostName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -265,41 +254,31 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'hostName': self._serialize.url("host_name", host_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'ResourcePatch') + _json = self._serialize.body(body, 'ResourcePatch') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + host_name=host_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Host', pipeline_response) @@ -308,8 +287,10 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts/{hostName}'} # type: ignore + async def _delete_initial( self, resource_group_name: str, @@ -322,42 +303,32 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'hostName': self._serialize.url("host_name", host_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if force is not None: - query_parameters['force'] = self._serialize.query("force", force, 'bool') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + host_name=host_name, + force=force, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts/{hostName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -377,15 +348,17 @@ async def begin_delete( :type force: bool :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -400,21 +373,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'hostName': self._serialize.url("host_name", host_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -426,8 +392,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts/{hostName}'} # type: ignore + @distributed_trace def list( self, **kwargs: Any @@ -446,34 +414,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('HostsList', pipeline_response) + deserialized = self._deserialize("HostsList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -486,17 +449,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/hosts'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -518,35 +483,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('HostsList', pipeline_response) + deserialized = self._deserialize("HostsList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -559,12 +520,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_hybrid_identity_metadata_operations.py b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_hybrid_identity_metadata_operations.py index d8a86e3a9895..3c9f40768786 100644 --- a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_hybrid_identity_metadata_operations.py +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_hybrid_identity_metadata_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._hybrid_identity_metadata_operations import build_create_request, build_delete_request, build_get_request, build_list_by_vm_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create( self, resource_group_name: str, @@ -71,42 +77,32 @@ async def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - 'metadataName': self._serialize.url("metadata_name", metadata_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'HybridIdentityMetadata') + _json = self._serialize.body(body, 'HybridIdentityMetadata') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_create_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + metadata_name=metadata_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('HybridIdentityMetadata', pipeline_response) @@ -115,8 +111,11 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/hybridIdentityMetadata/{metadataName}'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -144,34 +143,24 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - 'metadataName': self._serialize.url("metadata_name", metadata_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + metadata_name=metadata_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('HybridIdentityMetadata', pipeline_response) @@ -180,8 +169,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/hybridIdentityMetadata/{metadataName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -209,34 +201,24 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - 'metadataName': self._serialize.url("metadata_name", metadata_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + metadata_name=metadata_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -244,6 +226,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/hybridIdentityMetadata/{metadataName}'} # type: ignore + + @distributed_trace def list_by_vm( self, resource_group_name: str, @@ -259,8 +243,10 @@ def list_by_vm( :param virtual_machine_name: Name of the vm. :type virtual_machine_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either HybridIdentityMetadataList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.HybridIdentityMetadataList] + :return: An iterator like instance of either HybridIdentityMetadataList or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.HybridIdentityMetadataList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.HybridIdentityMetadataList"] @@ -268,36 +254,33 @@ def list_by_vm( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_vm.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - 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_vm_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + template_url=self.list_by_vm.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(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_vm_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_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('HybridIdentityMetadataList', pipeline_response) + deserialized = self._deserialize("HybridIdentityMetadataList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -310,12 +293,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_inventory_items_operations.py b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_inventory_items_operations.py index 056f35faa072..a860685cd1c4 100644 --- a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_inventory_items_operations.py +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_inventory_items_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._inventory_items_operations import build_create_request, build_delete_request, build_get_request, build_list_by_v_center_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create( self, resource_group_name: str, @@ -71,42 +77,32 @@ async def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'vcenterName': self._serialize.url("vcenter_name", vcenter_name, 'str'), - 'inventoryItemName': self._serialize.url("inventory_item_name", inventory_item_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'InventoryItem') + _json = self._serialize.body(body, 'InventoryItem') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_create_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vcenter_name=vcenter_name, + inventory_item_name=inventory_item_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('InventoryItem', pipeline_response) @@ -115,8 +111,11 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}/inventoryItems/{inventoryItemName}'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -144,34 +143,24 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'vcenterName': self._serialize.url("vcenter_name", vcenter_name, 'str'), - 'inventoryItemName': self._serialize.url("inventory_item_name", inventory_item_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vcenter_name=vcenter_name, + inventory_item_name=inventory_item_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('InventoryItem', pipeline_response) @@ -180,8 +169,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}/inventoryItems/{inventoryItemName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -209,34 +201,24 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'vcenterName': self._serialize.url("vcenter_name", vcenter_name, 'str'), - 'inventoryItemName': self._serialize.url("inventory_item_name", inventory_item_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vcenter_name=vcenter_name, + inventory_item_name=inventory_item_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -244,6 +226,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}/inventoryItems/{inventoryItemName}'} # type: ignore + + @distributed_trace def list_by_v_center( self, resource_group_name: str, @@ -260,7 +244,8 @@ def list_by_v_center( :type vcenter_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either InventoryItemsList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.InventoryItemsList] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.InventoryItemsList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.InventoryItemsList"] @@ -268,36 +253,33 @@ def list_by_v_center( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_v_center.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'vcenterName': self._serialize.url("vcenter_name", vcenter_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - 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_v_center_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vcenter_name=vcenter_name, + template_url=self.list_by_v_center.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(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_v_center_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vcenter_name=vcenter_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('InventoryItemsList', pipeline_response) + deserialized = self._deserialize("InventoryItemsList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -310,12 +292,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_machine_extensions_operations.py b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_machine_extensions_operations.py index d07f35c6c0e0..8a1cbdd86769 100644 --- a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_machine_extensions_operations.py +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_machine_extensions_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._machine_extensions_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -56,40 +61,29 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'extensionName': self._serialize.url("extension_name", extension_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(extension_parameters, 'MachineExtension') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + extension_name=extension_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(extension_parameters, 'MachineExtension') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('MachineExtension', pipeline_response) @@ -101,8 +95,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -123,15 +120,19 @@ async def begin_create_or_update( :type extension_parameters: ~azure.mgmt.connectedvmware.models.MachineExtension :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either MachineExtension or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MachineExtension or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.MachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.MachineExtension"] lro_delay = kwargs.pop( 'polling_interval', @@ -144,28 +145,21 @@ async def begin_create_or_update( name=name, extension_name=extension_name, extension_parameters=extension_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('MachineExtension', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'extensionName': self._serialize.url("extension_name", extension_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -177,6 +171,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}'} # type: ignore async def _update_initial( @@ -192,40 +187,29 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'extensionName': self._serialize.url("extension_name", extension_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(extension_parameters, 'MachineExtensionUpdate') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + extension_name=extension_name, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(extension_parameters, 'MachineExtensionUpdate') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('MachineExtension', pipeline_response) @@ -237,8 +221,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -259,15 +246,19 @@ async def begin_update( :type extension_parameters: ~azure.mgmt.connectedvmware.models.MachineExtensionUpdate :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either MachineExtension or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MachineExtension or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.MachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.MachineExtension"] lro_delay = kwargs.pop( 'polling_interval', @@ -280,28 +271,21 @@ async def begin_update( name=name, extension_name=extension_name, extension_parameters=extension_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('MachineExtension', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'extensionName': self._serialize.url("extension_name", extension_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -313,6 +297,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}'} # type: ignore async def _delete_initial( @@ -327,41 +312,32 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'extensionName': self._serialize.url("extension_name", extension_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + extension_name=extension_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -379,15 +355,17 @@ async def begin_delete( :type extension_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -402,22 +380,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'extensionName': self._serialize.url("extension_name", extension_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -429,8 +399,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -456,34 +428,24 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'extensionName': self._serialize.url("extension_name", extension_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + extension_name=extension_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('MachineExtension', pipeline_response) @@ -492,8 +454,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}'} # type: ignore + + @distributed_trace def list( self, resource_group_name: str, @@ -510,8 +475,10 @@ def list( :param expand: The expand expression to apply on the operation. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MachineExtensionsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.MachineExtensionsListResult] + :return: An iterator like instance of either MachineExtensionsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.MachineExtensionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.MachineExtensionsListResult"] @@ -519,38 +486,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + expand=expand, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + expand=expand, + 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('MachineExtensionsListResult', pipeline_response) + deserialized = self._deserialize("MachineExtensionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -563,12 +527,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_operations.py b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_operations.py index 8c28a2ae19da..84828a98e4db 100644 --- a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_operations.py +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,7 +55,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationsList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.OperationsList] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.OperationsList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationsList"] @@ -57,30 +64,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # 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('OperationsList', pipeline_response) + deserialized = self._deserialize("OperationsList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -93,12 +97,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_resource_pools_operations.py b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_resource_pools_operations.py index 05d871c51c7c..ad417a535dcd 100644 --- a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_resource_pools_operations.py +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_resource_pools_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._resource_pools_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -55,42 +60,31 @@ async def _create_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourcePoolName': self._serialize.url("resource_pool_name", resource_pool_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'ResourcePool') + _json = self._serialize.body(body, 'ResourcePool') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_pool_name=resource_pool_name, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('ResourcePool', pipeline_response) @@ -102,8 +96,11 @@ async def _create_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools/{resourcePoolName}'} # type: ignore + + @distributed_trace_async async def begin_create( self, resource_group_name: str, @@ -123,15 +120,19 @@ async def begin_create( :type body: ~azure.mgmt.connectedvmware.models.ResourcePool :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either ResourcePool or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ResourcePool or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.ResourcePool] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourcePool"] lro_delay = kwargs.pop( 'polling_interval', @@ -143,27 +144,21 @@ async def begin_create( resource_group_name=resource_group_name, resource_pool_name=resource_pool_name, body=body, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ResourcePool', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourcePoolName': self._serialize.url("resource_pool_name", resource_pool_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -175,8 +170,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools/{resourcePoolName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -201,33 +198,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourcePoolName': self._serialize.url("resource_pool_name", resource_pool_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_pool_name=resource_pool_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ResourcePool', pipeline_response) @@ -236,8 +223,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools/{resourcePoolName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -265,41 +255,31 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourcePoolName': self._serialize.url("resource_pool_name", resource_pool_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'ResourcePatch') + _json = self._serialize.body(body, 'ResourcePatch') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_pool_name=resource_pool_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ResourcePool', pipeline_response) @@ -308,8 +288,10 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools/{resourcePoolName}'} # type: ignore + async def _delete_initial( self, resource_group_name: str, @@ -322,42 +304,32 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourcePoolName': self._serialize.url("resource_pool_name", resource_pool_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if force is not None: - query_parameters['force'] = self._serialize.query("force", force, 'bool') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_pool_name=resource_pool_name, + force=force, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools/{resourcePoolName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -377,15 +349,17 @@ async def begin_delete( :type force: bool :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -400,21 +374,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourcePoolName': self._serialize.url("resource_pool_name", resource_pool_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -426,8 +393,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools/{resourcePoolName}'} # type: ignore + @distributed_trace def list( self, **kwargs: Any @@ -438,7 +407,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourcePoolsList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.ResourcePoolsList] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.ResourcePoolsList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourcePoolsList"] @@ -446,34 +416,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ResourcePoolsList', pipeline_response) + deserialized = self._deserialize("ResourcePoolsList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -486,17 +451,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -510,7 +477,8 @@ def list_by_resource_group( :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourcePoolsList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.ResourcePoolsList] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.ResourcePoolsList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourcePoolsList"] @@ -518,35 +486,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ResourcePoolsList', pipeline_response) + deserialized = self._deserialize("ResourcePoolsList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -559,12 +523,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_vcenters_operations.py b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_vcenters_operations.py index 94d34c438217..cc26ddea909c 100644 --- a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_vcenters_operations.py +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_vcenters_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._vcenters_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -55,42 +60,31 @@ async def _create_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'vcenterName': self._serialize.url("vcenter_name", vcenter_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'VCenter') + _json = self._serialize.body(body, 'VCenter') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vcenter_name=vcenter_name, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('VCenter', pipeline_response) @@ -102,8 +96,11 @@ async def _create_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}'} # type: ignore + + @distributed_trace_async async def begin_create( self, resource_group_name: str, @@ -123,15 +120,19 @@ async def begin_create( :type body: ~azure.mgmt.connectedvmware.models.VCenter :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either VCenter or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either VCenter or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.VCenter] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.VCenter"] lro_delay = kwargs.pop( 'polling_interval', @@ -143,27 +144,21 @@ async def begin_create( resource_group_name=resource_group_name, vcenter_name=vcenter_name, body=body, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('VCenter', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'vcenterName': self._serialize.url("vcenter_name", vcenter_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -175,8 +170,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -201,33 +198,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'vcenterName': self._serialize.url("vcenter_name", vcenter_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vcenter_name=vcenter_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('VCenter', pipeline_response) @@ -236,8 +223,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -265,41 +255,31 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'vcenterName': self._serialize.url("vcenter_name", vcenter_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'ResourcePatch') + _json = self._serialize.body(body, 'ResourcePatch') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vcenter_name=vcenter_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('VCenter', pipeline_response) @@ -308,8 +288,10 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}'} # type: ignore + async def _delete_initial( self, resource_group_name: str, @@ -322,42 +304,32 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'vcenterName': self._serialize.url("vcenter_name", vcenter_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if force is not None: - query_parameters['force'] = self._serialize.query("force", force, 'bool') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vcenter_name=vcenter_name, + force=force, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -377,15 +349,17 @@ async def begin_delete( :type force: bool :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -400,21 +374,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'vcenterName': self._serialize.url("vcenter_name", vcenter_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -426,8 +393,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}'} # type: ignore + @distributed_trace def list( self, **kwargs: Any @@ -438,7 +407,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either VCentersList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.VCentersList] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.VCentersList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.VCentersList"] @@ -446,34 +416,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('VCentersList', pipeline_response) + deserialized = self._deserialize("VCentersList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -486,17 +451,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/vcenters'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -510,7 +477,8 @@ def list_by_resource_group( :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either VCentersList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.VCentersList] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.VCentersList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.VCentersList"] @@ -518,35 +486,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('VCentersList', pipeline_response) + deserialized = self._deserialize("VCentersList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -559,12 +523,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_virtual_machine_templates_operations.py b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_virtual_machine_templates_operations.py index 6b829b6d708b..0a7d5847d8d2 100644 --- a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_virtual_machine_templates_operations.py +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_virtual_machine_templates_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._virtual_machine_templates_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -55,42 +60,31 @@ async def _create_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineTemplateName': self._serialize.url("virtual_machine_template_name", virtual_machine_template_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'VirtualMachineTemplate') + _json = self._serialize.body(body, 'VirtualMachineTemplate') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_template_name=virtual_machine_template_name, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('VirtualMachineTemplate', pipeline_response) @@ -102,8 +96,11 @@ async def _create_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates/{virtualMachineTemplateName}'} # type: ignore + + @distributed_trace_async async def begin_create( self, resource_group_name: str, @@ -123,15 +120,20 @@ async def begin_create( :type body: ~azure.mgmt.connectedvmware.models.VirtualMachineTemplate :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either VirtualMachineTemplate or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.VirtualMachineTemplate] - :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 VirtualMachineTemplate or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.VirtualMachineTemplate] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineTemplate"] lro_delay = kwargs.pop( 'polling_interval', @@ -143,27 +145,21 @@ async def begin_create( resource_group_name=resource_group_name, virtual_machine_template_name=virtual_machine_template_name, body=body, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('VirtualMachineTemplate', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineTemplateName': self._serialize.url("virtual_machine_template_name", virtual_machine_template_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -175,8 +171,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates/{virtualMachineTemplateName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -201,33 +199,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineTemplateName': self._serialize.url("virtual_machine_template_name", virtual_machine_template_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_template_name=virtual_machine_template_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('VirtualMachineTemplate', pipeline_response) @@ -236,8 +224,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates/{virtualMachineTemplateName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -265,41 +256,31 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineTemplateName': self._serialize.url("virtual_machine_template_name", virtual_machine_template_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'ResourcePatch') + _json = self._serialize.body(body, 'ResourcePatch') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_template_name=virtual_machine_template_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('VirtualMachineTemplate', pipeline_response) @@ -308,8 +289,10 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates/{virtualMachineTemplateName}'} # type: ignore + async def _delete_initial( self, resource_group_name: str, @@ -322,42 +305,32 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineTemplateName': self._serialize.url("virtual_machine_template_name", virtual_machine_template_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if force is not None: - query_parameters['force'] = self._serialize.query("force", force, 'bool') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_template_name=virtual_machine_template_name, + force=force, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates/{virtualMachineTemplateName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -377,15 +350,17 @@ async def begin_delete( :type force: bool :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -400,21 +375,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineTemplateName': self._serialize.url("virtual_machine_template_name", virtual_machine_template_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -426,8 +394,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates/{virtualMachineTemplateName}'} # type: ignore + @distributed_trace def list( self, **kwargs: Any @@ -437,8 +407,10 @@ def list( List of virtualMachineTemplates in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either VirtualMachineTemplatesList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.VirtualMachineTemplatesList] + :return: An iterator like instance of either VirtualMachineTemplatesList or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.VirtualMachineTemplatesList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineTemplatesList"] @@ -446,34 +418,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('VirtualMachineTemplatesList', pipeline_response) + deserialized = self._deserialize("VirtualMachineTemplatesList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -486,17 +453,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -509,8 +478,10 @@ def list_by_resource_group( :param resource_group_name: The Resource Group Name. :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 VirtualMachineTemplatesList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.VirtualMachineTemplatesList] + :return: An iterator like instance of either VirtualMachineTemplatesList or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.VirtualMachineTemplatesList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineTemplatesList"] @@ -518,35 +489,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('VirtualMachineTemplatesList', pipeline_response) + deserialized = self._deserialize("VirtualMachineTemplatesList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -559,12 +526,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_virtual_machines_operations.py b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_virtual_machines_operations.py index 87786f136f65..a5526aa8cb44 100644 --- a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_virtual_machines_operations.py +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_virtual_machines_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._virtual_machines_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_request, build_restart_request_initial, build_start_request_initial, build_stop_request_initial, build_update_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -55,42 +60,31 @@ async def _create_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'VirtualMachine') + _json = self._serialize.body(body, 'VirtualMachine') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('VirtualMachine', pipeline_response) @@ -102,8 +96,11 @@ async def _create_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}'} # type: ignore + + @distributed_trace_async async def begin_create( self, resource_group_name: str, @@ -123,15 +120,19 @@ async def begin_create( :type body: ~azure.mgmt.connectedvmware.models.VirtualMachine :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either VirtualMachine or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either VirtualMachine or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.VirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', @@ -143,27 +144,21 @@ async def begin_create( resource_group_name=resource_group_name, virtual_machine_name=virtual_machine_name, body=body, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('VirtualMachine', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -175,8 +170,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -201,33 +198,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('VirtualMachine', pipeline_response) @@ -236,57 +223,49 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}'} # type: ignore + async def _update_initial( self, resource_group_name: str, virtual_machine_name: str, body: Optional["_models.VirtualMachineUpdate"] = None, **kwargs: Any - ) -> "_models.VirtualMachine": - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + ) -> Optional["_models.VirtualMachine"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachine"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'VirtualMachineUpdate') + _json = self._serialize.body(body, 'VirtualMachineUpdate') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + content_type=content_type, + json=_json, + template_url=self._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]: + if response.status_code not in [200, 201, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = None if response.status_code == 200: deserialized = self._deserialize('VirtualMachine', pipeline_response) @@ -297,8 +276,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -318,15 +300,19 @@ async def begin_update( :type body: ~azure.mgmt.connectedvmware.models.VirtualMachineUpdate :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either VirtualMachine or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either VirtualMachine or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.VirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', @@ -338,27 +324,21 @@ async def begin_update( resource_group_name=resource_group_name, virtual_machine_name=virtual_machine_name, body=body, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('VirtualMachine', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -370,6 +350,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}'} # type: ignore async def _delete_initial( @@ -384,42 +365,32 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if force is not None: - query_parameters['force'] = self._serialize.query("force", force, 'bool') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + force=force, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -439,15 +410,17 @@ async def begin_delete( :type force: bool :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -462,21 +435,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -488,6 +454,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}'} # type: ignore async def _stop_initial( @@ -502,48 +469,39 @@ async def _stop_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._stop_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'StopVirtualMachineOptions') + _json = self._serialize.body(body, 'StopVirtualMachineOptions') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_stop_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + content_type=content_type, + json=_json, + template_url=self._stop_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, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _stop_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/stop'} # type: ignore + + @distributed_trace_async async def begin_stop( self, resource_group_name: str, @@ -563,15 +521,18 @@ async def begin_stop( :type body: ~azure.mgmt.connectedvmware.models.StopVirtualMachineOptions :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + 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[None] lro_delay = kwargs.pop( 'polling_interval', @@ -583,24 +544,18 @@ async def begin_stop( resource_group_name=resource_group_name, virtual_machine_name=virtual_machine_name, body=body, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -612,6 +567,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_stop.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/stop'} # type: ignore async def _start_initial( @@ -625,40 +581,31 @@ async def _start_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self._start_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_start_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + template_url=self._start_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _start_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/start'} # type: ignore + + @distributed_trace_async async def begin_start( self, resource_group_name: str, @@ -675,15 +622,17 @@ async def begin_start( :type virtual_machine_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -697,21 +646,14 @@ async def begin_start( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -723,6 +665,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_start.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/start'} # type: ignore async def _restart_initial( @@ -736,40 +679,31 @@ async def _restart_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self._restart_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_restart_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + template_url=self._restart_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _restart_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/restart'} # type: ignore + + @distributed_trace_async async def begin_restart( self, resource_group_name: str, @@ -786,15 +720,17 @@ async def begin_restart( :type virtual_machine_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -808,21 +744,14 @@ async def begin_restart( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -834,8 +763,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_restart.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/restart'} # type: ignore + @distributed_trace def list( self, **kwargs: Any @@ -846,7 +777,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either VirtualMachinesList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.VirtualMachinesList] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.VirtualMachinesList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachinesList"] @@ -854,34 +786,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('VirtualMachinesList', pipeline_response) + deserialized = self._deserialize("VirtualMachinesList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -894,17 +821,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -918,7 +847,8 @@ def list_by_resource_group( :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either VirtualMachinesList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.VirtualMachinesList] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.VirtualMachinesList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachinesList"] @@ -926,35 +856,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('VirtualMachinesList', pipeline_response) + deserialized = self._deserialize("VirtualMachinesList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -967,12 +893,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_virtual_networks_operations.py b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_virtual_networks_operations.py index 36bd2c415842..ea77cb74df8a 100644 --- a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_virtual_networks_operations.py +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_virtual_networks_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._virtual_networks_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -55,42 +60,31 @@ async def _create_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualNetworkName': self._serialize.url("virtual_network_name", virtual_network_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'VirtualNetwork') + _json = self._serialize.body(body, 'VirtualNetwork') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_network_name=virtual_network_name, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('VirtualNetwork', pipeline_response) @@ -102,8 +96,11 @@ async def _create_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks/{virtualNetworkName}'} # type: ignore + + @distributed_trace_async async def begin_create( self, resource_group_name: str, @@ -123,15 +120,19 @@ async def begin_create( :type body: ~azure.mgmt.connectedvmware.models.VirtualNetwork :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either VirtualNetwork or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either VirtualNetwork or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.VirtualNetwork] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetwork"] lro_delay = kwargs.pop( 'polling_interval', @@ -143,27 +144,21 @@ async def begin_create( resource_group_name=resource_group_name, virtual_network_name=virtual_network_name, body=body, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('VirtualNetwork', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualNetworkName': self._serialize.url("virtual_network_name", virtual_network_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -175,8 +170,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks/{virtualNetworkName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -201,33 +198,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualNetworkName': self._serialize.url("virtual_network_name", virtual_network_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_network_name=virtual_network_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('VirtualNetwork', pipeline_response) @@ -236,8 +223,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks/{virtualNetworkName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -265,41 +255,31 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualNetworkName': self._serialize.url("virtual_network_name", virtual_network_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'ResourcePatch') + _json = self._serialize.body(body, 'ResourcePatch') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_network_name=virtual_network_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('VirtualNetwork', pipeline_response) @@ -308,8 +288,10 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks/{virtualNetworkName}'} # type: ignore + async def _delete_initial( self, resource_group_name: str, @@ -322,42 +304,32 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualNetworkName': self._serialize.url("virtual_network_name", virtual_network_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if force is not None: - query_parameters['force'] = self._serialize.query("force", force, 'bool') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_network_name=virtual_network_name, + force=force, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks/{virtualNetworkName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -377,15 +349,17 @@ async def begin_delete( :type force: bool :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -400,21 +374,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualNetworkName': self._serialize.url("virtual_network_name", virtual_network_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -426,8 +393,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks/{virtualNetworkName}'} # type: ignore + @distributed_trace def list( self, **kwargs: Any @@ -438,7 +407,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either VirtualNetworksList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.VirtualNetworksList] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.VirtualNetworksList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetworksList"] @@ -446,34 +416,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('VirtualNetworksList', pipeline_response) + deserialized = self._deserialize("VirtualNetworksList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -486,17 +451,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -510,7 +477,8 @@ def list_by_resource_group( :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either VirtualNetworksList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.VirtualNetworksList] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.VirtualNetworksList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetworksList"] @@ -518,35 +486,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('VirtualNetworksList', pipeline_response) + deserialized = self._deserialize("VirtualNetworksList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -559,12 +523,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/models/__init__.py b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/models/__init__.py index 137a2f8f8560..3f2c19ff4ea6 100644 --- a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/models/__init__.py +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/models/__init__.py @@ -6,150 +6,78 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import Cluster - from ._models_py3 import ClusterInventoryItem - from ._models_py3 import ClustersList - from ._models_py3 import Condition - from ._models_py3 import Datastore - from ._models_py3 import DatastoreInventoryItem - from ._models_py3 import DatastoresList - from ._models_py3 import ErrorDefinition - from ._models_py3 import ErrorDetail - from ._models_py3 import ErrorResponse - from ._models_py3 import ExtendedLocation - from ._models_py3 import GuestAgent - from ._models_py3 import GuestAgentList - from ._models_py3 import GuestAgentProfile - from ._models_py3 import GuestCredential - from ._models_py3 import HardwareProfile - from ._models_py3 import Host - from ._models_py3 import HostInventoryItem - from ._models_py3 import HostsList - from ._models_py3 import HttpProxyConfiguration - from ._models_py3 import HybridIdentityMetadata - from ._models_py3 import HybridIdentityMetadataList - from ._models_py3 import Identity - from ._models_py3 import InventoryItem - from ._models_py3 import InventoryItemDetails - from ._models_py3 import InventoryItemProperties - from ._models_py3 import InventoryItemsList - from ._models_py3 import MachineExtension - from ._models_py3 import MachineExtensionInstanceView - from ._models_py3 import MachineExtensionInstanceViewStatus - from ._models_py3 import MachineExtensionPropertiesInstanceView - from ._models_py3 import MachineExtensionUpdate - from ._models_py3 import MachineExtensionsListResult - from ._models_py3 import NetworkInterface - from ._models_py3 import NetworkInterfaceUpdate - from ._models_py3 import NetworkProfile - from ._models_py3 import NetworkProfileUpdate - from ._models_py3 import NicIPAddressSettings - from ._models_py3 import NicIPSettings - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationsList - from ._models_py3 import OsProfile - from ._models_py3 import PlacementProfile - from ._models_py3 import ProxyResource - from ._models_py3 import Resource - from ._models_py3 import ResourcePatch - from ._models_py3 import ResourcePool - from ._models_py3 import ResourcePoolInventoryItem - from ._models_py3 import ResourcePoolsList - from ._models_py3 import ResourceStatus - from ._models_py3 import StopVirtualMachineOptions - from ._models_py3 import StorageProfile - from ._models_py3 import StorageProfileUpdate - from ._models_py3 import SystemData - from ._models_py3 import VCenter - from ._models_py3 import VCentersList - from ._models_py3 import VICredential - from ._models_py3 import VirtualDisk - from ._models_py3 import VirtualDiskUpdate - from ._models_py3 import VirtualMachine - from ._models_py3 import VirtualMachineInventoryItem - from ._models_py3 import VirtualMachineTemplate - from ._models_py3 import VirtualMachineTemplateInventoryItem - from ._models_py3 import VirtualMachineTemplatesList - from ._models_py3 import VirtualMachineUpdate - from ._models_py3 import VirtualMachinesList - from ._models_py3 import VirtualNetwork - from ._models_py3 import VirtualNetworkInventoryItem - from ._models_py3 import VirtualNetworksList - from ._models_py3 import VirtualSCSIController -except (SyntaxError, ImportError): - from ._models import Cluster # type: ignore - from ._models import ClusterInventoryItem # type: ignore - from ._models import ClustersList # type: ignore - from ._models import Condition # type: ignore - from ._models import Datastore # type: ignore - from ._models import DatastoreInventoryItem # type: ignore - from ._models import DatastoresList # type: ignore - from ._models import ErrorDefinition # type: ignore - from ._models import ErrorDetail # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import ExtendedLocation # type: ignore - from ._models import GuestAgent # type: ignore - from ._models import GuestAgentList # type: ignore - from ._models import GuestAgentProfile # type: ignore - from ._models import GuestCredential # type: ignore - from ._models import HardwareProfile # type: ignore - from ._models import Host # type: ignore - from ._models import HostInventoryItem # type: ignore - from ._models import HostsList # type: ignore - from ._models import HttpProxyConfiguration # type: ignore - from ._models import HybridIdentityMetadata # type: ignore - from ._models import HybridIdentityMetadataList # type: ignore - from ._models import Identity # type: ignore - from ._models import InventoryItem # type: ignore - from ._models import InventoryItemDetails # type: ignore - from ._models import InventoryItemProperties # type: ignore - from ._models import InventoryItemsList # type: ignore - from ._models import MachineExtension # type: ignore - from ._models import MachineExtensionInstanceView # type: ignore - from ._models import MachineExtensionInstanceViewStatus # type: ignore - from ._models import MachineExtensionPropertiesInstanceView # type: ignore - from ._models import MachineExtensionUpdate # type: ignore - from ._models import MachineExtensionsListResult # type: ignore - from ._models import NetworkInterface # type: ignore - from ._models import NetworkInterfaceUpdate # type: ignore - from ._models import NetworkProfile # type: ignore - from ._models import NetworkProfileUpdate # type: ignore - from ._models import NicIPAddressSettings # type: ignore - from ._models import NicIPSettings # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationsList # type: ignore - from ._models import OsProfile # type: ignore - from ._models import PlacementProfile # type: ignore - from ._models import ProxyResource # type: ignore - from ._models import Resource # type: ignore - from ._models import ResourcePatch # type: ignore - from ._models import ResourcePool # type: ignore - from ._models import ResourcePoolInventoryItem # type: ignore - from ._models import ResourcePoolsList # type: ignore - from ._models import ResourceStatus # type: ignore - from ._models import StopVirtualMachineOptions # type: ignore - from ._models import StorageProfile # type: ignore - from ._models import StorageProfileUpdate # type: ignore - from ._models import SystemData # type: ignore - from ._models import VCenter # type: ignore - from ._models import VCentersList # type: ignore - from ._models import VICredential # type: ignore - from ._models import VirtualDisk # type: ignore - from ._models import VirtualDiskUpdate # type: ignore - from ._models import VirtualMachine # type: ignore - from ._models import VirtualMachineInventoryItem # type: ignore - from ._models import VirtualMachineTemplate # type: ignore - from ._models import VirtualMachineTemplateInventoryItem # type: ignore - from ._models import VirtualMachineTemplatesList # type: ignore - from ._models import VirtualMachineUpdate # type: ignore - from ._models import VirtualMachinesList # type: ignore - from ._models import VirtualNetwork # type: ignore - from ._models import VirtualNetworkInventoryItem # type: ignore - from ._models import VirtualNetworksList # type: ignore - from ._models import VirtualSCSIController # type: ignore +from ._models_py3 import Cluster +from ._models_py3 import ClusterInventoryItem +from ._models_py3 import ClustersList +from ._models_py3 import Condition +from ._models_py3 import Datastore +from ._models_py3 import DatastoreInventoryItem +from ._models_py3 import DatastoresList +from ._models_py3 import ErrorDefinition +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse +from ._models_py3 import ExtendedLocation +from ._models_py3 import GuestAgent +from ._models_py3 import GuestAgentList +from ._models_py3 import GuestAgentProfile +from ._models_py3 import GuestCredential +from ._models_py3 import HardwareProfile +from ._models_py3 import Host +from ._models_py3 import HostInventoryItem +from ._models_py3 import HostsList +from ._models_py3 import HttpProxyConfiguration +from ._models_py3 import HybridIdentityMetadata +from ._models_py3 import HybridIdentityMetadataList +from ._models_py3 import Identity +from ._models_py3 import InventoryItem +from ._models_py3 import InventoryItemDetails +from ._models_py3 import InventoryItemProperties +from ._models_py3 import InventoryItemsList +from ._models_py3 import MachineExtension +from ._models_py3 import MachineExtensionInstanceView +from ._models_py3 import MachineExtensionInstanceViewStatus +from ._models_py3 import MachineExtensionPropertiesInstanceView +from ._models_py3 import MachineExtensionUpdate +from ._models_py3 import MachineExtensionsListResult +from ._models_py3 import NetworkInterface +from ._models_py3 import NetworkInterfaceUpdate +from ._models_py3 import NetworkProfile +from ._models_py3 import NetworkProfileUpdate +from ._models_py3 import NicIPAddressSettings +from ._models_py3 import NicIPSettings +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationsList +from ._models_py3 import OsProfile +from ._models_py3 import PlacementProfile +from ._models_py3 import ProxyResource +from ._models_py3 import Resource +from ._models_py3 import ResourcePatch +from ._models_py3 import ResourcePool +from ._models_py3 import ResourcePoolInventoryItem +from ._models_py3 import ResourcePoolsList +from ._models_py3 import ResourceStatus +from ._models_py3 import StopVirtualMachineOptions +from ._models_py3 import StorageProfile +from ._models_py3 import StorageProfileUpdate +from ._models_py3 import SystemData +from ._models_py3 import VCenter +from ._models_py3 import VCentersList +from ._models_py3 import VICredential +from ._models_py3 import VirtualDisk +from ._models_py3 import VirtualDiskUpdate +from ._models_py3 import VirtualMachine +from ._models_py3 import VirtualMachineInventoryItem +from ._models_py3 import VirtualMachineTemplate +from ._models_py3 import VirtualMachineTemplateInventoryItem +from ._models_py3 import VirtualMachineTemplatesList +from ._models_py3 import VirtualMachineUpdate +from ._models_py3 import VirtualMachinesList +from ._models_py3 import VirtualNetwork +from ._models_py3 import VirtualNetworkInventoryItem +from ._models_py3 import VirtualNetworksList +from ._models_py3 import VirtualSCSIController + from ._azure_arc_vmware_management_service_api_enums import ( CreatedByType, diff --git a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/models/_azure_arc_vmware_management_service_api_enums.py b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/models/_azure_arc_vmware_management_service_api_enums.py index 9a15a80b6c87..6d7ccd29d1c4 100644 --- a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/models/_azure_arc_vmware_management_service_api_enums.py +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/models/_azure_arc_vmware_management_service_api_enums.py @@ -6,27 +6,12 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of identity that created the resource. """ @@ -35,7 +20,7 @@ class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class DiskMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DiskMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Defines the different types of disk modes. """ @@ -43,7 +28,7 @@ class DiskMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): INDEPENDENT_PERSISTENT = "independent_persistent" INDEPENDENT_NONPERSISTENT = "independent_nonpersistent" -class DiskType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DiskType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Defines the different types of disks. """ @@ -55,21 +40,21 @@ class DiskType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SESPARSE = "sesparse" UNKNOWN = "unknown" -class FirmwareType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class FirmwareType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Firmware type """ BIOS = "bios" EFI = "efi" -class IdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of managed service identity. """ NONE = "None" SYSTEM_ASSIGNED = "SystemAssigned" -class InventoryType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class InventoryType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The inventory type. """ @@ -81,7 +66,7 @@ class InventoryType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): DATASTORE = "Datastore" HOST = "Host" -class IPAddressAllocationMethod(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IPAddressAllocationMethod(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """IP address allocation method. """ @@ -92,7 +77,7 @@ class IPAddressAllocationMethod(with_metaclass(_CaseInsensitiveEnumMeta, str, En RANDOM = "random" OTHER = "other" -class NICType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class NICType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """NIC type """ @@ -103,7 +88,7 @@ class NICType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): E1000_E = "e1000e" PCNET32 = "pcnet32" -class OsType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class OsType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Defines the different types of VM guest operating systems. """ @@ -111,14 +96,14 @@ class OsType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): LINUX = "Linux" OTHER = "Other" -class PowerOnBootOption(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PowerOnBootOption(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Defines the options for power on boot. """ ENABLED = "enabled" DISABLED = "disabled" -class ProvisioningAction(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Defines the different types of operations for guest agent. """ @@ -126,7 +111,7 @@ class ProvisioningAction(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): UNINSTALL = "uninstall" REPAIR = "repair" -class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The current deployment state of resource. """ @@ -139,7 +124,7 @@ class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): ACCEPTED = "Accepted" CREATED = "Created" -class SCSIControllerType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SCSIControllerType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Defines the different types of SCSI controllers. """ @@ -148,7 +133,7 @@ class SCSIControllerType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): PVSCSI = "pvscsi" LSILOGICSAS = "lsilogicsas" -class StatusLevelTypes(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class StatusLevelTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The level code. """ @@ -156,7 +141,7 @@ class StatusLevelTypes(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): WARNING = "Warning" ERROR = "Error" -class StatusTypes(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class StatusTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The status of the hybrid machine agent. """ @@ -164,7 +149,7 @@ class StatusTypes(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): DISCONNECTED = "Disconnected" ERROR = "Error" -class VirtualSCSISharing(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class VirtualSCSISharing(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Defines the sharing mode for sharing the SCSI bus. """ diff --git a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/models/_models.py b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/models/_models.py deleted file mode 100644 index b932b37bd4d6..000000000000 --- a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/models/_models.py +++ /dev/null @@ -1,3496 +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 Cluster(msrest.serialization.Model): - """Define the cluster. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param location: Required. Gets or sets the location. - :type location: str - :param extended_location: Gets or sets the extended location. - :type extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation - :ivar system_data: The system data. - :vartype system_data: ~azure.mgmt.connectedvmware.models.SystemData - :param tags: A set of tags. Gets or sets the Resource tags. - :type tags: dict[str, str] - :ivar name: Gets or sets the name. - :vartype name: str - :ivar id: Gets or sets the Id. - :vartype id: str - :ivar type: Gets or sets the type of the resource. - :vartype type: str - :param kind: Metadata used by portal/tooling/etc to render different UX experiences for - resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, - the resource provider must validate and persist this value. - :type kind: str - :ivar uuid: Gets or sets a unique identifier for this resource. - :vartype uuid: str - :param v_center_id: Gets or sets the ARM Id of the vCenter resource in which this cluster - resides. - :type v_center_id: str - :param mo_ref_id: Gets or sets the vCenter MoRef (Managed Object Reference) ID for the cluster. - :type mo_ref_id: str - :param inventory_item_id: Gets or sets the inventory Item ID for the cluster. - :type inventory_item_id: str - :ivar mo_name: Gets or sets the vCenter Managed Object name for the cluster. - :vartype mo_name: str - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.connectedvmware.models.ResourceStatus] - :ivar custom_resource_name: Gets the name of the corresponding resource in Kubernetes. - :vartype custom_resource_name: str - :ivar datastore_ids: Gets or sets the datastore ARM ids. - :vartype datastore_ids: list[str] - :ivar network_ids: Gets or sets the network ARM ids. - :vartype network_ids: list[str] - :ivar provisioning_state: Gets or sets the provisioning state. - :vartype provisioning_state: str - """ - - _validation = { - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'name': {'readonly': True}, - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'uuid': {'readonly': True}, - 'mo_name': {'readonly': True}, - 'statuses': {'readonly': True}, - 'custom_resource_name': {'readonly': True}, - 'datastore_ids': {'readonly': True}, - 'network_ids': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'name': {'key': 'name', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'uuid': {'key': 'properties.uuid', 'type': 'str'}, - 'v_center_id': {'key': 'properties.vCenterId', 'type': 'str'}, - 'mo_ref_id': {'key': 'properties.moRefId', 'type': 'str'}, - 'inventory_item_id': {'key': 'properties.inventoryItemId', 'type': 'str'}, - 'mo_name': {'key': 'properties.moName', 'type': 'str'}, - 'statuses': {'key': 'properties.statuses', 'type': '[ResourceStatus]'}, - 'custom_resource_name': {'key': 'properties.customResourceName', 'type': 'str'}, - 'datastore_ids': {'key': 'properties.datastoreIds', 'type': '[str]'}, - 'network_ids': {'key': 'properties.networkIds', 'type': '[str]'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Cluster, self).__init__(**kwargs) - self.location = kwargs['location'] - self.extended_location = kwargs.get('extended_location', None) - self.system_data = None - self.tags = kwargs.get('tags', None) - self.name = None - self.id = None - self.type = None - self.kind = kwargs.get('kind', None) - self.uuid = None - self.v_center_id = kwargs.get('v_center_id', None) - self.mo_ref_id = kwargs.get('mo_ref_id', None) - self.inventory_item_id = kwargs.get('inventory_item_id', None) - self.mo_name = None - self.statuses = None - self.custom_resource_name = None - self.datastore_ids = None - self.network_ids = None - self.provisioning_state = None - - -class InventoryItemProperties(msrest.serialization.Model): - """Defines the resource properties. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: ClusterInventoryItem, DatastoreInventoryItem, HostInventoryItem, ResourcePoolInventoryItem, VirtualMachineInventoryItem, VirtualMachineTemplateInventoryItem, VirtualNetworkInventoryItem. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param inventory_type: Required. They inventory type.Constant filled by server. Possible - values include: "ResourcePool", "VirtualMachine", "VirtualMachineTemplate", "VirtualNetwork", - "Cluster", "Datastore", "Host". - :type inventory_type: str or ~azure.mgmt.connectedvmware.models.InventoryType - :param managed_resource_id: Gets or sets the tracked resource id corresponding to the inventory - resource. - :type managed_resource_id: str - :param mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory item. - :type mo_ref_id: str - :param mo_name: Gets or sets the vCenter Managed Object name for the inventory item. - :type mo_name: str - :ivar provisioning_state: Gets or sets the provisioning state. - :vartype provisioning_state: str - """ - - _validation = { - 'inventory_type': {'required': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'inventory_type': {'key': 'inventoryType', 'type': 'str'}, - 'managed_resource_id': {'key': 'managedResourceId', 'type': 'str'}, - 'mo_ref_id': {'key': 'moRefId', 'type': 'str'}, - 'mo_name': {'key': 'moName', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - } - - _subtype_map = { - 'inventory_type': {'Cluster': 'ClusterInventoryItem', 'Datastore': 'DatastoreInventoryItem', 'Host': 'HostInventoryItem', 'ResourcePool': 'ResourcePoolInventoryItem', 'VirtualMachine': 'VirtualMachineInventoryItem', 'VirtualMachineTemplate': 'VirtualMachineTemplateInventoryItem', 'VirtualNetwork': 'VirtualNetworkInventoryItem'} - } - - def __init__( - self, - **kwargs - ): - super(InventoryItemProperties, self).__init__(**kwargs) - self.inventory_type = None # type: Optional[str] - self.managed_resource_id = kwargs.get('managed_resource_id', None) - self.mo_ref_id = kwargs.get('mo_ref_id', None) - self.mo_name = kwargs.get('mo_name', None) - self.provisioning_state = None - - -class ClusterInventoryItem(InventoryItemProperties): - """The cluster inventory item. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param inventory_type: Required. They inventory type.Constant filled by server. Possible - values include: "ResourcePool", "VirtualMachine", "VirtualMachineTemplate", "VirtualNetwork", - "Cluster", "Datastore", "Host". - :type inventory_type: str or ~azure.mgmt.connectedvmware.models.InventoryType - :param managed_resource_id: Gets or sets the tracked resource id corresponding to the inventory - resource. - :type managed_resource_id: str - :param mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory item. - :type mo_ref_id: str - :param mo_name: Gets or sets the vCenter Managed Object name for the inventory item. - :type mo_name: str - :ivar provisioning_state: Gets or sets the provisioning state. - :vartype provisioning_state: str - """ - - _validation = { - 'inventory_type': {'required': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'inventory_type': {'key': 'inventoryType', 'type': 'str'}, - 'managed_resource_id': {'key': 'managedResourceId', 'type': 'str'}, - 'mo_ref_id': {'key': 'moRefId', 'type': 'str'}, - 'mo_name': {'key': 'moName', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ClusterInventoryItem, self).__init__(**kwargs) - self.inventory_type = 'Cluster' # type: str - - -class ClustersList(msrest.serialization.Model): - """List of Clusters. - - All required parameters must be populated in order to send to Azure. - - :param next_link: Url to follow for getting next page of Clusters. - :type next_link: str - :param value: Required. Array of Clusters. - :type value: list[~azure.mgmt.connectedvmware.models.Cluster] - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[Cluster]'}, - } - - def __init__( - self, - **kwargs - ): - super(ClustersList, self).__init__(**kwargs) - self.next_link = kwargs.get('next_link', None) - self.value = kwargs['value'] - - -class Condition(msrest.serialization.Model): - """Condition defines an extension to status. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar status: Status of the condition. - :vartype status: str - :ivar reason: The reason for the condition's status. - :vartype reason: str - :ivar message: A human readable message indicating details about the status. - :vartype message: str - :ivar severity: Severity with which to treat failures of this type of condition. - :vartype severity: str - """ - - _validation = { - 'status': {'readonly': True}, - 'reason': {'readonly': True}, - 'message': {'readonly': True}, - 'severity': {'readonly': True}, - } - - _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'severity': {'key': 'severity', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Condition, self).__init__(**kwargs) - self.status = None - self.reason = None - self.message = None - self.severity = None - - -class Datastore(msrest.serialization.Model): - """Define the datastore. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param location: Required. Gets or sets the location. - :type location: str - :param extended_location: Gets or sets the extended location. - :type extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation - :ivar system_data: The system data. - :vartype system_data: ~azure.mgmt.connectedvmware.models.SystemData - :param tags: A set of tags. Gets or sets the Resource tags. - :type tags: dict[str, str] - :ivar name: Gets or sets the name. - :vartype name: str - :ivar id: Gets or sets the Id. - :vartype id: str - :ivar type: Gets or sets the type of the resource. - :vartype type: str - :param kind: Metadata used by portal/tooling/etc to render different UX experiences for - resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, - the resource provider must validate and persist this value. - :type kind: str - :ivar uuid: Gets or sets a unique identifier for this resource. - :vartype uuid: str - :param v_center_id: Gets or sets the ARM Id of the vCenter resource in which this datastore - resides. - :type v_center_id: str - :param mo_ref_id: Gets or sets the vCenter MoRef (Managed Object Reference) ID for the - datastore. - :type mo_ref_id: str - :param inventory_item_id: Gets or sets the inventory Item ID for the datastore. - :type inventory_item_id: str - :ivar mo_name: Gets or sets the vCenter Managed Object name for the datastore. - :vartype mo_name: str - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.connectedvmware.models.ResourceStatus] - :ivar custom_resource_name: Gets the name of the corresponding resource in Kubernetes. - :vartype custom_resource_name: str - :ivar provisioning_state: Provisioning state of the resource. Possible values include: - "Succeeded", "Failed", "Canceled", "Provisioning", "Updating", "Deleting", "Accepted", - "Created". - :vartype provisioning_state: str or ~azure.mgmt.connectedvmware.models.ProvisioningState - """ - - _validation = { - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'name': {'readonly': True}, - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'uuid': {'readonly': True}, - 'mo_name': {'readonly': True}, - 'statuses': {'readonly': True}, - 'custom_resource_name': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'name': {'key': 'name', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'uuid': {'key': 'properties.uuid', 'type': 'str'}, - 'v_center_id': {'key': 'properties.vCenterId', 'type': 'str'}, - 'mo_ref_id': {'key': 'properties.moRefId', 'type': 'str'}, - 'inventory_item_id': {'key': 'properties.inventoryItemId', 'type': 'str'}, - 'mo_name': {'key': 'properties.moName', 'type': 'str'}, - 'statuses': {'key': 'properties.statuses', 'type': '[ResourceStatus]'}, - 'custom_resource_name': {'key': 'properties.customResourceName', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Datastore, self).__init__(**kwargs) - self.location = kwargs['location'] - self.extended_location = kwargs.get('extended_location', None) - self.system_data = None - self.tags = kwargs.get('tags', None) - self.name = None - self.id = None - self.type = None - self.kind = kwargs.get('kind', None) - self.uuid = None - self.v_center_id = kwargs.get('v_center_id', None) - self.mo_ref_id = kwargs.get('mo_ref_id', None) - self.inventory_item_id = kwargs.get('inventory_item_id', None) - self.mo_name = None - self.statuses = None - self.custom_resource_name = None - self.provisioning_state = None - - -class DatastoreInventoryItem(InventoryItemProperties): - """The datastore inventory item. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param inventory_type: Required. They inventory type.Constant filled by server. Possible - values include: "ResourcePool", "VirtualMachine", "VirtualMachineTemplate", "VirtualNetwork", - "Cluster", "Datastore", "Host". - :type inventory_type: str or ~azure.mgmt.connectedvmware.models.InventoryType - :param managed_resource_id: Gets or sets the tracked resource id corresponding to the inventory - resource. - :type managed_resource_id: str - :param mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory item. - :type mo_ref_id: str - :param mo_name: Gets or sets the vCenter Managed Object name for the inventory item. - :type mo_name: str - :ivar provisioning_state: Gets or sets the provisioning state. - :vartype provisioning_state: str - :param capacity_gb: Gets or sets Maximum capacity of this datastore, in GBs. - :type capacity_gb: long - :param free_space_gb: Gets or sets Available space of this datastore, in GBs. - :type free_space_gb: long - """ - - _validation = { - 'inventory_type': {'required': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'inventory_type': {'key': 'inventoryType', 'type': 'str'}, - 'managed_resource_id': {'key': 'managedResourceId', 'type': 'str'}, - 'mo_ref_id': {'key': 'moRefId', 'type': 'str'}, - 'mo_name': {'key': 'moName', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'capacity_gb': {'key': 'capacityGB', 'type': 'long'}, - 'free_space_gb': {'key': 'freeSpaceGB', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(DatastoreInventoryItem, self).__init__(**kwargs) - self.inventory_type = 'Datastore' # type: str - self.capacity_gb = kwargs.get('capacity_gb', None) - self.free_space_gb = kwargs.get('free_space_gb', None) - - -class DatastoresList(msrest.serialization.Model): - """List of Datastores. - - All required parameters must be populated in order to send to Azure. - - :param next_link: Url to follow for getting next page of Datastores. - :type next_link: str - :param value: Required. Array of Datastores. - :type value: list[~azure.mgmt.connectedvmware.models.Datastore] - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[Datastore]'}, - } - - def __init__( - self, - **kwargs - ): - super(DatastoresList, self).__init__(**kwargs) - self.next_link = kwargs.get('next_link', None) - self.value = kwargs['value'] - - -class ErrorDefinition(msrest.serialization.Model): - """Error definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: Service specific error code which serves as the substatus for the HTTP error code. - :vartype code: str - :ivar message: Description of the error. - :vartype message: str - :ivar details: Internal error details. - :vartype details: list[~azure.mgmt.connectedvmware.models.ErrorDefinition] - """ - - _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'details': {'readonly': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorDefinition]'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorDefinition, self).__init__(**kwargs) - self.code = None - self.message = None - self.details = None - - -class ErrorDetail(msrest.serialization.Model): - """Error details. - - All required parameters must be populated in order to send to Azure. - - :param code: Required. The error's code. - :type code: str - :param message: Required. A human readable error message. - :type message: str - :param target: Indicates which property in the request is responsible for the error. - :type target: str - :param details: Additional error details. - :type details: list[~azure.mgmt.connectedvmware.models.ErrorDetail] - """ - - _validation = { - 'code': {'required': True}, - 'message': {'required': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorDetail]'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorDetail, self).__init__(**kwargs) - self.code = kwargs['code'] - self.message = kwargs['message'] - self.target = kwargs.get('target', None) - self.details = kwargs.get('details', None) - - -class ErrorResponse(msrest.serialization.Model): - """Error response. - - :param error: The error details. - :type error: ~azure.mgmt.connectedvmware.models.ErrorDefinition - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDefinition'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class ExtendedLocation(msrest.serialization.Model): - """The extended location. - - :param type: The extended location type. - :type type: str - :param name: The extended location name. - :type name: str - """ - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ExtendedLocation, self).__init__(**kwargs) - self.type = kwargs.get('type', None) - self.name = kwargs.get('name', None) - - -class Resource(msrest.serialization.Model): - """Common fields that are returned in the response for all Azure Resource Manager resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class 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 GuestAgent(ProxyResource): - """Defines the GuestAgent. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: The system data. - :vartype system_data: ~azure.mgmt.connectedvmware.models.SystemData - :ivar uuid: Gets or sets a unique identifier for this resource. - :vartype uuid: str - :param credentials: Username / Password Credentials to provision guest agent. - :type credentials: ~azure.mgmt.connectedvmware.models.GuestCredential - :param http_proxy_config: HTTP Proxy configuration for the VM. - :type http_proxy_config: ~azure.mgmt.connectedvmware.models.HttpProxyConfiguration - :param provisioning_action: Gets or sets the guest agent provisioning action. Possible values - include: "install", "uninstall", "repair". - :type provisioning_action: str or ~azure.mgmt.connectedvmware.models.ProvisioningAction - :ivar status: Gets or sets the guest agent status. - :vartype status: str - :ivar custom_resource_name: Gets the name of the corresponding resource in Kubernetes. - :vartype custom_resource_name: str - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.connectedvmware.models.ResourceStatus] - :ivar provisioning_state: Gets or sets the provisioning state. - :vartype provisioning_state: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'uuid': {'readonly': True}, - 'status': {'readonly': True}, - 'custom_resource_name': {'readonly': True}, - 'statuses': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'uuid': {'key': 'properties.uuid', 'type': 'str'}, - 'credentials': {'key': 'properties.credentials', 'type': 'GuestCredential'}, - 'http_proxy_config': {'key': 'properties.httpProxyConfig', 'type': 'HttpProxyConfiguration'}, - 'provisioning_action': {'key': 'properties.provisioningAction', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'custom_resource_name': {'key': 'properties.customResourceName', 'type': 'str'}, - 'statuses': {'key': 'properties.statuses', 'type': '[ResourceStatus]'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(GuestAgent, self).__init__(**kwargs) - self.system_data = None - self.uuid = None - self.credentials = kwargs.get('credentials', None) - self.http_proxy_config = kwargs.get('http_proxy_config', None) - self.provisioning_action = kwargs.get('provisioning_action', None) - self.status = None - self.custom_resource_name = None - self.statuses = None - self.provisioning_state = None - - -class GuestAgentList(msrest.serialization.Model): - """List of GuestAgent. - - All required parameters must be populated in order to send to Azure. - - :param next_link: Url to follow for getting next page of GuestAgent. - :type next_link: str - :param value: Required. Array of GuestAgent. - :type value: list[~azure.mgmt.connectedvmware.models.GuestAgent] - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[GuestAgent]'}, - } - - def __init__( - self, - **kwargs - ): - super(GuestAgentList, self).__init__(**kwargs) - self.next_link = kwargs.get('next_link', None) - self.value = kwargs['value'] - - -class GuestAgentProfile(msrest.serialization.Model): - """Defines the resource properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar vm_uuid: Specifies the VM's unique SMBIOS ID. - :vartype vm_uuid: str - :ivar status: The status of the hybrid machine agent. Possible values include: "Connected", - "Disconnected", "Error". - :vartype status: str or ~azure.mgmt.connectedvmware.models.StatusTypes - :ivar last_status_change: The time of the last status change. - :vartype last_status_change: ~datetime.datetime - :ivar agent_version: The hybrid machine agent full version. - :vartype agent_version: str - :ivar error_details: Details about the error state. - :vartype error_details: list[~azure.mgmt.connectedvmware.models.ErrorDetail] - """ - - _validation = { - 'vm_uuid': {'readonly': True}, - 'status': {'readonly': True}, - 'last_status_change': {'readonly': True}, - 'agent_version': {'readonly': True}, - 'error_details': {'readonly': True}, - } - - _attribute_map = { - 'vm_uuid': {'key': 'vmUuid', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'last_status_change': {'key': 'lastStatusChange', 'type': 'iso-8601'}, - 'agent_version': {'key': 'agentVersion', 'type': 'str'}, - 'error_details': {'key': 'errorDetails', 'type': '[ErrorDetail]'}, - } - - def __init__( - self, - **kwargs - ): - super(GuestAgentProfile, self).__init__(**kwargs) - self.vm_uuid = None - self.status = None - self.last_status_change = None - self.agent_version = None - self.error_details = None - - -class GuestCredential(msrest.serialization.Model): - """Username / Password Credentials to connect to guest. - - :param username: Gets or sets username to connect with the guest. - :type username: str - :param password: Gets or sets the password to connect with the guest. - :type password: str - """ - - _attribute_map = { - 'username': {'key': 'username', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(GuestCredential, self).__init__(**kwargs) - self.username = kwargs.get('username', None) - self.password = kwargs.get('password', None) - - -class HardwareProfile(msrest.serialization.Model): - """Defines the resource properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param memory_size_mb: Gets or sets memory size in MBs for the vm. - :type memory_size_mb: int - :param num_cp_us: Gets or sets the number of vCPUs for the vm. - :type num_cp_us: int - :param num_cores_per_socket: Gets or sets the number of cores per socket for the vm. Defaults - to 1 if unspecified. - :type num_cores_per_socket: int - :ivar cpu_hot_add_enabled: Gets or sets a value indicating whether virtual processors can be - added while this virtual machine is running. - :vartype cpu_hot_add_enabled: bool - :ivar cpu_hot_remove_enabled: Gets or sets a value indicating whether virtual processors can be - removed while this virtual machine is running. - :vartype cpu_hot_remove_enabled: bool - :ivar memory_hot_add_enabled: Gets or sets a value indicating whether memory can be added while - this virtual machine is running. - :vartype memory_hot_add_enabled: bool - """ - - _validation = { - 'cpu_hot_add_enabled': {'readonly': True}, - 'cpu_hot_remove_enabled': {'readonly': True}, - 'memory_hot_add_enabled': {'readonly': True}, - } - - _attribute_map = { - 'memory_size_mb': {'key': 'memorySizeMB', 'type': 'int'}, - 'num_cp_us': {'key': 'numCPUs', 'type': 'int'}, - 'num_cores_per_socket': {'key': 'numCoresPerSocket', 'type': 'int'}, - 'cpu_hot_add_enabled': {'key': 'cpuHotAddEnabled', 'type': 'bool'}, - 'cpu_hot_remove_enabled': {'key': 'cpuHotRemoveEnabled', 'type': 'bool'}, - 'memory_hot_add_enabled': {'key': 'memoryHotAddEnabled', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(HardwareProfile, self).__init__(**kwargs) - self.memory_size_mb = kwargs.get('memory_size_mb', None) - self.num_cp_us = kwargs.get('num_cp_us', None) - self.num_cores_per_socket = kwargs.get('num_cores_per_socket', None) - self.cpu_hot_add_enabled = None - self.cpu_hot_remove_enabled = None - self.memory_hot_add_enabled = None - - -class Host(msrest.serialization.Model): - """Define the host. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param location: Required. Gets or sets the location. - :type location: str - :param extended_location: Gets or sets the extended location. - :type extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation - :ivar system_data: The system data. - :vartype system_data: ~azure.mgmt.connectedvmware.models.SystemData - :param tags: A set of tags. Gets or sets the Resource tags. - :type tags: dict[str, str] - :ivar name: Gets or sets the name. - :vartype name: str - :ivar id: Gets or sets the Id. - :vartype id: str - :ivar type: Gets or sets the type of the resource. - :vartype type: str - :param kind: Metadata used by portal/tooling/etc to render different UX experiences for - resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, - the resource provider must validate and persist this value. - :type kind: str - :ivar uuid: Gets or sets a unique identifier for this resource. - :vartype uuid: str - :param v_center_id: Gets or sets the ARM Id of the vCenter resource in which this host resides. - :type v_center_id: str - :param mo_ref_id: Gets or sets the vCenter MoRef (Managed Object Reference) ID for the host. - :type mo_ref_id: str - :param inventory_item_id: Gets or sets the inventory Item ID for the host. - :type inventory_item_id: str - :ivar mo_name: Gets or sets the vCenter Managed Object name for the host. - :vartype mo_name: str - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.connectedvmware.models.ResourceStatus] - :ivar custom_resource_name: Gets the name of the corresponding resource in Kubernetes. - :vartype custom_resource_name: str - :ivar provisioning_state: Gets or sets the provisioning state. - :vartype provisioning_state: str - """ - - _validation = { - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'name': {'readonly': True}, - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'uuid': {'readonly': True}, - 'mo_name': {'readonly': True}, - 'statuses': {'readonly': True}, - 'custom_resource_name': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'name': {'key': 'name', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'uuid': {'key': 'properties.uuid', 'type': 'str'}, - 'v_center_id': {'key': 'properties.vCenterId', 'type': 'str'}, - 'mo_ref_id': {'key': 'properties.moRefId', 'type': 'str'}, - 'inventory_item_id': {'key': 'properties.inventoryItemId', 'type': 'str'}, - 'mo_name': {'key': 'properties.moName', 'type': 'str'}, - 'statuses': {'key': 'properties.statuses', 'type': '[ResourceStatus]'}, - 'custom_resource_name': {'key': 'properties.customResourceName', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Host, self).__init__(**kwargs) - self.location = kwargs['location'] - self.extended_location = kwargs.get('extended_location', None) - self.system_data = None - self.tags = kwargs.get('tags', None) - self.name = None - self.id = None - self.type = None - self.kind = kwargs.get('kind', None) - self.uuid = None - self.v_center_id = kwargs.get('v_center_id', None) - self.mo_ref_id = kwargs.get('mo_ref_id', None) - self.inventory_item_id = kwargs.get('inventory_item_id', None) - self.mo_name = None - self.statuses = None - self.custom_resource_name = None - self.provisioning_state = None - - -class HostInventoryItem(InventoryItemProperties): - """The host inventory item. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param inventory_type: Required. They inventory type.Constant filled by server. Possible - values include: "ResourcePool", "VirtualMachine", "VirtualMachineTemplate", "VirtualNetwork", - "Cluster", "Datastore", "Host". - :type inventory_type: str or ~azure.mgmt.connectedvmware.models.InventoryType - :param managed_resource_id: Gets or sets the tracked resource id corresponding to the inventory - resource. - :type managed_resource_id: str - :param mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory item. - :type mo_ref_id: str - :param mo_name: Gets or sets the vCenter Managed Object name for the inventory item. - :type mo_name: str - :ivar provisioning_state: Gets or sets the provisioning state. - :vartype provisioning_state: str - :param parent: Parent host inventory resource details. - :type parent: ~azure.mgmt.connectedvmware.models.InventoryItemDetails - """ - - _validation = { - 'inventory_type': {'required': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'inventory_type': {'key': 'inventoryType', 'type': 'str'}, - 'managed_resource_id': {'key': 'managedResourceId', 'type': 'str'}, - 'mo_ref_id': {'key': 'moRefId', 'type': 'str'}, - 'mo_name': {'key': 'moName', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'parent': {'key': 'parent', 'type': 'InventoryItemDetails'}, - } - - def __init__( - self, - **kwargs - ): - super(HostInventoryItem, self).__init__(**kwargs) - self.inventory_type = 'Host' # type: str - self.parent = kwargs.get('parent', None) - - -class HostsList(msrest.serialization.Model): - """List of Hosts. - - All required parameters must be populated in order to send to Azure. - - :param next_link: Url to follow for getting next page of Hosts. - :type next_link: str - :param value: Required. Array of Hosts. - :type value: list[~azure.mgmt.connectedvmware.models.Host] - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[Host]'}, - } - - def __init__( - self, - **kwargs - ): - super(HostsList, self).__init__(**kwargs) - self.next_link = kwargs.get('next_link', None) - self.value = kwargs['value'] - - -class HttpProxyConfiguration(msrest.serialization.Model): - """HTTP Proxy configuration for the VM. - - :param https_proxy: Gets or sets httpsProxy url. - :type https_proxy: str - """ - - _attribute_map = { - 'https_proxy': {'key': 'httpsProxy', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(HttpProxyConfiguration, self).__init__(**kwargs) - self.https_proxy = kwargs.get('https_proxy', None) - - -class HybridIdentityMetadata(ProxyResource): - """Defines the HybridIdentityMetadata. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: The system data. - :vartype system_data: ~azure.mgmt.connectedvmware.models.SystemData - :param vm_id: Gets or sets the Vm Id. - :type vm_id: str - :param public_key: Gets or sets the Public Key. - :type public_key: str - :ivar identity: The identity of the resource. - :vartype identity: ~azure.mgmt.connectedvmware.models.Identity - :ivar provisioning_state: Gets or sets the provisioning state. - :vartype provisioning_state: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'identity': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'vm_id': {'key': 'properties.vmId', 'type': 'str'}, - 'public_key': {'key': 'properties.publicKey', 'type': 'str'}, - 'identity': {'key': 'properties.identity', 'type': 'Identity'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(HybridIdentityMetadata, self).__init__(**kwargs) - self.system_data = None - self.vm_id = kwargs.get('vm_id', None) - self.public_key = kwargs.get('public_key', None) - self.identity = None - self.provisioning_state = None - - -class HybridIdentityMetadataList(msrest.serialization.Model): - """List of HybridIdentityMetadata. - - All required parameters must be populated in order to send to Azure. - - :param next_link: Url to follow for getting next page of HybridIdentityMetadata. - :type next_link: str - :param value: Required. Array of HybridIdentityMetadata. - :type value: list[~azure.mgmt.connectedvmware.models.HybridIdentityMetadata] - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[HybridIdentityMetadata]'}, - } - - def __init__( - self, - **kwargs - ): - super(HybridIdentityMetadataList, self).__init__(**kwargs) - self.next_link = kwargs.get('next_link', None) - self.value = kwargs['value'] - - -class Identity(msrest.serialization.Model): - """Managed service identity. - - 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 principal_id: The principal id of managed service identity. - :vartype principal_id: str - :ivar tenant_id: The tenant of managed service identity. - :vartype tenant_id: str - :param type: Required. The type of managed service identity. Possible values include: "None", - "SystemAssigned". - :type type: str or ~azure.mgmt.connectedvmware.models.IdentityType - """ - - _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'type': {'required': 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(Identity, self).__init__(**kwargs) - self.principal_id = None - self.tenant_id = None - self.type = kwargs['type'] - - -class InventoryItem(ProxyResource): - """Defines the inventory item. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: The system data. - :vartype system_data: ~azure.mgmt.connectedvmware.models.SystemData - :param kind: Metadata used by portal/tooling/etc to render different UX experiences for - resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, - the resource provider must validate and persist this value. - :type kind: str - :param inventory_type: Required. They inventory type.Constant filled by server. Possible - values include: "ResourcePool", "VirtualMachine", "VirtualMachineTemplate", "VirtualNetwork", - "Cluster", "Datastore", "Host". - :type inventory_type: str or ~azure.mgmt.connectedvmware.models.InventoryType - :param managed_resource_id: Gets or sets the tracked resource id corresponding to the inventory - resource. - :type managed_resource_id: str - :param mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory item. - :type mo_ref_id: str - :param mo_name: Gets or sets the vCenter Managed Object name for the inventory item. - :type mo_name: str - :ivar provisioning_state: Gets or sets the provisioning state. - :vartype provisioning_state: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'inventory_type': {'required': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'inventory_type': {'key': 'properties.inventoryType', 'type': 'str'}, - 'managed_resource_id': {'key': 'properties.managedResourceId', 'type': 'str'}, - 'mo_ref_id': {'key': 'properties.moRefId', 'type': 'str'}, - 'mo_name': {'key': 'properties.moName', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(InventoryItem, self).__init__(**kwargs) - self.system_data = None - self.kind = kwargs.get('kind', None) - self.inventory_type = None # type: Optional[str] - self.managed_resource_id = kwargs.get('managed_resource_id', None) - self.mo_ref_id = kwargs.get('mo_ref_id', None) - self.mo_name = kwargs.get('mo_name', None) - self.provisioning_state = None - - -class InventoryItemDetails(msrest.serialization.Model): - """Defines the resource properties. - - :param inventory_item_id: Gets or sets the inventory Item ID for the resource. - :type inventory_item_id: str - :param mo_name: Gets or sets the vCenter Managed Object name for the resource. - :type mo_name: str - """ - - _attribute_map = { - 'inventory_item_id': {'key': 'inventoryItemId', 'type': 'str'}, - 'mo_name': {'key': 'moName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(InventoryItemDetails, self).__init__(**kwargs) - self.inventory_item_id = kwargs.get('inventory_item_id', None) - self.mo_name = kwargs.get('mo_name', None) - - -class InventoryItemsList(msrest.serialization.Model): - """List of InventoryItems. - - All required parameters must be populated in order to send to Azure. - - :param next_link: Url to follow for getting next page of InventoryItems. - :type next_link: str - :param value: Required. Array of InventoryItems. - :type value: list[~azure.mgmt.connectedvmware.models.InventoryItem] - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[InventoryItem]'}, - } - - def __init__( - self, - **kwargs - ): - super(InventoryItemsList, self).__init__(**kwargs) - self.next_link = kwargs.get('next_link', None) - self.value = kwargs['value'] - - -class MachineExtension(msrest.serialization.Model): - """Describes a Machine Extension. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param location: Gets or sets the location. - :type location: str - :ivar system_data: The system data. - :vartype system_data: ~azure.mgmt.connectedvmware.models.SystemData - :param tags: A set of tags. Gets or sets the Resource tags. - :type tags: dict[str, str] - :ivar name: Gets or sets the name. - :vartype name: str - :ivar id: Gets or sets the Id. - :vartype id: str - :ivar type: Gets or sets the type of the resource. - :vartype type: str - :param force_update_tag: How the extension handler should be forced to update even if the - extension configuration has not changed. - :type force_update_tag: str - :param publisher: The name of the extension handler publisher. - :type publisher: str - :param type_properties_type: Specifies the type of the extension; an example is - "CustomScriptExtension". - :type type_properties_type: str - :param type_handler_version: Specifies the version of the script handler. - :type type_handler_version: str - :param auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :type auto_upgrade_minor_version: bool - :param settings: Json formatted public settings for the extension. - :type settings: any - :param protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :type protected_settings: any - :ivar provisioning_state: The provisioning state, which only appears in the response. - :vartype provisioning_state: str - :param instance_view: The machine extension instance view. - :type instance_view: ~azure.mgmt.connectedvmware.models.MachineExtensionPropertiesInstanceView - """ - - _validation = { - 'system_data': {'readonly': True}, - 'name': {'readonly': True}, - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'name': {'key': 'name', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'force_update_tag': {'key': 'properties.forceUpdateTag', 'type': 'str'}, - 'publisher': {'key': 'properties.publisher', 'type': 'str'}, - 'type_properties_type': {'key': 'properties.type', 'type': 'str'}, - 'type_handler_version': {'key': 'properties.typeHandlerVersion', 'type': 'str'}, - 'auto_upgrade_minor_version': {'key': 'properties.autoUpgradeMinorVersion', 'type': 'bool'}, - 'settings': {'key': 'properties.settings', 'type': 'object'}, - 'protected_settings': {'key': 'properties.protectedSettings', 'type': 'object'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'instance_view': {'key': 'properties.instanceView', 'type': 'MachineExtensionPropertiesInstanceView'}, - } - - def __init__( - self, - **kwargs - ): - super(MachineExtension, self).__init__(**kwargs) - self.location = kwargs.get('location', None) - self.system_data = None - self.tags = kwargs.get('tags', None) - self.name = None - self.id = None - self.type = None - self.force_update_tag = kwargs.get('force_update_tag', None) - self.publisher = kwargs.get('publisher', None) - self.type_properties_type = kwargs.get('type_properties_type', None) - self.type_handler_version = kwargs.get('type_handler_version', None) - self.auto_upgrade_minor_version = kwargs.get('auto_upgrade_minor_version', None) - self.settings = kwargs.get('settings', None) - self.protected_settings = kwargs.get('protected_settings', None) - self.provisioning_state = None - self.instance_view = kwargs.get('instance_view', None) - - -class MachineExtensionInstanceView(msrest.serialization.Model): - """Describes the Machine Extension Instance View. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The machine extension name. - :vartype name: str - :ivar type: Specifies the type of the extension; an example is "CustomScriptExtension". - :vartype type: str - :ivar type_handler_version: Specifies the version of the script handler. - :vartype type_handler_version: str - :param status: Instance view status. - :type status: ~azure.mgmt.connectedvmware.models.MachineExtensionInstanceViewStatus - """ - - _validation = { - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'type_handler_version': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'type_handler_version': {'key': 'typeHandlerVersion', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'MachineExtensionInstanceViewStatus'}, - } - - def __init__( - self, - **kwargs - ): - super(MachineExtensionInstanceView, self).__init__(**kwargs) - self.name = None - self.type = None - self.type_handler_version = None - self.status = kwargs.get('status', None) - - -class MachineExtensionInstanceViewStatus(msrest.serialization.Model): - """Instance view status. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The status code. - :vartype code: str - :ivar level: The level code. Possible values include: "Info", "Warning", "Error". - :vartype level: str or ~azure.mgmt.connectedvmware.models.StatusLevelTypes - :ivar display_status: The short localizable label for the status. - :vartype display_status: str - :ivar message: The detailed status message, including for alerts and error messages. - :vartype message: str - :ivar time: The time of the status. - :vartype time: ~datetime.datetime - """ - - _validation = { - 'code': {'readonly': True}, - 'level': {'readonly': True}, - 'display_status': {'readonly': True}, - 'message': {'readonly': True}, - 'time': {'readonly': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'level': {'key': 'level', 'type': 'str'}, - 'display_status': {'key': 'displayStatus', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'time': {'key': 'time', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(MachineExtensionInstanceViewStatus, self).__init__(**kwargs) - self.code = None - self.level = None - self.display_status = None - self.message = None - self.time = None - - -class MachineExtensionPropertiesInstanceView(MachineExtensionInstanceView): - """The machine extension instance view. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The machine extension name. - :vartype name: str - :ivar type: Specifies the type of the extension; an example is "CustomScriptExtension". - :vartype type: str - :ivar type_handler_version: Specifies the version of the script handler. - :vartype type_handler_version: str - :param status: Instance view status. - :type status: ~azure.mgmt.connectedvmware.models.MachineExtensionInstanceViewStatus - """ - - _validation = { - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'type_handler_version': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'type_handler_version': {'key': 'typeHandlerVersion', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'MachineExtensionInstanceViewStatus'}, - } - - def __init__( - self, - **kwargs - ): - super(MachineExtensionPropertiesInstanceView, self).__init__(**kwargs) - - -class MachineExtensionsListResult(msrest.serialization.Model): - """Describes the Machine Extensions List Result. - - :param value: The list of extensions. - :type value: list[~azure.mgmt.connectedvmware.models.MachineExtension] - :param next_link: The uri to fetch the next page of machine extensions. Call ListNext() with - this to fetch the next page of extensions. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[MachineExtension]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MachineExtensionsListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class ResourcePatch(msrest.serialization.Model): - """Object containing updates for patch operations. - - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourcePatch, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - - -class MachineExtensionUpdate(ResourcePatch): - """Describes a Machine Extension Update. - - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param force_update_tag: How the extension handler should be forced to update even if the - extension configuration has not changed. - :type force_update_tag: str - :param publisher: The name of the extension handler publisher. - :type publisher: str - :param type: Specifies the type of the extension; an example is "CustomScriptExtension". - :type type: str - :param type_handler_version: Specifies the version of the script handler. - :type type_handler_version: str - :param auto_upgrade_minor_version: Indicates whether the extension should use a newer minor - version if one is available at deployment time. Once deployed, however, the extension will not - upgrade minor versions unless redeployed, even with this property set to true. - :type auto_upgrade_minor_version: bool - :param settings: Json formatted public settings for the extension. - :type settings: any - :param protected_settings: The extension can contain either protectedSettings or - protectedSettingsFromKeyVault or no protected settings at all. - :type protected_settings: any - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'force_update_tag': {'key': 'properties.forceUpdateTag', 'type': 'str'}, - 'publisher': {'key': 'properties.publisher', 'type': 'str'}, - 'type': {'key': 'properties.type', 'type': 'str'}, - 'type_handler_version': {'key': 'properties.typeHandlerVersion', 'type': 'str'}, - 'auto_upgrade_minor_version': {'key': 'properties.autoUpgradeMinorVersion', 'type': 'bool'}, - 'settings': {'key': 'properties.settings', 'type': 'object'}, - 'protected_settings': {'key': 'properties.protectedSettings', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(MachineExtensionUpdate, self).__init__(**kwargs) - self.force_update_tag = kwargs.get('force_update_tag', None) - self.publisher = kwargs.get('publisher', None) - self.type = kwargs.get('type', None) - self.type_handler_version = kwargs.get('type_handler_version', None) - self.auto_upgrade_minor_version = kwargs.get('auto_upgrade_minor_version', None) - self.settings = kwargs.get('settings', None) - self.protected_settings = kwargs.get('protected_settings', None) - - -class NetworkInterface(msrest.serialization.Model): - """Network Interface model. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param name: Gets or sets the name of the network interface. - :type name: str - :ivar label: Gets or sets the label of the virtual network in vCenter that the nic is connected - to. - :vartype label: str - :ivar ip_addresses: Gets or sets the nic ip addresses. - :vartype ip_addresses: list[str] - :ivar mac_address: Gets or sets the NIC MAC address. - :vartype mac_address: str - :param network_id: Gets or sets the ARM Id of the network resource to connect the virtual - machine. - :type network_id: str - :param nic_type: NIC type. Possible values include: "vmxnet3", "vmxnet2", "vmxnet", "e1000", - "e1000e", "pcnet32". - :type nic_type: str or ~azure.mgmt.connectedvmware.models.NICType - :param power_on_boot: Gets or sets the power on boot. Possible values include: "enabled", - "disabled". - :type power_on_boot: str or ~azure.mgmt.connectedvmware.models.PowerOnBootOption - :ivar network_mo_ref_id: Gets or sets the vCenter MoRef (Managed Object Reference) ID of the - virtual network - that the nic is connected to. - :vartype network_mo_ref_id: str - :ivar network_mo_name: Gets or sets the name of the virtual network in vCenter that the nic is - connected to. - :vartype network_mo_name: str - :param device_key: Gets or sets the device key value. - :type device_key: int - :param ip_settings: Gets or sets the ipsettings. - :type ip_settings: ~azure.mgmt.connectedvmware.models.NicIPSettings - """ - - _validation = { - 'label': {'readonly': True}, - 'ip_addresses': {'readonly': True}, - 'mac_address': {'readonly': True}, - 'network_mo_ref_id': {'readonly': True}, - 'network_mo_name': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'ip_addresses': {'key': 'ipAddresses', 'type': '[str]'}, - 'mac_address': {'key': 'macAddress', 'type': 'str'}, - 'network_id': {'key': 'networkId', 'type': 'str'}, - 'nic_type': {'key': 'nicType', 'type': 'str'}, - 'power_on_boot': {'key': 'powerOnBoot', 'type': 'str'}, - 'network_mo_ref_id': {'key': 'networkMoRefId', 'type': 'str'}, - 'network_mo_name': {'key': 'networkMoName', 'type': 'str'}, - 'device_key': {'key': 'deviceKey', 'type': 'int'}, - 'ip_settings': {'key': 'ipSettings', 'type': 'NicIPSettings'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkInterface, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.label = None - self.ip_addresses = None - self.mac_address = None - self.network_id = kwargs.get('network_id', None) - self.nic_type = kwargs.get('nic_type', None) - self.power_on_boot = kwargs.get('power_on_boot', None) - self.network_mo_ref_id = None - self.network_mo_name = None - self.device_key = kwargs.get('device_key', None) - self.ip_settings = kwargs.get('ip_settings', None) - - -class NetworkInterfaceUpdate(msrest.serialization.Model): - """Defines the network interface update. - - :param name: Gets or sets the name of the network interface. - :type name: str - :param network_id: Gets or sets the ARM Id of the network resource to connect the virtual - machine. - :type network_id: str - :param nic_type: NIC type. Possible values include: "vmxnet3", "vmxnet2", "vmxnet", "e1000", - "e1000e", "pcnet32". - :type nic_type: str or ~azure.mgmt.connectedvmware.models.NICType - :param power_on_boot: Gets or sets the power on boot. Possible values include: "enabled", - "disabled". - :type power_on_boot: str or ~azure.mgmt.connectedvmware.models.PowerOnBootOption - :param device_key: Gets or sets the device key value. - :type device_key: int - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'network_id': {'key': 'networkId', 'type': 'str'}, - 'nic_type': {'key': 'nicType', 'type': 'str'}, - 'power_on_boot': {'key': 'powerOnBoot', 'type': 'str'}, - 'device_key': {'key': 'deviceKey', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkInterfaceUpdate, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.network_id = kwargs.get('network_id', None) - self.nic_type = kwargs.get('nic_type', None) - self.power_on_boot = kwargs.get('power_on_boot', None) - self.device_key = kwargs.get('device_key', None) - - -class NetworkProfile(msrest.serialization.Model): - """Defines the resource properties. - - :param network_interfaces: Gets or sets the list of network interfaces associated with the - virtual machine. - :type network_interfaces: list[~azure.mgmt.connectedvmware.models.NetworkInterface] - """ - - _attribute_map = { - 'network_interfaces': {'key': 'networkInterfaces', 'type': '[NetworkInterface]'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkProfile, self).__init__(**kwargs) - self.network_interfaces = kwargs.get('network_interfaces', None) - - -class NetworkProfileUpdate(msrest.serialization.Model): - """Defines the update resource properties. - - :param network_interfaces: Gets or sets the list of network interfaces associated with the - virtual machine. - :type network_interfaces: list[~azure.mgmt.connectedvmware.models.NetworkInterfaceUpdate] - """ - - _attribute_map = { - 'network_interfaces': {'key': 'networkInterfaces', 'type': '[NetworkInterfaceUpdate]'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkProfileUpdate, self).__init__(**kwargs) - self.network_interfaces = kwargs.get('network_interfaces', None) - - -class NicIPAddressSettings(msrest.serialization.Model): - """IP address information for a virtual network adapter reported by the fabric. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar allocation_method: Gets the ip address allocation method. - :vartype allocation_method: str - :ivar ip_address: Gets the ip address for the nic. - :vartype ip_address: str - :ivar subnet_mask: Gets the mask. - :vartype subnet_mask: str - """ - - _validation = { - 'allocation_method': {'readonly': True}, - 'ip_address': {'readonly': True}, - 'subnet_mask': {'readonly': True}, - } - - _attribute_map = { - 'allocation_method': {'key': 'allocationMethod', 'type': 'str'}, - 'ip_address': {'key': 'ipAddress', 'type': 'str'}, - 'subnet_mask': {'key': 'subnetMask', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(NicIPAddressSettings, self).__init__(**kwargs) - self.allocation_method = None - self.ip_address = None - self.subnet_mask = None - - -class NicIPSettings(msrest.serialization.Model): - """Defines the network interface ip settings. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param allocation_method: Gets or sets the nic allocation method. Possible values include: - "unset", "dynamic", "static", "linklayer", "random", "other". - :type allocation_method: str or ~azure.mgmt.connectedvmware.models.IPAddressAllocationMethod - :param dns_servers: Gets or sets the dns servers. - :type dns_servers: list[str] - :param gateway: Gets or sets the gateway. - :type gateway: list[str] - :param ip_address: Gets or sets the ip address for the nic. - :type ip_address: str - :param subnet_mask: Gets or sets the mask. - :type subnet_mask: str - :ivar primary_wins_server: Gets or sets the primary server. - :vartype primary_wins_server: str - :ivar secondary_wins_server: Gets or sets the secondary server. - :vartype secondary_wins_server: str - :ivar ip_address_info: Gets or sets the IP address information being reported for this NIC. - This contains the same IPv4 information above plus IPV6 information. - :vartype ip_address_info: list[~azure.mgmt.connectedvmware.models.NicIPAddressSettings] - """ - - _validation = { - 'primary_wins_server': {'readonly': True}, - 'secondary_wins_server': {'readonly': True}, - 'ip_address_info': {'readonly': True}, - } - - _attribute_map = { - 'allocation_method': {'key': 'allocationMethod', 'type': 'str'}, - 'dns_servers': {'key': 'dnsServers', 'type': '[str]'}, - 'gateway': {'key': 'gateway', 'type': '[str]'}, - 'ip_address': {'key': 'ipAddress', 'type': 'str'}, - 'subnet_mask': {'key': 'subnetMask', 'type': 'str'}, - 'primary_wins_server': {'key': 'primaryWinsServer', 'type': 'str'}, - 'secondary_wins_server': {'key': 'secondaryWinsServer', 'type': 'str'}, - 'ip_address_info': {'key': 'ipAddressInfo', 'type': '[NicIPAddressSettings]'}, - } - - def __init__( - self, - **kwargs - ): - super(NicIPSettings, self).__init__(**kwargs) - self.allocation_method = kwargs.get('allocation_method', None) - self.dns_servers = kwargs.get('dns_servers', None) - self.gateway = kwargs.get('gateway', None) - self.ip_address = kwargs.get('ip_address', None) - self.subnet_mask = kwargs.get('subnet_mask', None) - self.primary_wins_server = None - self.secondary_wins_server = None - self.ip_address_info = None - - -class Operation(msrest.serialization.Model): - """Operation provided by provider. - - :param name: Name of the operation. - :type name: str - :param is_data_action: Indicates whether the operation is data action or not. - :type is_data_action: bool - :param display: Properties of the operation. - :type display: ~azure.mgmt.connectedvmware.models.OperationDisplay - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - } - - 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) - - -class OperationDisplay(msrest.serialization.Model): - """Properties of the operation. - - :param provider: Provider name. - :type provider: str - :param resource: Resource name. - :type resource: str - :param operation: Operation name. - :type operation: str - :param description: Description of the 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 OperationsList(msrest.serialization.Model): - """Lists the operations available. - - All required parameters must be populated in order to send to Azure. - - :param next_link: Url to follow for getting next page of operations. - :type next_link: str - :param value: Required. Array of operations. - :type value: list[~azure.mgmt.connectedvmware.models.Operation] - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[Operation]'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationsList, self).__init__(**kwargs) - self.next_link = kwargs.get('next_link', None) - self.value = kwargs['value'] - - -class OsProfile(msrest.serialization.Model): - """Defines the resource properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param computer_name: Gets or sets computer name. - :type computer_name: str - :param admin_username: Gets or sets administrator username. - :type admin_username: str - :param admin_password: Gets or sets administrator password. - :type admin_password: str - :param os_type: Gets or sets the type of the os. Possible values include: "Windows", "Linux", - "Other". - :type os_type: str or ~azure.mgmt.connectedvmware.models.OsType - :ivar os_name: Gets or sets os name. - :vartype os_name: str - :ivar tools_running_status: Gets or sets the current running status of VMware Tools running in - the guest operating system. - :vartype tools_running_status: str - :ivar tools_version_status: Gets or sets the current version status of VMware Tools installed - in the guest operating system. - :vartype tools_version_status: str - :ivar tools_version: Gets or sets the current version of VMware Tools. - :vartype tools_version: str - """ - - _validation = { - 'os_name': {'readonly': True}, - 'tools_running_status': {'readonly': True}, - 'tools_version_status': {'readonly': True}, - 'tools_version': {'readonly': True}, - } - - _attribute_map = { - 'computer_name': {'key': 'computerName', 'type': 'str'}, - 'admin_username': {'key': 'adminUsername', 'type': 'str'}, - 'admin_password': {'key': 'adminPassword', 'type': 'str'}, - 'os_type': {'key': 'osType', 'type': 'str'}, - 'os_name': {'key': 'osName', 'type': 'str'}, - 'tools_running_status': {'key': 'toolsRunningStatus', 'type': 'str'}, - 'tools_version_status': {'key': 'toolsVersionStatus', 'type': 'str'}, - 'tools_version': {'key': 'toolsVersion', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OsProfile, self).__init__(**kwargs) - self.computer_name = kwargs.get('computer_name', None) - self.admin_username = kwargs.get('admin_username', None) - self.admin_password = kwargs.get('admin_password', None) - self.os_type = kwargs.get('os_type', None) - self.os_name = None - self.tools_running_status = None - self.tools_version_status = None - self.tools_version = None - - -class PlacementProfile(msrest.serialization.Model): - """Defines the resource properties. - - :param resource_pool_id: Gets or sets the ARM Id of the resourcePool resource on which this - virtual machine will deploy. - :type resource_pool_id: str - :param cluster_id: Gets or sets the ARM Id of the cluster resource on which this virtual - machine will deploy. - :type cluster_id: str - :param host_id: Gets or sets the ARM Id of the host resource on which this virtual machine will - deploy. - :type host_id: str - :param datastore_id: Gets or sets the ARM Id of the datastore resource on which the data for - the virtual machine will be kept. - :type datastore_id: str - """ - - _attribute_map = { - 'resource_pool_id': {'key': 'resourcePoolId', 'type': 'str'}, - 'cluster_id': {'key': 'clusterId', 'type': 'str'}, - 'host_id': {'key': 'hostId', 'type': 'str'}, - 'datastore_id': {'key': 'datastoreId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PlacementProfile, self).__init__(**kwargs) - self.resource_pool_id = kwargs.get('resource_pool_id', None) - self.cluster_id = kwargs.get('cluster_id', None) - self.host_id = kwargs.get('host_id', None) - self.datastore_id = kwargs.get('datastore_id', None) - - -class ResourcePool(msrest.serialization.Model): - """Define the resourcePool. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param location: Required. Gets or sets the location. - :type location: str - :param extended_location: Gets or sets the extended location. - :type extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation - :ivar system_data: The system data. - :vartype system_data: ~azure.mgmt.connectedvmware.models.SystemData - :param tags: A set of tags. Gets or sets the Resource tags. - :type tags: dict[str, str] - :ivar name: Gets or sets the name. - :vartype name: str - :ivar id: Gets or sets the Id. - :vartype id: str - :ivar type: Gets or sets the type of the resource. - :vartype type: str - :param kind: Metadata used by portal/tooling/etc to render different UX experiences for - resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, - the resource provider must validate and persist this value. - :type kind: str - :ivar uuid: Gets or sets a unique identifier for this resource. - :vartype uuid: str - :param v_center_id: Gets or sets the ARM Id of the vCenter resource in which this resource pool - resides. - :type v_center_id: str - :param mo_ref_id: Gets or sets the vCenter MoRef (Managed Object Reference) ID for the resource - pool. - :type mo_ref_id: str - :param inventory_item_id: Gets or sets the inventory Item ID for the resource pool. - :type inventory_item_id: str - :ivar mo_name: Gets or sets the vCenter Managed Object name for the resource pool. - :vartype mo_name: str - :ivar cpu_shares_level: Gets or sets CPUSharesLevel which specifies the CPU allocation level - for this pool. - This property is used in relative allocation between resource consumers. - :vartype cpu_shares_level: str - :ivar cpu_reservation_m_hz: Gets or sets CPUReservationMHz which specifies the CPU size in MHz - that is guaranteed - to be available. - :vartype cpu_reservation_m_hz: long - :ivar cpu_limit_m_hz: Gets or sets CPULimitMHz which specifies a CPU usage limit in MHz. - Utilization will not exceed this limit even if there are available resources. - :vartype cpu_limit_m_hz: long - :ivar mem_shares_level: Gets or sets CPUSharesLevel which specifies the memory allocation level - for this pool. - This property is used in relative allocation between resource consumers. - :vartype mem_shares_level: str - :ivar mem_reservation_mb: Gets or sets MemReservationMB which specifies the guaranteed - available memory in - megabytes. - :vartype mem_reservation_mb: long - :ivar mem_limit_mb: Gets or sets MemLimitMB specifies a memory usage limit in megabytes. - Utilization will not exceed the specified limit even if there are available resources. - :vartype mem_limit_mb: long - :ivar custom_resource_name: Gets the name of the corresponding resource in Kubernetes. - :vartype custom_resource_name: str - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.connectedvmware.models.ResourceStatus] - :ivar provisioning_state: Gets or sets the provisioning state. - :vartype provisioning_state: str - """ - - _validation = { - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'name': {'readonly': True}, - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'uuid': {'readonly': True}, - 'mo_name': {'readonly': True}, - 'cpu_shares_level': {'readonly': True}, - 'cpu_reservation_m_hz': {'readonly': True}, - 'cpu_limit_m_hz': {'readonly': True}, - 'mem_shares_level': {'readonly': True}, - 'mem_reservation_mb': {'readonly': True}, - 'mem_limit_mb': {'readonly': True}, - 'custom_resource_name': {'readonly': True}, - 'statuses': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'name': {'key': 'name', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'uuid': {'key': 'properties.uuid', 'type': 'str'}, - 'v_center_id': {'key': 'properties.vCenterId', 'type': 'str'}, - 'mo_ref_id': {'key': 'properties.moRefId', 'type': 'str'}, - 'inventory_item_id': {'key': 'properties.inventoryItemId', 'type': 'str'}, - 'mo_name': {'key': 'properties.moName', 'type': 'str'}, - 'cpu_shares_level': {'key': 'properties.cpuSharesLevel', 'type': 'str'}, - 'cpu_reservation_m_hz': {'key': 'properties.cpuReservationMHz', 'type': 'long'}, - 'cpu_limit_m_hz': {'key': 'properties.cpuLimitMHz', 'type': 'long'}, - 'mem_shares_level': {'key': 'properties.memSharesLevel', 'type': 'str'}, - 'mem_reservation_mb': {'key': 'properties.memReservationMB', 'type': 'long'}, - 'mem_limit_mb': {'key': 'properties.memLimitMB', 'type': 'long'}, - 'custom_resource_name': {'key': 'properties.customResourceName', 'type': 'str'}, - 'statuses': {'key': 'properties.statuses', 'type': '[ResourceStatus]'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourcePool, self).__init__(**kwargs) - self.location = kwargs['location'] - self.extended_location = kwargs.get('extended_location', None) - self.system_data = None - self.tags = kwargs.get('tags', None) - self.name = None - self.id = None - self.type = None - self.kind = kwargs.get('kind', None) - self.uuid = None - self.v_center_id = kwargs.get('v_center_id', None) - self.mo_ref_id = kwargs.get('mo_ref_id', None) - self.inventory_item_id = kwargs.get('inventory_item_id', None) - self.mo_name = None - self.cpu_shares_level = None - self.cpu_reservation_m_hz = None - self.cpu_limit_m_hz = None - self.mem_shares_level = None - self.mem_reservation_mb = None - self.mem_limit_mb = None - self.custom_resource_name = None - self.statuses = None - self.provisioning_state = None - - -class ResourcePoolInventoryItem(InventoryItemProperties): - """The resource pool inventory item. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param inventory_type: Required. They inventory type.Constant filled by server. Possible - values include: "ResourcePool", "VirtualMachine", "VirtualMachineTemplate", "VirtualNetwork", - "Cluster", "Datastore", "Host". - :type inventory_type: str or ~azure.mgmt.connectedvmware.models.InventoryType - :param managed_resource_id: Gets or sets the tracked resource id corresponding to the inventory - resource. - :type managed_resource_id: str - :param mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory item. - :type mo_ref_id: str - :param mo_name: Gets or sets the vCenter Managed Object name for the inventory item. - :type mo_name: str - :ivar provisioning_state: Gets or sets the provisioning state. - :vartype provisioning_state: str - :param parent: Parent resourcePool inventory resource details. - :type parent: ~azure.mgmt.connectedvmware.models.InventoryItemDetails - """ - - _validation = { - 'inventory_type': {'required': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'inventory_type': {'key': 'inventoryType', 'type': 'str'}, - 'managed_resource_id': {'key': 'managedResourceId', 'type': 'str'}, - 'mo_ref_id': {'key': 'moRefId', 'type': 'str'}, - 'mo_name': {'key': 'moName', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'parent': {'key': 'parent', 'type': 'InventoryItemDetails'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourcePoolInventoryItem, self).__init__(**kwargs) - self.inventory_type = 'ResourcePool' # type: str - self.parent = kwargs.get('parent', None) - - -class ResourcePoolsList(msrest.serialization.Model): - """List of ResourcePools. - - All required parameters must be populated in order to send to Azure. - - :param next_link: Url to follow for getting next page of ResourcePools. - :type next_link: str - :param value: Required. Array of ResourcePools. - :type value: list[~azure.mgmt.connectedvmware.models.ResourcePool] - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[ResourcePool]'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourcePoolsList, self).__init__(**kwargs) - self.next_link = kwargs.get('next_link', None) - self.value = kwargs['value'] - - -class ResourceStatus(msrest.serialization.Model): - """The resource status information. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The type of the condition. - :vartype type: str - :ivar status: Status of the condition. - :vartype status: str - :ivar reason: The reason for the condition's status. - :vartype reason: str - :ivar message: A human readable message indicating details about the status. - :vartype message: str - :ivar severity: Severity with which to treat failures of this type of condition. - :vartype severity: str - :ivar last_updated_at: The last update time for this condition. - :vartype last_updated_at: ~datetime.datetime - """ - - _validation = { - 'type': {'readonly': True}, - 'status': {'readonly': True}, - 'reason': {'readonly': True}, - 'message': {'readonly': True}, - 'severity': {'readonly': True}, - 'last_updated_at': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'severity': {'key': 'severity', 'type': 'str'}, - 'last_updated_at': {'key': 'lastUpdatedAt', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceStatus, self).__init__(**kwargs) - self.type = None - self.status = None - self.reason = None - self.message = None - self.severity = None - self.last_updated_at = None - - -class StopVirtualMachineOptions(msrest.serialization.Model): - """Defines the stop action properties. - - :param skip_shutdown: Gets or sets a value indicating whether to request non-graceful VM - shutdown. True value for this flag indicates non-graceful shutdown whereas false indicates - otherwise. Defaults to false. - :type skip_shutdown: bool - """ - - _attribute_map = { - 'skip_shutdown': {'key': 'skipShutdown', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(StopVirtualMachineOptions, self).__init__(**kwargs) - self.skip_shutdown = kwargs.get('skip_shutdown', False) - - -class StorageProfile(msrest.serialization.Model): - """Defines the resource properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param disks: Gets or sets the list of virtual disks associated with the virtual machine. - :type disks: list[~azure.mgmt.connectedvmware.models.VirtualDisk] - :ivar scsi_controllers: Gets or sets the list of virtual SCSI controllers associated with the - virtual machine. - :vartype scsi_controllers: list[~azure.mgmt.connectedvmware.models.VirtualSCSIController] - """ - - _validation = { - 'scsi_controllers': {'readonly': True}, - } - - _attribute_map = { - 'disks': {'key': 'disks', 'type': '[VirtualDisk]'}, - 'scsi_controllers': {'key': 'scsiControllers', 'type': '[VirtualSCSIController]'}, - } - - def __init__( - self, - **kwargs - ): - super(StorageProfile, self).__init__(**kwargs) - self.disks = kwargs.get('disks', None) - self.scsi_controllers = None - - -class StorageProfileUpdate(msrest.serialization.Model): - """Defines the resource update properties. - - :param disks: Gets or sets the list of virtual disks associated with the virtual machine. - :type disks: list[~azure.mgmt.connectedvmware.models.VirtualDiskUpdate] - """ - - _attribute_map = { - 'disks': {'key': 'disks', 'type': '[VirtualDiskUpdate]'}, - } - - def __init__( - self, - **kwargs - ): - super(StorageProfileUpdate, self).__init__(**kwargs) - self.disks = kwargs.get('disks', None) - - -class SystemData(msrest.serialization.Model): - """Metadata pertaining to creation and last modification of the resource. - - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~azure.mgmt.connectedvmware.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or ~azure.mgmt.connectedvmware.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - 'created_by': {'key': 'createdBy', 'type': 'str'}, - 'created_by_type': {'key': 'createdByType', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(SystemData, self).__init__(**kwargs) - self.created_by = kwargs.get('created_by', None) - self.created_by_type = kwargs.get('created_by_type', None) - self.created_at = kwargs.get('created_at', None) - self.last_modified_by = kwargs.get('last_modified_by', None) - self.last_modified_by_type = kwargs.get('last_modified_by_type', None) - self.last_modified_at = kwargs.get('last_modified_at', None) - - -class VCenter(msrest.serialization.Model): - """Defines the vCenter. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param location: Required. Gets or sets the location. - :type location: str - :param extended_location: Gets or sets the extended location. - :type extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation - :ivar system_data: The system data. - :vartype system_data: ~azure.mgmt.connectedvmware.models.SystemData - :param tags: A set of tags. Gets or sets the Resource tags. - :type tags: dict[str, str] - :ivar name: Gets or sets the name. - :vartype name: str - :ivar id: Gets or sets the Id. - :vartype id: str - :ivar type: Gets or sets the type of the resource. - :vartype type: str - :param kind: Metadata used by portal/tooling/etc to render different UX experiences for - resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, - the resource provider must validate and persist this value. - :type kind: str - :ivar uuid: Gets or sets a unique identifier for this resource. - :vartype uuid: str - :param fqdn: Required. Gets or sets the FQDN/IPAddress of the vCenter. - :type fqdn: str - :param port: Gets or sets the port of the vCenter. - :type port: int - :ivar version: Gets or sets the version of the vCenter. - :vartype version: str - :ivar instance_uuid: Gets or sets the instance UUID of the vCenter. - :vartype instance_uuid: str - :ivar connection_status: Gets or sets the connection status to the vCenter. - :vartype connection_status: str - :ivar custom_resource_name: Gets the name of the corresponding resource in Kubernetes. - :vartype custom_resource_name: str - :param credentials: Username / Password Credentials to connect to vcenter. - :type credentials: ~azure.mgmt.connectedvmware.models.VICredential - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.connectedvmware.models.ResourceStatus] - :ivar provisioning_state: Gets or sets the provisioning state. - :vartype provisioning_state: str - """ - - _validation = { - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'name': {'readonly': True}, - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'uuid': {'readonly': True}, - 'fqdn': {'required': True}, - 'port': {'maximum': 65535, 'minimum': 1}, - 'version': {'readonly': True}, - 'instance_uuid': {'readonly': True}, - 'connection_status': {'readonly': True}, - 'custom_resource_name': {'readonly': True}, - 'statuses': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'name': {'key': 'name', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'uuid': {'key': 'properties.uuid', 'type': 'str'}, - 'fqdn': {'key': 'properties.fqdn', 'type': 'str'}, - 'port': {'key': 'properties.port', 'type': 'int'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'instance_uuid': {'key': 'properties.instanceUuid', 'type': 'str'}, - 'connection_status': {'key': 'properties.connectionStatus', 'type': 'str'}, - 'custom_resource_name': {'key': 'properties.customResourceName', 'type': 'str'}, - 'credentials': {'key': 'properties.credentials', 'type': 'VICredential'}, - 'statuses': {'key': 'properties.statuses', 'type': '[ResourceStatus]'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(VCenter, self).__init__(**kwargs) - self.location = kwargs['location'] - self.extended_location = kwargs.get('extended_location', None) - self.system_data = None - self.tags = kwargs.get('tags', None) - self.name = None - self.id = None - self.type = None - self.kind = kwargs.get('kind', None) - self.uuid = None - self.fqdn = kwargs['fqdn'] - self.port = kwargs.get('port', None) - self.version = None - self.instance_uuid = None - self.connection_status = None - self.custom_resource_name = None - self.credentials = kwargs.get('credentials', None) - self.statuses = None - self.provisioning_state = None - - -class VCentersList(msrest.serialization.Model): - """List of VCenters. - - All required parameters must be populated in order to send to Azure. - - :param next_link: Url to follow for getting next page of VCenters. - :type next_link: str - :param value: Required. Array of VCenters. - :type value: list[~azure.mgmt.connectedvmware.models.VCenter] - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[VCenter]'}, - } - - def __init__( - self, - **kwargs - ): - super(VCentersList, self).__init__(**kwargs) - self.next_link = kwargs.get('next_link', None) - self.value = kwargs['value'] - - -class VICredential(msrest.serialization.Model): - """Username / Password Credentials to connect to vcenter. - - :param username: Gets or sets username to connect with the vCenter. - :type username: str - :param password: Gets or sets the password to connect with the vCenter. - :type password: str - """ - - _attribute_map = { - 'username': {'key': 'username', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(VICredential, self).__init__(**kwargs) - self.username = kwargs.get('username', None) - self.password = kwargs.get('password', None) - - -class VirtualDisk(msrest.serialization.Model): - """Virtual disk model. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param name: Gets or sets the name of the virtual disk. - :type name: str - :ivar label: Gets or sets the label of the virtual disk in vCenter. - :vartype label: str - :ivar disk_object_id: Gets or sets the disk object id. - :vartype disk_object_id: str - :param disk_size_gb: Gets or sets the disk total size. - :type disk_size_gb: int - :param device_key: Gets or sets the device key value. - :type device_key: int - :param disk_mode: Gets or sets the disk mode. Possible values include: "persistent", - "independent_persistent", "independent_nonpersistent". - :type disk_mode: str or ~azure.mgmt.connectedvmware.models.DiskMode - :param controller_key: Gets or sets the controller id. - :type controller_key: int - :param unit_number: Gets or sets the unit number of the disk on the controller. - :type unit_number: int - :param device_name: Gets or sets the device name. - :type device_name: str - :param disk_type: Gets or sets the disk backing type. Possible values include: "flat", "pmem", - "rawphysical", "rawvirtual", "sparse", "sesparse", "unknown". - :type disk_type: str or ~azure.mgmt.connectedvmware.models.DiskType - """ - - _validation = { - 'label': {'readonly': True}, - 'disk_object_id': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'disk_object_id': {'key': 'diskObjectId', 'type': 'str'}, - 'disk_size_gb': {'key': 'diskSizeGB', 'type': 'int'}, - 'device_key': {'key': 'deviceKey', 'type': 'int'}, - 'disk_mode': {'key': 'diskMode', 'type': 'str'}, - 'controller_key': {'key': 'controllerKey', 'type': 'int'}, - 'unit_number': {'key': 'unitNumber', 'type': 'int'}, - 'device_name': {'key': 'deviceName', 'type': 'str'}, - 'disk_type': {'key': 'diskType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(VirtualDisk, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.label = None - self.disk_object_id = None - self.disk_size_gb = kwargs.get('disk_size_gb', None) - self.device_key = kwargs.get('device_key', None) - self.disk_mode = kwargs.get('disk_mode', None) - self.controller_key = kwargs.get('controller_key', None) - self.unit_number = kwargs.get('unit_number', None) - self.device_name = kwargs.get('device_name', None) - self.disk_type = kwargs.get('disk_type', None) - - -class VirtualDiskUpdate(msrest.serialization.Model): - """Defines the virtual disk update. - - :param name: Gets or sets the name of the virtual disk. - :type name: str - :param disk_size_gb: Gets or sets the disk total size. - :type disk_size_gb: int - :param device_key: Gets or sets the device key value. - :type device_key: int - :param disk_mode: Gets or sets the disk mode. Possible values include: "persistent", - "independent_persistent", "independent_nonpersistent". - :type disk_mode: str or ~azure.mgmt.connectedvmware.models.DiskMode - :param controller_key: Gets or sets the controller id. - :type controller_key: int - :param unit_number: Gets or sets the unit number of the disk on the controller. - :type unit_number: int - :param device_name: Gets or sets the device name. - :type device_name: str - :param disk_type: Gets or sets the disk backing type. Possible values include: "flat", "pmem", - "rawphysical", "rawvirtual", "sparse", "sesparse", "unknown". - :type disk_type: str or ~azure.mgmt.connectedvmware.models.DiskType - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'disk_size_gb': {'key': 'diskSizeGB', 'type': 'int'}, - 'device_key': {'key': 'deviceKey', 'type': 'int'}, - 'disk_mode': {'key': 'diskMode', 'type': 'str'}, - 'controller_key': {'key': 'controllerKey', 'type': 'int'}, - 'unit_number': {'key': 'unitNumber', 'type': 'int'}, - 'device_name': {'key': 'deviceName', 'type': 'str'}, - 'disk_type': {'key': 'diskType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(VirtualDiskUpdate, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.disk_size_gb = kwargs.get('disk_size_gb', None) - self.device_key = kwargs.get('device_key', None) - self.disk_mode = kwargs.get('disk_mode', None) - self.controller_key = kwargs.get('controller_key', None) - self.unit_number = kwargs.get('unit_number', None) - self.device_name = kwargs.get('device_name', None) - self.disk_type = kwargs.get('disk_type', None) - - -class VirtualMachine(msrest.serialization.Model): - """Define the virtualMachine. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param location: Required. Gets or sets the location. - :type location: str - :param extended_location: Gets or sets the extended location. - :type extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation - :ivar system_data: The system data. - :vartype system_data: ~azure.mgmt.connectedvmware.models.SystemData - :param tags: A set of tags. Gets or sets the Resource tags. - :type tags: dict[str, str] - :ivar name: Gets or sets the name. - :vartype name: str - :ivar id: Gets or sets the Id. - :vartype id: str - :ivar type: Gets or sets the type of the resource. - :vartype type: str - :param kind: Metadata used by portal/tooling/etc to render different UX experiences for - resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, - the resource provider must validate and persist this value. - :type kind: str - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.connectedvmware.models.Identity - :param resource_pool_id: Gets or sets the ARM Id of the resourcePool resource on which this - virtual machine will - deploy. - :type resource_pool_id: str - :param template_id: Gets or sets the ARM Id of the template resource to deploy the virtual - machine. - :type template_id: str - :param v_center_id: Gets or sets the ARM Id of the vCenter resource in which this resource pool - resides. - :type v_center_id: str - :param placement_profile: Placement properties. - :type placement_profile: ~azure.mgmt.connectedvmware.models.PlacementProfile - :param os_profile: OS properties. - :type os_profile: ~azure.mgmt.connectedvmware.models.OsProfile - :param hardware_profile: Hardware properties. - :type hardware_profile: ~azure.mgmt.connectedvmware.models.HardwareProfile - :param network_profile: Network properties. - :type network_profile: ~azure.mgmt.connectedvmware.models.NetworkProfile - :param storage_profile: Storage properties. - :type storage_profile: ~azure.mgmt.connectedvmware.models.StorageProfile - :param guest_agent_profile: Guest agent status properties. - :type guest_agent_profile: ~azure.mgmt.connectedvmware.models.GuestAgentProfile - :param mo_ref_id: Gets or sets the vCenter MoRef (Managed Object Reference) ID for the virtual - machine. - :type mo_ref_id: str - :param inventory_item_id: Gets or sets the inventory Item ID for the virtual machine. - :type inventory_item_id: str - :ivar mo_name: Gets or sets the vCenter Managed Object name for the virtual machine. - :vartype mo_name: str - :ivar folder_path: Gets or sets the folder path of the vm. - :vartype folder_path: str - :ivar instance_uuid: Gets or sets the instance uuid of the vm. - :vartype instance_uuid: str - :param smbios_uuid: Gets or sets the SMBIOS UUID of the vm. - :type smbios_uuid: str - :param firmware_type: Firmware type. Possible values include: "bios", "efi". - :type firmware_type: str or ~azure.mgmt.connectedvmware.models.FirmwareType - :ivar power_state: Gets the power state of the virtual machine. - :vartype power_state: str - :ivar custom_resource_name: Gets the name of the corresponding resource in Kubernetes. - :vartype custom_resource_name: str - :ivar uuid: Gets or sets a unique identifier for this resource. - :vartype uuid: str - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.connectedvmware.models.ResourceStatus] - :ivar provisioning_state: Gets or sets the provisioning state. - :vartype provisioning_state: str - :ivar vm_id: Gets or sets a unique identifier for the vm resource. - :vartype vm_id: str - """ - - _validation = { - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'name': {'readonly': True}, - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'mo_name': {'readonly': True}, - 'folder_path': {'readonly': True}, - 'instance_uuid': {'readonly': True}, - 'power_state': {'readonly': True}, - 'custom_resource_name': {'readonly': True}, - 'uuid': {'readonly': True}, - 'statuses': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'vm_id': {'readonly': True}, - } - - _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'name': {'key': 'name', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'resource_pool_id': {'key': 'properties.resourcePoolId', 'type': 'str'}, - 'template_id': {'key': 'properties.templateId', 'type': 'str'}, - 'v_center_id': {'key': 'properties.vCenterId', 'type': 'str'}, - 'placement_profile': {'key': 'properties.placementProfile', 'type': 'PlacementProfile'}, - 'os_profile': {'key': 'properties.osProfile', 'type': 'OsProfile'}, - 'hardware_profile': {'key': 'properties.hardwareProfile', 'type': 'HardwareProfile'}, - 'network_profile': {'key': 'properties.networkProfile', 'type': 'NetworkProfile'}, - 'storage_profile': {'key': 'properties.storageProfile', 'type': 'StorageProfile'}, - 'guest_agent_profile': {'key': 'properties.guestAgentProfile', 'type': 'GuestAgentProfile'}, - 'mo_ref_id': {'key': 'properties.moRefId', 'type': 'str'}, - 'inventory_item_id': {'key': 'properties.inventoryItemId', 'type': 'str'}, - 'mo_name': {'key': 'properties.moName', 'type': 'str'}, - 'folder_path': {'key': 'properties.folderPath', 'type': 'str'}, - 'instance_uuid': {'key': 'properties.instanceUuid', 'type': 'str'}, - 'smbios_uuid': {'key': 'properties.smbiosUuid', 'type': 'str'}, - 'firmware_type': {'key': 'properties.firmwareType', 'type': 'str'}, - 'power_state': {'key': 'properties.powerState', 'type': 'str'}, - 'custom_resource_name': {'key': 'properties.customResourceName', 'type': 'str'}, - 'uuid': {'key': 'properties.uuid', 'type': 'str'}, - 'statuses': {'key': 'properties.statuses', 'type': '[ResourceStatus]'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'vm_id': {'key': 'properties.vmId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(VirtualMachine, self).__init__(**kwargs) - self.location = kwargs['location'] - self.extended_location = kwargs.get('extended_location', None) - self.system_data = None - self.tags = kwargs.get('tags', None) - self.name = None - self.id = None - self.type = None - self.kind = kwargs.get('kind', None) - self.identity = kwargs.get('identity', None) - self.resource_pool_id = kwargs.get('resource_pool_id', None) - self.template_id = kwargs.get('template_id', None) - self.v_center_id = kwargs.get('v_center_id', None) - self.placement_profile = kwargs.get('placement_profile', None) - self.os_profile = kwargs.get('os_profile', None) - self.hardware_profile = kwargs.get('hardware_profile', None) - self.network_profile = kwargs.get('network_profile', None) - self.storage_profile = kwargs.get('storage_profile', None) - self.guest_agent_profile = kwargs.get('guest_agent_profile', None) - self.mo_ref_id = kwargs.get('mo_ref_id', None) - self.inventory_item_id = kwargs.get('inventory_item_id', None) - self.mo_name = None - self.folder_path = None - self.instance_uuid = None - self.smbios_uuid = kwargs.get('smbios_uuid', None) - self.firmware_type = kwargs.get('firmware_type', None) - self.power_state = None - self.custom_resource_name = None - self.uuid = None - self.statuses = None - self.provisioning_state = None - self.vm_id = None - - -class VirtualMachineInventoryItem(InventoryItemProperties): - """The VM inventory item. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param inventory_type: Required. They inventory type.Constant filled by server. Possible - values include: "ResourcePool", "VirtualMachine", "VirtualMachineTemplate", "VirtualNetwork", - "Cluster", "Datastore", "Host". - :type inventory_type: str or ~azure.mgmt.connectedvmware.models.InventoryType - :param managed_resource_id: Gets or sets the tracked resource id corresponding to the inventory - resource. - :type managed_resource_id: str - :param mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory item. - :type mo_ref_id: str - :param mo_name: Gets or sets the vCenter Managed Object name for the inventory item. - :type mo_name: str - :ivar provisioning_state: Gets or sets the provisioning state. - :vartype provisioning_state: str - :param os_type: Gets or sets the type of the os. Possible values include: "Windows", "Linux", - "Other". - :type os_type: str or ~azure.mgmt.connectedvmware.models.OsType - :param os_name: Gets or sets os name. - :type os_name: str - :param ip_addresses: Gets or sets the nic ip addresses. - :type ip_addresses: list[str] - :param folder_path: Gets or sets the folder path of the vm. - :type folder_path: str - :param host: Host inventory resource details. - :type host: ~azure.mgmt.connectedvmware.models.InventoryItemDetails - :param resource_pool: ResourcePool inventory resource details. - :type resource_pool: ~azure.mgmt.connectedvmware.models.InventoryItemDetails - :param instance_uuid: Gets or sets the instance uuid of the vm. - :type instance_uuid: str - :param smbios_uuid: Gets or sets the SMBIOS UUID of the vm. - :type smbios_uuid: str - :ivar power_state: Gets the power state of the virtual machine. - :vartype power_state: str - :ivar tools_running_status: Gets or sets the current running status of VMware Tools running in - the guest operating system. - :vartype tools_running_status: str - :ivar tools_version_status: Gets or sets the current version status of VMware Tools installed - in the guest operating system. - :vartype tools_version_status: str - :ivar tools_version: Gets or sets the current version of VMware Tools. - :vartype tools_version: str - """ - - _validation = { - 'inventory_type': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'power_state': {'readonly': True}, - 'tools_running_status': {'readonly': True}, - 'tools_version_status': {'readonly': True}, - 'tools_version': {'readonly': True}, - } - - _attribute_map = { - 'inventory_type': {'key': 'inventoryType', 'type': 'str'}, - 'managed_resource_id': {'key': 'managedResourceId', 'type': 'str'}, - 'mo_ref_id': {'key': 'moRefId', 'type': 'str'}, - 'mo_name': {'key': 'moName', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'os_type': {'key': 'osType', 'type': 'str'}, - 'os_name': {'key': 'osName', 'type': 'str'}, - 'ip_addresses': {'key': 'ipAddresses', 'type': '[str]'}, - 'folder_path': {'key': 'folderPath', 'type': 'str'}, - 'host': {'key': 'host', 'type': 'InventoryItemDetails'}, - 'resource_pool': {'key': 'resourcePool', 'type': 'InventoryItemDetails'}, - 'instance_uuid': {'key': 'instanceUuid', 'type': 'str'}, - 'smbios_uuid': {'key': 'smbiosUuid', 'type': 'str'}, - 'power_state': {'key': 'powerState', 'type': 'str'}, - 'tools_running_status': {'key': 'toolsRunningStatus', 'type': 'str'}, - 'tools_version_status': {'key': 'toolsVersionStatus', 'type': 'str'}, - 'tools_version': {'key': 'toolsVersion', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(VirtualMachineInventoryItem, self).__init__(**kwargs) - self.inventory_type = 'VirtualMachine' # type: str - self.os_type = kwargs.get('os_type', None) - self.os_name = kwargs.get('os_name', None) - self.ip_addresses = kwargs.get('ip_addresses', None) - self.folder_path = kwargs.get('folder_path', None) - self.host = kwargs.get('host', None) - self.resource_pool = kwargs.get('resource_pool', None) - self.instance_uuid = kwargs.get('instance_uuid', None) - self.smbios_uuid = kwargs.get('smbios_uuid', None) - self.power_state = None - self.tools_running_status = None - self.tools_version_status = None - self.tools_version = None - - -class VirtualMachinesList(msrest.serialization.Model): - """List of VirtualMachines. - - All required parameters must be populated in order to send to Azure. - - :param next_link: Url to follow for getting next page of VirtualMachines. - :type next_link: str - :param value: Required. Array of VirtualMachines. - :type value: list[~azure.mgmt.connectedvmware.models.VirtualMachine] - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[VirtualMachine]'}, - } - - def __init__( - self, - **kwargs - ): - super(VirtualMachinesList, self).__init__(**kwargs) - self.next_link = kwargs.get('next_link', None) - self.value = kwargs['value'] - - -class VirtualMachineTemplate(msrest.serialization.Model): - """Define the virtualMachineTemplate. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param location: Required. Gets or sets the location. - :type location: str - :param extended_location: Gets or sets the extended location. - :type extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation - :ivar system_data: The system data. - :vartype system_data: ~azure.mgmt.connectedvmware.models.SystemData - :param tags: A set of tags. Gets or sets the Resource tags. - :type tags: dict[str, str] - :ivar name: Gets or sets the name. - :vartype name: str - :ivar id: Gets or sets the Id. - :vartype id: str - :ivar type: Gets or sets the type of the resource. - :vartype type: str - :param kind: Metadata used by portal/tooling/etc to render different UX experiences for - resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, - the resource provider must validate and persist this value. - :type kind: str - :ivar uuid: Gets or sets a unique identifier for this resource. - :vartype uuid: str - :param v_center_id: Gets or sets the ARM Id of the vCenter resource in which this template - resides. - :type v_center_id: str - :param mo_ref_id: Gets or sets the vCenter MoRef (Managed Object Reference) ID for the virtual - machine - template. - :type mo_ref_id: str - :param inventory_item_id: Gets or sets the inventory Item ID for the virtual machine template. - :type inventory_item_id: str - :ivar mo_name: Gets or sets the vCenter Managed Object name for the virtual machine template. - :vartype mo_name: str - :ivar memory_size_mb: Gets or sets memory size in MBs for the template. - :vartype memory_size_mb: int - :ivar num_cp_us: Gets or sets the number of vCPUs for the template. - :vartype num_cp_us: int - :ivar num_cores_per_socket: Gets or sets the number of cores per socket for the template. - Defaults to 1 if unspecified. - :vartype num_cores_per_socket: int - :ivar os_type: Gets or sets the type of the os. Possible values include: "Windows", "Linux", - "Other". - :vartype os_type: str or ~azure.mgmt.connectedvmware.models.OsType - :ivar os_name: Gets or sets os name. - :vartype os_name: str - :ivar folder_path: Gets or sets the folder path of the template. - :vartype folder_path: str - :ivar network_interfaces: Gets or sets the network interfaces of the template. - :vartype network_interfaces: list[~azure.mgmt.connectedvmware.models.NetworkInterface] - :ivar disks: Gets or sets the disks the template. - :vartype disks: list[~azure.mgmt.connectedvmware.models.VirtualDisk] - :ivar custom_resource_name: Gets the name of the corresponding resource in Kubernetes. - :vartype custom_resource_name: str - :ivar tools_version_status: Gets or sets the current version status of VMware Tools installed - in the guest operating system. - :vartype tools_version_status: str - :ivar tools_version: Gets or sets the current version of VMware Tools. - :vartype tools_version: str - :ivar firmware_type: Firmware type. Possible values include: "bios", "efi". - :vartype firmware_type: str or ~azure.mgmt.connectedvmware.models.FirmwareType - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.connectedvmware.models.ResourceStatus] - :ivar provisioning_state: Gets or sets the provisioning state. - :vartype provisioning_state: str - """ - - _validation = { - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'name': {'readonly': True}, - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'uuid': {'readonly': True}, - 'mo_name': {'readonly': True}, - 'memory_size_mb': {'readonly': True}, - 'num_cp_us': {'readonly': True}, - 'num_cores_per_socket': {'readonly': True}, - 'os_type': {'readonly': True}, - 'os_name': {'readonly': True}, - 'folder_path': {'readonly': True}, - 'network_interfaces': {'readonly': True}, - 'disks': {'readonly': True}, - 'custom_resource_name': {'readonly': True}, - 'tools_version_status': {'readonly': True}, - 'tools_version': {'readonly': True}, - 'firmware_type': {'readonly': True}, - 'statuses': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'name': {'key': 'name', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'uuid': {'key': 'properties.uuid', 'type': 'str'}, - 'v_center_id': {'key': 'properties.vCenterId', 'type': 'str'}, - 'mo_ref_id': {'key': 'properties.moRefId', 'type': 'str'}, - 'inventory_item_id': {'key': 'properties.inventoryItemId', 'type': 'str'}, - 'mo_name': {'key': 'properties.moName', 'type': 'str'}, - 'memory_size_mb': {'key': 'properties.memorySizeMB', 'type': 'int'}, - 'num_cp_us': {'key': 'properties.numCPUs', 'type': 'int'}, - 'num_cores_per_socket': {'key': 'properties.numCoresPerSocket', 'type': 'int'}, - 'os_type': {'key': 'properties.osType', 'type': 'str'}, - 'os_name': {'key': 'properties.osName', 'type': 'str'}, - 'folder_path': {'key': 'properties.folderPath', 'type': 'str'}, - 'network_interfaces': {'key': 'properties.networkInterfaces', 'type': '[NetworkInterface]'}, - 'disks': {'key': 'properties.disks', 'type': '[VirtualDisk]'}, - 'custom_resource_name': {'key': 'properties.customResourceName', 'type': 'str'}, - 'tools_version_status': {'key': 'properties.toolsVersionStatus', 'type': 'str'}, - 'tools_version': {'key': 'properties.toolsVersion', 'type': 'str'}, - 'firmware_type': {'key': 'properties.firmwareType', 'type': 'str'}, - 'statuses': {'key': 'properties.statuses', 'type': '[ResourceStatus]'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(VirtualMachineTemplate, self).__init__(**kwargs) - self.location = kwargs['location'] - self.extended_location = kwargs.get('extended_location', None) - self.system_data = None - self.tags = kwargs.get('tags', None) - self.name = None - self.id = None - self.type = None - self.kind = kwargs.get('kind', None) - self.uuid = None - self.v_center_id = kwargs.get('v_center_id', None) - self.mo_ref_id = kwargs.get('mo_ref_id', None) - self.inventory_item_id = kwargs.get('inventory_item_id', None) - self.mo_name = None - self.memory_size_mb = None - self.num_cp_us = None - self.num_cores_per_socket = None - self.os_type = None - self.os_name = None - self.folder_path = None - self.network_interfaces = None - self.disks = None - self.custom_resource_name = None - self.tools_version_status = None - self.tools_version = None - self.firmware_type = None - self.statuses = None - self.provisioning_state = None - - -class VirtualMachineTemplateInventoryItem(InventoryItemProperties): - """The VM Template inventory item. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param inventory_type: Required. They inventory type.Constant filled by server. Possible - values include: "ResourcePool", "VirtualMachine", "VirtualMachineTemplate", "VirtualNetwork", - "Cluster", "Datastore", "Host". - :type inventory_type: str or ~azure.mgmt.connectedvmware.models.InventoryType - :param managed_resource_id: Gets or sets the tracked resource id corresponding to the inventory - resource. - :type managed_resource_id: str - :param mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory item. - :type mo_ref_id: str - :param mo_name: Gets or sets the vCenter Managed Object name for the inventory item. - :type mo_name: str - :ivar provisioning_state: Gets or sets the provisioning state. - :vartype provisioning_state: str - :param memory_size_mb: Gets or sets memory size in MBs for the template. - :type memory_size_mb: int - :param num_cp_us: Gets or sets the number of vCPUs for the template. - :type num_cp_us: int - :param num_cores_per_socket: Gets or sets the number of cores per socket for the template. - Defaults to 1 if unspecified. - :type num_cores_per_socket: int - :param os_type: Gets or sets the type of the os. Possible values include: "Windows", "Linux", - "Other". - :type os_type: str or ~azure.mgmt.connectedvmware.models.OsType - :param os_name: Gets or sets os name. - :type os_name: str - :param folder_path: Gets or sets the folder path of the template. - :type folder_path: str - """ - - _validation = { - 'inventory_type': {'required': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'inventory_type': {'key': 'inventoryType', 'type': 'str'}, - 'managed_resource_id': {'key': 'managedResourceId', 'type': 'str'}, - 'mo_ref_id': {'key': 'moRefId', 'type': 'str'}, - 'mo_name': {'key': 'moName', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'memory_size_mb': {'key': 'memorySizeMB', 'type': 'int'}, - 'num_cp_us': {'key': 'numCPUs', 'type': 'int'}, - 'num_cores_per_socket': {'key': 'numCoresPerSocket', 'type': 'int'}, - 'os_type': {'key': 'osType', 'type': 'str'}, - 'os_name': {'key': 'osName', 'type': 'str'}, - 'folder_path': {'key': 'folderPath', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(VirtualMachineTemplateInventoryItem, self).__init__(**kwargs) - self.inventory_type = 'VirtualMachineTemplate' # type: str - self.memory_size_mb = kwargs.get('memory_size_mb', None) - self.num_cp_us = kwargs.get('num_cp_us', None) - self.num_cores_per_socket = kwargs.get('num_cores_per_socket', None) - self.os_type = kwargs.get('os_type', None) - self.os_name = kwargs.get('os_name', None) - self.folder_path = kwargs.get('folder_path', None) - - -class VirtualMachineTemplatesList(msrest.serialization.Model): - """List of VirtualMachineTemplates. - - All required parameters must be populated in order to send to Azure. - - :param next_link: Url to follow for getting next page of VirtualMachineTemplates. - :type next_link: str - :param value: Required. Array of VirtualMachineTemplates. - :type value: list[~azure.mgmt.connectedvmware.models.VirtualMachineTemplate] - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[VirtualMachineTemplate]'}, - } - - def __init__( - self, - **kwargs - ): - super(VirtualMachineTemplatesList, self).__init__(**kwargs) - self.next_link = kwargs.get('next_link', None) - self.value = kwargs['value'] - - -class VirtualMachineUpdate(msrest.serialization.Model): - """Defines the virtualMachineUpdate. - - :param tags: A set of tags. Gets or sets the Resource tags. - :type tags: dict[str, str] - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.connectedvmware.models.Identity - :param hardware_profile: Defines the resource properties. - :type hardware_profile: ~azure.mgmt.connectedvmware.models.HardwareProfile - :param storage_profile: Defines the resource update properties. - :type storage_profile: ~azure.mgmt.connectedvmware.models.StorageProfileUpdate - :param network_profile: Defines the update resource properties. - :type network_profile: ~azure.mgmt.connectedvmware.models.NetworkProfileUpdate - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'hardware_profile': {'key': 'properties.hardwareProfile', 'type': 'HardwareProfile'}, - 'storage_profile': {'key': 'properties.storageProfile', 'type': 'StorageProfileUpdate'}, - 'network_profile': {'key': 'properties.networkProfile', 'type': 'NetworkProfileUpdate'}, - } - - def __init__( - self, - **kwargs - ): - super(VirtualMachineUpdate, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.identity = kwargs.get('identity', None) - self.hardware_profile = kwargs.get('hardware_profile', None) - self.storage_profile = kwargs.get('storage_profile', None) - self.network_profile = kwargs.get('network_profile', None) - - -class VirtualNetwork(msrest.serialization.Model): - """Define the virtualNetwork. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param location: Required. Gets or sets the location. - :type location: str - :param extended_location: Gets or sets the extended location. - :type extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation - :ivar system_data: The system data. - :vartype system_data: ~azure.mgmt.connectedvmware.models.SystemData - :param tags: A set of tags. Gets or sets the Resource tags. - :type tags: dict[str, str] - :ivar name: Gets or sets the name. - :vartype name: str - :ivar id: Gets or sets the Id. - :vartype id: str - :ivar type: Gets or sets the type of the resource. - :vartype type: str - :param kind: Metadata used by portal/tooling/etc to render different UX experiences for - resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, - the resource provider must validate and persist this value. - :type kind: str - :ivar uuid: Gets or sets a unique identifier for this resource. - :vartype uuid: str - :param v_center_id: Gets or sets the ARM Id of the vCenter resource in which this template - resides. - :type v_center_id: str - :param mo_ref_id: Gets or sets the vCenter MoRef (Managed Object Reference) ID for the virtual - network. - :type mo_ref_id: str - :param inventory_item_id: Gets or sets the inventory Item ID for the virtual network. - :type inventory_item_id: str - :ivar mo_name: Gets or sets the vCenter Managed Object name for the virtual network. - :vartype mo_name: str - :ivar custom_resource_name: Gets the name of the corresponding resource in Kubernetes. - :vartype custom_resource_name: str - :ivar statuses: The resource status information. - :vartype statuses: list[~azure.mgmt.connectedvmware.models.ResourceStatus] - :ivar provisioning_state: Gets or sets the provisioning state. - :vartype provisioning_state: str - """ - - _validation = { - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'name': {'readonly': True}, - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'uuid': {'readonly': True}, - 'mo_name': {'readonly': True}, - 'custom_resource_name': {'readonly': True}, - 'statuses': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'name': {'key': 'name', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'uuid': {'key': 'properties.uuid', 'type': 'str'}, - 'v_center_id': {'key': 'properties.vCenterId', 'type': 'str'}, - 'mo_ref_id': {'key': 'properties.moRefId', 'type': 'str'}, - 'inventory_item_id': {'key': 'properties.inventoryItemId', 'type': 'str'}, - 'mo_name': {'key': 'properties.moName', 'type': 'str'}, - 'custom_resource_name': {'key': 'properties.customResourceName', 'type': 'str'}, - 'statuses': {'key': 'properties.statuses', 'type': '[ResourceStatus]'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(VirtualNetwork, self).__init__(**kwargs) - self.location = kwargs['location'] - self.extended_location = kwargs.get('extended_location', None) - self.system_data = None - self.tags = kwargs.get('tags', None) - self.name = None - self.id = None - self.type = None - self.kind = kwargs.get('kind', None) - self.uuid = None - self.v_center_id = kwargs.get('v_center_id', None) - self.mo_ref_id = kwargs.get('mo_ref_id', None) - self.inventory_item_id = kwargs.get('inventory_item_id', None) - self.mo_name = None - self.custom_resource_name = None - self.statuses = None - self.provisioning_state = None - - -class VirtualNetworkInventoryItem(InventoryItemProperties): - """The Virtual network inventory item. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param inventory_type: Required. They inventory type.Constant filled by server. Possible - values include: "ResourcePool", "VirtualMachine", "VirtualMachineTemplate", "VirtualNetwork", - "Cluster", "Datastore", "Host". - :type inventory_type: str or ~azure.mgmt.connectedvmware.models.InventoryType - :param managed_resource_id: Gets or sets the tracked resource id corresponding to the inventory - resource. - :type managed_resource_id: str - :param mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory item. - :type mo_ref_id: str - :param mo_name: Gets or sets the vCenter Managed Object name for the inventory item. - :type mo_name: str - :ivar provisioning_state: Gets or sets the provisioning state. - :vartype provisioning_state: str - """ - - _validation = { - 'inventory_type': {'required': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'inventory_type': {'key': 'inventoryType', 'type': 'str'}, - 'managed_resource_id': {'key': 'managedResourceId', 'type': 'str'}, - 'mo_ref_id': {'key': 'moRefId', 'type': 'str'}, - 'mo_name': {'key': 'moName', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(VirtualNetworkInventoryItem, self).__init__(**kwargs) - self.inventory_type = 'VirtualNetwork' # type: str - - -class VirtualNetworksList(msrest.serialization.Model): - """List of VirtualNetworks. - - All required parameters must be populated in order to send to Azure. - - :param next_link: Url to follow for getting next page of VirtualNetworks. - :type next_link: str - :param value: Required. Array of VirtualNetworks. - :type value: list[~azure.mgmt.connectedvmware.models.VirtualNetwork] - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[VirtualNetwork]'}, - } - - def __init__( - self, - **kwargs - ): - super(VirtualNetworksList, self).__init__(**kwargs) - self.next_link = kwargs.get('next_link', None) - self.value = kwargs['value'] - - -class VirtualSCSIController(msrest.serialization.Model): - """This data object type contains the properties of a SCSI controller device attached to a virtual machine that is reported by the controller. - - :param type: Gets or sets the controller type. Possible values include: "lsilogic", "buslogic", - "pvscsi", "lsilogicsas". - :type type: str or ~azure.mgmt.connectedvmware.models.SCSIControllerType - :param controller_key: Gets or sets the key of the controller. - :type controller_key: int - :param bus_number: Gets or sets the bus number of the controller. - :type bus_number: int - :param scsi_ctlr_unit_number: Gets or sets the SCSI controller unit number. - :type scsi_ctlr_unit_number: int - :param sharing: Gets or sets the sharing mode. Possible values include: "noSharing", - "physicalSharing", "virtualSharing". - :type sharing: str or ~azure.mgmt.connectedvmware.models.VirtualSCSISharing - """ - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'controller_key': {'key': 'controllerKey', 'type': 'int'}, - 'bus_number': {'key': 'busNumber', 'type': 'int'}, - 'scsi_ctlr_unit_number': {'key': 'scsiCtlrUnitNumber', 'type': 'int'}, - 'sharing': {'key': 'sharing', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(VirtualSCSIController, self).__init__(**kwargs) - self.type = kwargs.get('type', None) - self.controller_key = kwargs.get('controller_key', None) - self.bus_number = kwargs.get('bus_number', None) - self.scsi_ctlr_unit_number = kwargs.get('scsi_ctlr_unit_number', None) - self.sharing = kwargs.get('sharing', None) diff --git a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/models/_models_py3.py b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/models/_models_py3.py index b89102973d60..3e9a1e398f69 100644 --- a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/models/_models_py3.py +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/models/_models_py3.py @@ -22,33 +22,33 @@ class Cluster(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: Required. Gets or sets the location. - :type location: str - :param extended_location: Gets or sets the extended location. - :type extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation + :ivar location: Required. Gets or sets the location. + :vartype location: str + :ivar extended_location: Gets or sets the extended location. + :vartype extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation :ivar system_data: The system data. :vartype system_data: ~azure.mgmt.connectedvmware.models.SystemData - :param tags: A set of tags. Gets or sets the Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Gets or sets the Resource tags. + :vartype tags: dict[str, str] :ivar name: Gets or sets the name. :vartype name: str :ivar id: Gets or sets the Id. :vartype id: str :ivar type: Gets or sets the type of the resource. :vartype type: str - :param kind: Metadata used by portal/tooling/etc to render different UX experiences for + :ivar kind: Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, the resource provider must validate and persist this value. - :type kind: str + :vartype kind: str :ivar uuid: Gets or sets a unique identifier for this resource. :vartype uuid: str - :param v_center_id: Gets or sets the ARM Id of the vCenter resource in which this cluster + :ivar v_center_id: Gets or sets the ARM Id of the vCenter resource in which this cluster resides. - :type v_center_id: str - :param mo_ref_id: Gets or sets the vCenter MoRef (Managed Object Reference) ID for the cluster. - :type mo_ref_id: str - :param inventory_item_id: Gets or sets the inventory Item ID for the cluster. - :type inventory_item_id: str + :vartype v_center_id: str + :ivar mo_ref_id: Gets or sets the vCenter MoRef (Managed Object Reference) ID for the cluster. + :vartype mo_ref_id: str + :ivar inventory_item_id: Gets or sets the inventory Item ID for the cluster. + :vartype inventory_item_id: str :ivar mo_name: Gets or sets the vCenter Managed Object name for the cluster. :vartype mo_name: str :ivar statuses: The resource status information. @@ -111,6 +111,26 @@ def __init__( inventory_item_id: Optional[str] = None, **kwargs ): + """ + :keyword location: Required. Gets or sets the location. + :paramtype location: str + :keyword extended_location: Gets or sets the extended location. + :paramtype extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation + :keyword tags: A set of tags. Gets or sets the Resource tags. + :paramtype tags: dict[str, str] + :keyword kind: Metadata used by portal/tooling/etc to render different UX experiences for + resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, + the resource provider must validate and persist this value. + :paramtype kind: str + :keyword v_center_id: Gets or sets the ARM Id of the vCenter resource in which this cluster + resides. + :paramtype v_center_id: str + :keyword mo_ref_id: Gets or sets the vCenter MoRef (Managed Object Reference) ID for the + cluster. + :paramtype mo_ref_id: str + :keyword inventory_item_id: Gets or sets the inventory Item ID for the cluster. + :paramtype inventory_item_id: str + """ super(Cluster, self).__init__(**kwargs) self.location = location self.extended_location = extended_location @@ -142,17 +162,17 @@ class InventoryItemProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param inventory_type: Required. They inventory type.Constant filled by server. Possible - values include: "ResourcePool", "VirtualMachine", "VirtualMachineTemplate", "VirtualNetwork", + :ivar inventory_type: Required. They inventory type.Constant filled by server. Possible values + include: "ResourcePool", "VirtualMachine", "VirtualMachineTemplate", "VirtualNetwork", "Cluster", "Datastore", "Host". - :type inventory_type: str or ~azure.mgmt.connectedvmware.models.InventoryType - :param managed_resource_id: Gets or sets the tracked resource id corresponding to the inventory + :vartype inventory_type: str or ~azure.mgmt.connectedvmware.models.InventoryType + :ivar managed_resource_id: Gets or sets the tracked resource id corresponding to the inventory resource. - :type managed_resource_id: str - :param mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory item. - :type mo_ref_id: str - :param mo_name: Gets or sets the vCenter Managed Object name for the inventory item. - :type mo_name: str + :vartype managed_resource_id: str + :ivar mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory item. + :vartype mo_ref_id: str + :ivar mo_name: Gets or sets the vCenter Managed Object name for the inventory item. + :vartype mo_name: str :ivar provisioning_state: Gets or sets the provisioning state. :vartype provisioning_state: str """ @@ -182,6 +202,16 @@ def __init__( mo_name: Optional[str] = None, **kwargs ): + """ + :keyword managed_resource_id: Gets or sets the tracked resource id corresponding to the + inventory resource. + :paramtype managed_resource_id: str + :keyword mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory + item. + :paramtype mo_ref_id: str + :keyword mo_name: Gets or sets the vCenter Managed Object name for the inventory item. + :paramtype mo_name: str + """ super(InventoryItemProperties, self).__init__(**kwargs) self.inventory_type = None # type: Optional[str] self.managed_resource_id = managed_resource_id @@ -197,17 +227,17 @@ class ClusterInventoryItem(InventoryItemProperties): All required parameters must be populated in order to send to Azure. - :param inventory_type: Required. They inventory type.Constant filled by server. Possible - values include: "ResourcePool", "VirtualMachine", "VirtualMachineTemplate", "VirtualNetwork", + :ivar inventory_type: Required. They inventory type.Constant filled by server. Possible values + include: "ResourcePool", "VirtualMachine", "VirtualMachineTemplate", "VirtualNetwork", "Cluster", "Datastore", "Host". - :type inventory_type: str or ~azure.mgmt.connectedvmware.models.InventoryType - :param managed_resource_id: Gets or sets the tracked resource id corresponding to the inventory + :vartype inventory_type: str or ~azure.mgmt.connectedvmware.models.InventoryType + :ivar managed_resource_id: Gets or sets the tracked resource id corresponding to the inventory resource. - :type managed_resource_id: str - :param mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory item. - :type mo_ref_id: str - :param mo_name: Gets or sets the vCenter Managed Object name for the inventory item. - :type mo_name: str + :vartype managed_resource_id: str + :ivar mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory item. + :vartype mo_ref_id: str + :ivar mo_name: Gets or sets the vCenter Managed Object name for the inventory item. + :vartype mo_name: str :ivar provisioning_state: Gets or sets the provisioning state. :vartype provisioning_state: str """ @@ -233,6 +263,16 @@ def __init__( mo_name: Optional[str] = None, **kwargs ): + """ + :keyword managed_resource_id: Gets or sets the tracked resource id corresponding to the + inventory resource. + :paramtype managed_resource_id: str + :keyword mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory + item. + :paramtype mo_ref_id: str + :keyword mo_name: Gets or sets the vCenter Managed Object name for the inventory item. + :paramtype mo_name: str + """ super(ClusterInventoryItem, self).__init__(managed_resource_id=managed_resource_id, mo_ref_id=mo_ref_id, mo_name=mo_name, **kwargs) self.inventory_type = 'Cluster' # type: str @@ -242,10 +282,10 @@ class ClustersList(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param next_link: Url to follow for getting next page of Clusters. - :type next_link: str - :param value: Required. Array of Clusters. - :type value: list[~azure.mgmt.connectedvmware.models.Cluster] + :ivar next_link: Url to follow for getting next page of Clusters. + :vartype next_link: str + :ivar value: Required. Array of Clusters. + :vartype value: list[~azure.mgmt.connectedvmware.models.Cluster] """ _validation = { @@ -264,6 +304,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword next_link: Url to follow for getting next page of Clusters. + :paramtype next_link: str + :keyword value: Required. Array of Clusters. + :paramtype value: list[~azure.mgmt.connectedvmware.models.Cluster] + """ super(ClustersList, self).__init__(**kwargs) self.next_link = next_link self.value = value @@ -302,6 +348,8 @@ def __init__( self, **kwargs ): + """ + """ super(Condition, self).__init__(**kwargs) self.status = None self.reason = None @@ -316,34 +364,34 @@ class Datastore(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: Required. Gets or sets the location. - :type location: str - :param extended_location: Gets or sets the extended location. - :type extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation + :ivar location: Required. Gets or sets the location. + :vartype location: str + :ivar extended_location: Gets or sets the extended location. + :vartype extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation :ivar system_data: The system data. :vartype system_data: ~azure.mgmt.connectedvmware.models.SystemData - :param tags: A set of tags. Gets or sets the Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Gets or sets the Resource tags. + :vartype tags: dict[str, str] :ivar name: Gets or sets the name. :vartype name: str :ivar id: Gets or sets the Id. :vartype id: str :ivar type: Gets or sets the type of the resource. :vartype type: str - :param kind: Metadata used by portal/tooling/etc to render different UX experiences for + :ivar kind: Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, the resource provider must validate and persist this value. - :type kind: str + :vartype kind: str :ivar uuid: Gets or sets a unique identifier for this resource. :vartype uuid: str - :param v_center_id: Gets or sets the ARM Id of the vCenter resource in which this datastore + :ivar v_center_id: Gets or sets the ARM Id of the vCenter resource in which this datastore resides. - :type v_center_id: str - :param mo_ref_id: Gets or sets the vCenter MoRef (Managed Object Reference) ID for the + :vartype v_center_id: str + :ivar mo_ref_id: Gets or sets the vCenter MoRef (Managed Object Reference) ID for the datastore. - :type mo_ref_id: str - :param inventory_item_id: Gets or sets the inventory Item ID for the datastore. - :type inventory_item_id: str + :vartype mo_ref_id: str + :ivar inventory_item_id: Gets or sets the inventory Item ID for the datastore. + :vartype inventory_item_id: str :ivar mo_name: Gets or sets the vCenter Managed Object name for the datastore. :vartype mo_name: str :ivar statuses: The resource status information. @@ -400,6 +448,26 @@ def __init__( inventory_item_id: Optional[str] = None, **kwargs ): + """ + :keyword location: Required. Gets or sets the location. + :paramtype location: str + :keyword extended_location: Gets or sets the extended location. + :paramtype extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation + :keyword tags: A set of tags. Gets or sets the Resource tags. + :paramtype tags: dict[str, str] + :keyword kind: Metadata used by portal/tooling/etc to render different UX experiences for + resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, + the resource provider must validate and persist this value. + :paramtype kind: str + :keyword v_center_id: Gets or sets the ARM Id of the vCenter resource in which this datastore + resides. + :paramtype v_center_id: str + :keyword mo_ref_id: Gets or sets the vCenter MoRef (Managed Object Reference) ID for the + datastore. + :paramtype mo_ref_id: str + :keyword inventory_item_id: Gets or sets the inventory Item ID for the datastore. + :paramtype inventory_item_id: str + """ super(Datastore, self).__init__(**kwargs) self.location = location self.extended_location = extended_location @@ -426,23 +494,23 @@ class DatastoreInventoryItem(InventoryItemProperties): All required parameters must be populated in order to send to Azure. - :param inventory_type: Required. They inventory type.Constant filled by server. Possible - values include: "ResourcePool", "VirtualMachine", "VirtualMachineTemplate", "VirtualNetwork", + :ivar inventory_type: Required. They inventory type.Constant filled by server. Possible values + include: "ResourcePool", "VirtualMachine", "VirtualMachineTemplate", "VirtualNetwork", "Cluster", "Datastore", "Host". - :type inventory_type: str or ~azure.mgmt.connectedvmware.models.InventoryType - :param managed_resource_id: Gets or sets the tracked resource id corresponding to the inventory + :vartype inventory_type: str or ~azure.mgmt.connectedvmware.models.InventoryType + :ivar managed_resource_id: Gets or sets the tracked resource id corresponding to the inventory resource. - :type managed_resource_id: str - :param mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory item. - :type mo_ref_id: str - :param mo_name: Gets or sets the vCenter Managed Object name for the inventory item. - :type mo_name: str + :vartype managed_resource_id: str + :ivar mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory item. + :vartype mo_ref_id: str + :ivar mo_name: Gets or sets the vCenter Managed Object name for the inventory item. + :vartype mo_name: str :ivar provisioning_state: Gets or sets the provisioning state. :vartype provisioning_state: str - :param capacity_gb: Gets or sets Maximum capacity of this datastore, in GBs. - :type capacity_gb: long - :param free_space_gb: Gets or sets Available space of this datastore, in GBs. - :type free_space_gb: long + :ivar capacity_gb: Gets or sets Maximum capacity of this datastore, in GBs. + :vartype capacity_gb: long + :ivar free_space_gb: Gets or sets Available space of this datastore, in GBs. + :vartype free_space_gb: long """ _validation = { @@ -470,6 +538,20 @@ def __init__( free_space_gb: Optional[int] = None, **kwargs ): + """ + :keyword managed_resource_id: Gets or sets the tracked resource id corresponding to the + inventory resource. + :paramtype managed_resource_id: str + :keyword mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory + item. + :paramtype mo_ref_id: str + :keyword mo_name: Gets or sets the vCenter Managed Object name for the inventory item. + :paramtype mo_name: str + :keyword capacity_gb: Gets or sets Maximum capacity of this datastore, in GBs. + :paramtype capacity_gb: long + :keyword free_space_gb: Gets or sets Available space of this datastore, in GBs. + :paramtype free_space_gb: long + """ super(DatastoreInventoryItem, self).__init__(managed_resource_id=managed_resource_id, mo_ref_id=mo_ref_id, mo_name=mo_name, **kwargs) self.inventory_type = 'Datastore' # type: str self.capacity_gb = capacity_gb @@ -481,10 +563,10 @@ class DatastoresList(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param next_link: Url to follow for getting next page of Datastores. - :type next_link: str - :param value: Required. Array of Datastores. - :type value: list[~azure.mgmt.connectedvmware.models.Datastore] + :ivar next_link: Url to follow for getting next page of Datastores. + :vartype next_link: str + :ivar value: Required. Array of Datastores. + :vartype value: list[~azure.mgmt.connectedvmware.models.Datastore] """ _validation = { @@ -503,6 +585,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword next_link: Url to follow for getting next page of Datastores. + :paramtype next_link: str + :keyword value: Required. Array of Datastores. + :paramtype value: list[~azure.mgmt.connectedvmware.models.Datastore] + """ super(DatastoresList, self).__init__(**kwargs) self.next_link = next_link self.value = value @@ -537,6 +625,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDefinition, self).__init__(**kwargs) self.code = None self.message = None @@ -548,14 +638,14 @@ class ErrorDetail(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param code: Required. The error's code. - :type code: str - :param message: Required. A human readable error message. - :type message: str - :param target: Indicates which property in the request is responsible for the error. - :type target: str - :param details: Additional error details. - :type details: list[~azure.mgmt.connectedvmware.models.ErrorDetail] + :ivar code: Required. The error's code. + :vartype code: str + :ivar message: Required. A human readable error message. + :vartype message: str + :ivar target: Indicates which property in the request is responsible for the error. + :vartype target: str + :ivar details: Additional error details. + :vartype details: list[~azure.mgmt.connectedvmware.models.ErrorDetail] """ _validation = { @@ -579,6 +669,16 @@ def __init__( details: Optional[List["ErrorDetail"]] = None, **kwargs ): + """ + :keyword code: Required. The error's code. + :paramtype code: str + :keyword message: Required. A human readable error message. + :paramtype message: str + :keyword target: Indicates which property in the request is responsible for the error. + :paramtype target: str + :keyword details: Additional error details. + :paramtype details: list[~azure.mgmt.connectedvmware.models.ErrorDetail] + """ super(ErrorDetail, self).__init__(**kwargs) self.code = code self.message = message @@ -589,8 +689,8 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Error response. - :param error: The error details. - :type error: ~azure.mgmt.connectedvmware.models.ErrorDefinition + :ivar error: The error details. + :vartype error: ~azure.mgmt.connectedvmware.models.ErrorDefinition """ _attribute_map = { @@ -603,6 +703,10 @@ def __init__( error: Optional["ErrorDefinition"] = None, **kwargs ): + """ + :keyword error: The error details. + :paramtype error: ~azure.mgmt.connectedvmware.models.ErrorDefinition + """ super(ErrorResponse, self).__init__(**kwargs) self.error = error @@ -610,10 +714,10 @@ def __init__( class ExtendedLocation(msrest.serialization.Model): """The extended location. - :param type: The extended location type. - :type type: str - :param name: The extended location name. - :type name: str + :ivar type: The extended location type. + :vartype type: str + :ivar name: The extended location name. + :vartype name: str """ _attribute_map = { @@ -628,6 +732,12 @@ def __init__( name: Optional[str] = None, **kwargs ): + """ + :keyword type: The extended location type. + :paramtype type: str + :keyword name: The extended location name. + :paramtype name: str + """ super(ExtendedLocation, self).__init__(**kwargs) self.type = type self.name = name @@ -664,6 +774,8 @@ def __init__( self, **kwargs ): + """ + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -701,6 +813,8 @@ def __init__( self, **kwargs ): + """ + """ super(ProxyResource, self).__init__(**kwargs) @@ -721,13 +835,13 @@ class GuestAgent(ProxyResource): :vartype system_data: ~azure.mgmt.connectedvmware.models.SystemData :ivar uuid: Gets or sets a unique identifier for this resource. :vartype uuid: str - :param credentials: Username / Password Credentials to provision guest agent. - :type credentials: ~azure.mgmt.connectedvmware.models.GuestCredential - :param http_proxy_config: HTTP Proxy configuration for the VM. - :type http_proxy_config: ~azure.mgmt.connectedvmware.models.HttpProxyConfiguration - :param provisioning_action: Gets or sets the guest agent provisioning action. Possible values + :ivar credentials: Username / Password Credentials to provision guest agent. + :vartype credentials: ~azure.mgmt.connectedvmware.models.GuestCredential + :ivar http_proxy_config: HTTP Proxy configuration for the VM. + :vartype http_proxy_config: ~azure.mgmt.connectedvmware.models.HttpProxyConfiguration + :ivar provisioning_action: Gets or sets the guest agent provisioning action. Possible values include: "install", "uninstall", "repair". - :type provisioning_action: str or ~azure.mgmt.connectedvmware.models.ProvisioningAction + :vartype provisioning_action: str or ~azure.mgmt.connectedvmware.models.ProvisioningAction :ivar status: Gets or sets the guest agent status. :vartype status: str :ivar custom_resource_name: Gets the name of the corresponding resource in Kubernetes. @@ -773,6 +887,15 @@ def __init__( provisioning_action: Optional[Union[str, "ProvisioningAction"]] = None, **kwargs ): + """ + :keyword credentials: Username / Password Credentials to provision guest agent. + :paramtype credentials: ~azure.mgmt.connectedvmware.models.GuestCredential + :keyword http_proxy_config: HTTP Proxy configuration for the VM. + :paramtype http_proxy_config: ~azure.mgmt.connectedvmware.models.HttpProxyConfiguration + :keyword provisioning_action: Gets or sets the guest agent provisioning action. Possible values + include: "install", "uninstall", "repair". + :paramtype provisioning_action: str or ~azure.mgmt.connectedvmware.models.ProvisioningAction + """ super(GuestAgent, self).__init__(**kwargs) self.system_data = None self.uuid = None @@ -790,10 +913,10 @@ class GuestAgentList(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param next_link: Url to follow for getting next page of GuestAgent. - :type next_link: str - :param value: Required. Array of GuestAgent. - :type value: list[~azure.mgmt.connectedvmware.models.GuestAgent] + :ivar next_link: Url to follow for getting next page of GuestAgent. + :vartype next_link: str + :ivar value: Required. Array of GuestAgent. + :vartype value: list[~azure.mgmt.connectedvmware.models.GuestAgent] """ _validation = { @@ -812,6 +935,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword next_link: Url to follow for getting next page of GuestAgent. + :paramtype next_link: str + :keyword value: Required. Array of GuestAgent. + :paramtype value: list[~azure.mgmt.connectedvmware.models.GuestAgent] + """ super(GuestAgentList, self).__init__(**kwargs) self.next_link = next_link self.value = value @@ -855,6 +984,8 @@ def __init__( self, **kwargs ): + """ + """ super(GuestAgentProfile, self).__init__(**kwargs) self.vm_uuid = None self.status = None @@ -866,10 +997,10 @@ def __init__( class GuestCredential(msrest.serialization.Model): """Username / Password Credentials to connect to guest. - :param username: Gets or sets username to connect with the guest. - :type username: str - :param password: Gets or sets the password to connect with the guest. - :type password: str + :ivar username: Gets or sets username to connect with the guest. + :vartype username: str + :ivar password: Gets or sets the password to connect with the guest. + :vartype password: str """ _attribute_map = { @@ -884,6 +1015,12 @@ def __init__( password: Optional[str] = None, **kwargs ): + """ + :keyword username: Gets or sets username to connect with the guest. + :paramtype username: str + :keyword password: Gets or sets the password to connect with the guest. + :paramtype password: str + """ super(GuestCredential, self).__init__(**kwargs) self.username = username self.password = password @@ -894,13 +1031,13 @@ class HardwareProfile(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param memory_size_mb: Gets or sets memory size in MBs for the vm. - :type memory_size_mb: int - :param num_cp_us: Gets or sets the number of vCPUs for the vm. - :type num_cp_us: int - :param num_cores_per_socket: Gets or sets the number of cores per socket for the vm. Defaults - to 1 if unspecified. - :type num_cores_per_socket: int + :ivar memory_size_mb: Gets or sets memory size in MBs for the vm. + :vartype memory_size_mb: int + :ivar num_cp_us: Gets or sets the number of vCPUs for the vm. + :vartype num_cp_us: int + :ivar num_cores_per_socket: Gets or sets the number of cores per socket for the vm. Defaults to + 1 if unspecified. + :vartype num_cores_per_socket: int :ivar cpu_hot_add_enabled: Gets or sets a value indicating whether virtual processors can be added while this virtual machine is running. :vartype cpu_hot_add_enabled: bool @@ -935,6 +1072,15 @@ def __init__( num_cores_per_socket: Optional[int] = None, **kwargs ): + """ + :keyword memory_size_mb: Gets or sets memory size in MBs for the vm. + :paramtype memory_size_mb: int + :keyword num_cp_us: Gets or sets the number of vCPUs for the vm. + :paramtype num_cp_us: int + :keyword num_cores_per_socket: Gets or sets the number of cores per socket for the vm. Defaults + to 1 if unspecified. + :paramtype num_cores_per_socket: int + """ super(HardwareProfile, self).__init__(**kwargs) self.memory_size_mb = memory_size_mb self.num_cp_us = num_cp_us @@ -951,32 +1097,32 @@ class Host(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: Required. Gets or sets the location. - :type location: str - :param extended_location: Gets or sets the extended location. - :type extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation + :ivar location: Required. Gets or sets the location. + :vartype location: str + :ivar extended_location: Gets or sets the extended location. + :vartype extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation :ivar system_data: The system data. :vartype system_data: ~azure.mgmt.connectedvmware.models.SystemData - :param tags: A set of tags. Gets or sets the Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Gets or sets the Resource tags. + :vartype tags: dict[str, str] :ivar name: Gets or sets the name. :vartype name: str :ivar id: Gets or sets the Id. :vartype id: str :ivar type: Gets or sets the type of the resource. :vartype type: str - :param kind: Metadata used by portal/tooling/etc to render different UX experiences for + :ivar kind: Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, the resource provider must validate and persist this value. - :type kind: str + :vartype kind: str :ivar uuid: Gets or sets a unique identifier for this resource. :vartype uuid: str - :param v_center_id: Gets or sets the ARM Id of the vCenter resource in which this host resides. - :type v_center_id: str - :param mo_ref_id: Gets or sets the vCenter MoRef (Managed Object Reference) ID for the host. - :type mo_ref_id: str - :param inventory_item_id: Gets or sets the inventory Item ID for the host. - :type inventory_item_id: str + :ivar v_center_id: Gets or sets the ARM Id of the vCenter resource in which this host resides. + :vartype v_center_id: str + :ivar mo_ref_id: Gets or sets the vCenter MoRef (Managed Object Reference) ID for the host. + :vartype mo_ref_id: str + :ivar inventory_item_id: Gets or sets the inventory Item ID for the host. + :vartype inventory_item_id: str :ivar mo_name: Gets or sets the vCenter Managed Object name for the host. :vartype mo_name: str :ivar statuses: The resource status information. @@ -1031,6 +1177,25 @@ def __init__( inventory_item_id: Optional[str] = None, **kwargs ): + """ + :keyword location: Required. Gets or sets the location. + :paramtype location: str + :keyword extended_location: Gets or sets the extended location. + :paramtype extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation + :keyword tags: A set of tags. Gets or sets the Resource tags. + :paramtype tags: dict[str, str] + :keyword kind: Metadata used by portal/tooling/etc to render different UX experiences for + resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, + the resource provider must validate and persist this value. + :paramtype kind: str + :keyword v_center_id: Gets or sets the ARM Id of the vCenter resource in which this host + resides. + :paramtype v_center_id: str + :keyword mo_ref_id: Gets or sets the vCenter MoRef (Managed Object Reference) ID for the host. + :paramtype mo_ref_id: str + :keyword inventory_item_id: Gets or sets the inventory Item ID for the host. + :paramtype inventory_item_id: str + """ super(Host, self).__init__(**kwargs) self.location = location self.extended_location = extended_location @@ -1057,21 +1222,21 @@ class HostInventoryItem(InventoryItemProperties): All required parameters must be populated in order to send to Azure. - :param inventory_type: Required. They inventory type.Constant filled by server. Possible - values include: "ResourcePool", "VirtualMachine", "VirtualMachineTemplate", "VirtualNetwork", + :ivar inventory_type: Required. They inventory type.Constant filled by server. Possible values + include: "ResourcePool", "VirtualMachine", "VirtualMachineTemplate", "VirtualNetwork", "Cluster", "Datastore", "Host". - :type inventory_type: str or ~azure.mgmt.connectedvmware.models.InventoryType - :param managed_resource_id: Gets or sets the tracked resource id corresponding to the inventory + :vartype inventory_type: str or ~azure.mgmt.connectedvmware.models.InventoryType + :ivar managed_resource_id: Gets or sets the tracked resource id corresponding to the inventory resource. - :type managed_resource_id: str - :param mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory item. - :type mo_ref_id: str - :param mo_name: Gets or sets the vCenter Managed Object name for the inventory item. - :type mo_name: str + :vartype managed_resource_id: str + :ivar mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory item. + :vartype mo_ref_id: str + :ivar mo_name: Gets or sets the vCenter Managed Object name for the inventory item. + :vartype mo_name: str :ivar provisioning_state: Gets or sets the provisioning state. :vartype provisioning_state: str - :param parent: Parent host inventory resource details. - :type parent: ~azure.mgmt.connectedvmware.models.InventoryItemDetails + :ivar parent: Parent host inventory resource details. + :vartype parent: ~azure.mgmt.connectedvmware.models.InventoryItemDetails """ _validation = { @@ -1097,6 +1262,18 @@ def __init__( parent: Optional["InventoryItemDetails"] = None, **kwargs ): + """ + :keyword managed_resource_id: Gets or sets the tracked resource id corresponding to the + inventory resource. + :paramtype managed_resource_id: str + :keyword mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory + item. + :paramtype mo_ref_id: str + :keyword mo_name: Gets or sets the vCenter Managed Object name for the inventory item. + :paramtype mo_name: str + :keyword parent: Parent host inventory resource details. + :paramtype parent: ~azure.mgmt.connectedvmware.models.InventoryItemDetails + """ super(HostInventoryItem, self).__init__(managed_resource_id=managed_resource_id, mo_ref_id=mo_ref_id, mo_name=mo_name, **kwargs) self.inventory_type = 'Host' # type: str self.parent = parent @@ -1107,10 +1284,10 @@ class HostsList(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param next_link: Url to follow for getting next page of Hosts. - :type next_link: str - :param value: Required. Array of Hosts. - :type value: list[~azure.mgmt.connectedvmware.models.Host] + :ivar next_link: Url to follow for getting next page of Hosts. + :vartype next_link: str + :ivar value: Required. Array of Hosts. + :vartype value: list[~azure.mgmt.connectedvmware.models.Host] """ _validation = { @@ -1129,6 +1306,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword next_link: Url to follow for getting next page of Hosts. + :paramtype next_link: str + :keyword value: Required. Array of Hosts. + :paramtype value: list[~azure.mgmt.connectedvmware.models.Host] + """ super(HostsList, self).__init__(**kwargs) self.next_link = next_link self.value = value @@ -1137,8 +1320,8 @@ def __init__( class HttpProxyConfiguration(msrest.serialization.Model): """HTTP Proxy configuration for the VM. - :param https_proxy: Gets or sets httpsProxy url. - :type https_proxy: str + :ivar https_proxy: Gets or sets httpsProxy url. + :vartype https_proxy: str """ _attribute_map = { @@ -1151,6 +1334,10 @@ def __init__( https_proxy: Optional[str] = None, **kwargs ): + """ + :keyword https_proxy: Gets or sets httpsProxy url. + :paramtype https_proxy: str + """ super(HttpProxyConfiguration, self).__init__(**kwargs) self.https_proxy = https_proxy @@ -1170,10 +1357,10 @@ class HybridIdentityMetadata(ProxyResource): :vartype type: str :ivar system_data: The system data. :vartype system_data: ~azure.mgmt.connectedvmware.models.SystemData - :param vm_id: Gets or sets the Vm Id. - :type vm_id: str - :param public_key: Gets or sets the Public Key. - :type public_key: str + :ivar vm_id: Gets or sets the Vm Id. + :vartype vm_id: str + :ivar public_key: Gets or sets the Public Key. + :vartype public_key: str :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.connectedvmware.models.Identity :ivar provisioning_state: Gets or sets the provisioning state. @@ -1207,6 +1394,12 @@ def __init__( public_key: Optional[str] = None, **kwargs ): + """ + :keyword vm_id: Gets or sets the Vm Id. + :paramtype vm_id: str + :keyword public_key: Gets or sets the Public Key. + :paramtype public_key: str + """ super(HybridIdentityMetadata, self).__init__(**kwargs) self.system_data = None self.vm_id = vm_id @@ -1220,10 +1413,10 @@ class HybridIdentityMetadataList(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param next_link: Url to follow for getting next page of HybridIdentityMetadata. - :type next_link: str - :param value: Required. Array of HybridIdentityMetadata. - :type value: list[~azure.mgmt.connectedvmware.models.HybridIdentityMetadata] + :ivar next_link: Url to follow for getting next page of HybridIdentityMetadata. + :vartype next_link: str + :ivar value: Required. Array of HybridIdentityMetadata. + :vartype value: list[~azure.mgmt.connectedvmware.models.HybridIdentityMetadata] """ _validation = { @@ -1242,6 +1435,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword next_link: Url to follow for getting next page of HybridIdentityMetadata. + :paramtype next_link: str + :keyword value: Required. Array of HybridIdentityMetadata. + :paramtype value: list[~azure.mgmt.connectedvmware.models.HybridIdentityMetadata] + """ super(HybridIdentityMetadataList, self).__init__(**kwargs) self.next_link = next_link self.value = value @@ -1258,9 +1457,9 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant of managed service identity. :vartype tenant_id: str - :param type: Required. The type of managed service identity. Possible values include: "None", + :ivar type: Required. The type of managed service identity. Possible values include: "None", "SystemAssigned". - :type type: str or ~azure.mgmt.connectedvmware.models.IdentityType + :vartype type: str or ~azure.mgmt.connectedvmware.models.IdentityType """ _validation = { @@ -1281,6 +1480,11 @@ def __init__( type: Union[str, "IdentityType"], **kwargs ): + """ + :keyword type: Required. The type of managed service identity. Possible values include: "None", + "SystemAssigned". + :paramtype type: str or ~azure.mgmt.connectedvmware.models.IdentityType + """ super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -1304,21 +1508,21 @@ class InventoryItem(ProxyResource): :vartype type: str :ivar system_data: The system data. :vartype system_data: ~azure.mgmt.connectedvmware.models.SystemData - :param kind: Metadata used by portal/tooling/etc to render different UX experiences for + :ivar kind: Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, the resource provider must validate and persist this value. - :type kind: str - :param inventory_type: Required. They inventory type.Constant filled by server. Possible - values include: "ResourcePool", "VirtualMachine", "VirtualMachineTemplate", "VirtualNetwork", + :vartype kind: str + :ivar inventory_type: Required. They inventory type.Constant filled by server. Possible values + include: "ResourcePool", "VirtualMachine", "VirtualMachineTemplate", "VirtualNetwork", "Cluster", "Datastore", "Host". - :type inventory_type: str or ~azure.mgmt.connectedvmware.models.InventoryType - :param managed_resource_id: Gets or sets the tracked resource id corresponding to the inventory + :vartype inventory_type: str or ~azure.mgmt.connectedvmware.models.InventoryType + :ivar managed_resource_id: Gets or sets the tracked resource id corresponding to the inventory resource. - :type managed_resource_id: str - :param mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory item. - :type mo_ref_id: str - :param mo_name: Gets or sets the vCenter Managed Object name for the inventory item. - :type mo_name: str + :vartype managed_resource_id: str + :ivar mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory item. + :vartype mo_ref_id: str + :ivar mo_name: Gets or sets the vCenter Managed Object name for the inventory item. + :vartype mo_name: str :ivar provisioning_state: Gets or sets the provisioning state. :vartype provisioning_state: str """ @@ -1354,6 +1558,20 @@ def __init__( mo_name: Optional[str] = None, **kwargs ): + """ + :keyword kind: Metadata used by portal/tooling/etc to render different UX experiences for + resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, + the resource provider must validate and persist this value. + :paramtype kind: str + :keyword managed_resource_id: Gets or sets the tracked resource id corresponding to the + inventory resource. + :paramtype managed_resource_id: str + :keyword mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory + item. + :paramtype mo_ref_id: str + :keyword mo_name: Gets or sets the vCenter Managed Object name for the inventory item. + :paramtype mo_name: str + """ super(InventoryItem, self).__init__(**kwargs) self.system_data = None self.kind = kind @@ -1367,10 +1585,10 @@ def __init__( class InventoryItemDetails(msrest.serialization.Model): """Defines the resource properties. - :param inventory_item_id: Gets or sets the inventory Item ID for the resource. - :type inventory_item_id: str - :param mo_name: Gets or sets the vCenter Managed Object name for the resource. - :type mo_name: str + :ivar inventory_item_id: Gets or sets the inventory Item ID for the resource. + :vartype inventory_item_id: str + :ivar mo_name: Gets or sets the vCenter Managed Object name for the resource. + :vartype mo_name: str """ _attribute_map = { @@ -1385,6 +1603,12 @@ def __init__( mo_name: Optional[str] = None, **kwargs ): + """ + :keyword inventory_item_id: Gets or sets the inventory Item ID for the resource. + :paramtype inventory_item_id: str + :keyword mo_name: Gets or sets the vCenter Managed Object name for the resource. + :paramtype mo_name: str + """ super(InventoryItemDetails, self).__init__(**kwargs) self.inventory_item_id = inventory_item_id self.mo_name = mo_name @@ -1395,10 +1619,10 @@ class InventoryItemsList(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param next_link: Url to follow for getting next page of InventoryItems. - :type next_link: str - :param value: Required. Array of InventoryItems. - :type value: list[~azure.mgmt.connectedvmware.models.InventoryItem] + :ivar next_link: Url to follow for getting next page of InventoryItems. + :vartype next_link: str + :ivar value: Required. Array of InventoryItems. + :vartype value: list[~azure.mgmt.connectedvmware.models.InventoryItem] """ _validation = { @@ -1417,6 +1641,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword next_link: Url to follow for getting next page of InventoryItems. + :paramtype next_link: str + :keyword value: Required. Array of InventoryItems. + :paramtype value: list[~azure.mgmt.connectedvmware.models.InventoryItem] + """ super(InventoryItemsList, self).__init__(**kwargs) self.next_link = next_link self.value = value @@ -1427,41 +1657,42 @@ class MachineExtension(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param location: Gets or sets the location. - :type location: str + :ivar location: Gets or sets the location. + :vartype location: str :ivar system_data: The system data. :vartype system_data: ~azure.mgmt.connectedvmware.models.SystemData - :param tags: A set of tags. Gets or sets the Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Gets or sets the Resource tags. + :vartype tags: dict[str, str] :ivar name: Gets or sets the name. :vartype name: str :ivar id: Gets or sets the Id. :vartype id: str :ivar type: Gets or sets the type of the resource. :vartype type: str - :param force_update_tag: How the extension handler should be forced to update even if the + :ivar force_update_tag: How the extension handler should be forced to update even if the extension configuration has not changed. - :type force_update_tag: str - :param publisher: The name of the extension handler publisher. - :type publisher: str - :param type_properties_type: Specifies the type of the extension; an example is + :vartype force_update_tag: str + :ivar publisher: The name of the extension handler publisher. + :vartype publisher: str + :ivar type_properties_type: Specifies the type of the extension; an example is "CustomScriptExtension". - :type type_properties_type: str - :param type_handler_version: Specifies the version of the script handler. - :type type_handler_version: str - :param auto_upgrade_minor_version: Indicates whether the extension should use a newer minor + :vartype type_properties_type: str + :ivar type_handler_version: Specifies the version of the script handler. + :vartype type_handler_version: str + :ivar auto_upgrade_minor_version: Indicates whether the extension should use a newer minor version if one is available at deployment time. Once deployed, however, the extension will not upgrade minor versions unless redeployed, even with this property set to true. - :type auto_upgrade_minor_version: bool - :param settings: Json formatted public settings for the extension. - :type settings: any - :param protected_settings: The extension can contain either protectedSettings or + :vartype auto_upgrade_minor_version: bool + :ivar settings: Json formatted public settings for the extension. + :vartype settings: any + :ivar protected_settings: The extension can contain either protectedSettings or protectedSettingsFromKeyVault or no protected settings at all. - :type protected_settings: any + :vartype protected_settings: any :ivar provisioning_state: The provisioning state, which only appears in the response. :vartype provisioning_state: str - :param instance_view: The machine extension instance view. - :type instance_view: ~azure.mgmt.connectedvmware.models.MachineExtensionPropertiesInstanceView + :ivar instance_view: The machine extension instance view. + :vartype instance_view: + ~azure.mgmt.connectedvmware.models.MachineExtensionPropertiesInstanceView """ _validation = { @@ -1505,6 +1736,34 @@ def __init__( instance_view: Optional["MachineExtensionPropertiesInstanceView"] = None, **kwargs ): + """ + :keyword location: Gets or sets the location. + :paramtype location: str + :keyword tags: A set of tags. Gets or sets the Resource tags. + :paramtype tags: dict[str, str] + :keyword force_update_tag: How the extension handler should be forced to update even if the + extension configuration has not changed. + :paramtype force_update_tag: str + :keyword publisher: The name of the extension handler publisher. + :paramtype publisher: str + :keyword type_properties_type: Specifies the type of the extension; an example is + "CustomScriptExtension". + :paramtype type_properties_type: str + :keyword type_handler_version: Specifies the version of the script handler. + :paramtype type_handler_version: str + :keyword auto_upgrade_minor_version: Indicates whether the extension should use a newer minor + version if one is available at deployment time. Once deployed, however, the extension will not + upgrade minor versions unless redeployed, even with this property set to true. + :paramtype auto_upgrade_minor_version: bool + :keyword settings: Json formatted public settings for the extension. + :paramtype settings: any + :keyword protected_settings: The extension can contain either protectedSettings or + protectedSettingsFromKeyVault or no protected settings at all. + :paramtype protected_settings: any + :keyword instance_view: The machine extension instance view. + :paramtype instance_view: + ~azure.mgmt.connectedvmware.models.MachineExtensionPropertiesInstanceView + """ super(MachineExtension, self).__init__(**kwargs) self.location = location self.system_data = None @@ -1534,8 +1793,8 @@ class MachineExtensionInstanceView(msrest.serialization.Model): :vartype type: str :ivar type_handler_version: Specifies the version of the script handler. :vartype type_handler_version: str - :param status: Instance view status. - :type status: ~azure.mgmt.connectedvmware.models.MachineExtensionInstanceViewStatus + :ivar status: Instance view status. + :vartype status: ~azure.mgmt.connectedvmware.models.MachineExtensionInstanceViewStatus """ _validation = { @@ -1557,6 +1816,10 @@ def __init__( status: Optional["MachineExtensionInstanceViewStatus"] = None, **kwargs ): + """ + :keyword status: Instance view status. + :paramtype status: ~azure.mgmt.connectedvmware.models.MachineExtensionInstanceViewStatus + """ super(MachineExtensionInstanceView, self).__init__(**kwargs) self.name = None self.type = None @@ -1601,6 +1864,8 @@ def __init__( self, **kwargs ): + """ + """ super(MachineExtensionInstanceViewStatus, self).__init__(**kwargs) self.code = None self.level = None @@ -1620,8 +1885,8 @@ class MachineExtensionPropertiesInstanceView(MachineExtensionInstanceView): :vartype type: str :ivar type_handler_version: Specifies the version of the script handler. :vartype type_handler_version: str - :param status: Instance view status. - :type status: ~azure.mgmt.connectedvmware.models.MachineExtensionInstanceViewStatus + :ivar status: Instance view status. + :vartype status: ~azure.mgmt.connectedvmware.models.MachineExtensionInstanceViewStatus """ _validation = { @@ -1643,17 +1908,21 @@ def __init__( status: Optional["MachineExtensionInstanceViewStatus"] = None, **kwargs ): + """ + :keyword status: Instance view status. + :paramtype status: ~azure.mgmt.connectedvmware.models.MachineExtensionInstanceViewStatus + """ super(MachineExtensionPropertiesInstanceView, self).__init__(status=status, **kwargs) class MachineExtensionsListResult(msrest.serialization.Model): """Describes the Machine Extensions List Result. - :param value: The list of extensions. - :type value: list[~azure.mgmt.connectedvmware.models.MachineExtension] - :param next_link: The uri to fetch the next page of machine extensions. Call ListNext() with + :ivar value: The list of extensions. + :vartype value: list[~azure.mgmt.connectedvmware.models.MachineExtension] + :ivar next_link: The uri to fetch the next page of machine extensions. Call ListNext() with this to fetch the next page of extensions. - :type next_link: str + :vartype next_link: str """ _attribute_map = { @@ -1668,6 +1937,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: The list of extensions. + :paramtype value: list[~azure.mgmt.connectedvmware.models.MachineExtension] + :keyword next_link: The uri to fetch the next page of machine extensions. Call ListNext() with + this to fetch the next page of extensions. + :paramtype next_link: str + """ super(MachineExtensionsListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1676,8 +1952,8 @@ def __init__( class ResourcePatch(msrest.serialization.Model): """Object containing updates for patch operations. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -1690,6 +1966,10 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(ResourcePatch, self).__init__(**kwargs) self.tags = tags @@ -1697,26 +1977,26 @@ def __init__( class MachineExtensionUpdate(ResourcePatch): """Describes a Machine Extension Update. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param force_update_tag: How the extension handler should be forced to update even if the + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar force_update_tag: How the extension handler should be forced to update even if the extension configuration has not changed. - :type force_update_tag: str - :param publisher: The name of the extension handler publisher. - :type publisher: str - :param type: Specifies the type of the extension; an example is "CustomScriptExtension". - :type type: str - :param type_handler_version: Specifies the version of the script handler. - :type type_handler_version: str - :param auto_upgrade_minor_version: Indicates whether the extension should use a newer minor + :vartype force_update_tag: str + :ivar publisher: The name of the extension handler publisher. + :vartype publisher: str + :ivar type: Specifies the type of the extension; an example is "CustomScriptExtension". + :vartype type: str + :ivar type_handler_version: Specifies the version of the script handler. + :vartype type_handler_version: str + :ivar auto_upgrade_minor_version: Indicates whether the extension should use a newer minor version if one is available at deployment time. Once deployed, however, the extension will not upgrade minor versions unless redeployed, even with this property set to true. - :type auto_upgrade_minor_version: bool - :param settings: Json formatted public settings for the extension. - :type settings: any - :param protected_settings: The extension can contain either protectedSettings or + :vartype auto_upgrade_minor_version: bool + :ivar settings: Json formatted public settings for the extension. + :vartype settings: any + :ivar protected_settings: The extension can contain either protectedSettings or protectedSettingsFromKeyVault or no protected settings at all. - :type protected_settings: any + :vartype protected_settings: any """ _attribute_map = { @@ -1743,6 +2023,28 @@ def __init__( protected_settings: Optional[Any] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword force_update_tag: How the extension handler should be forced to update even if the + extension configuration has not changed. + :paramtype force_update_tag: str + :keyword publisher: The name of the extension handler publisher. + :paramtype publisher: str + :keyword type: Specifies the type of the extension; an example is "CustomScriptExtension". + :paramtype type: str + :keyword type_handler_version: Specifies the version of the script handler. + :paramtype type_handler_version: str + :keyword auto_upgrade_minor_version: Indicates whether the extension should use a newer minor + version if one is available at deployment time. Once deployed, however, the extension will not + upgrade minor versions unless redeployed, even with this property set to true. + :paramtype auto_upgrade_minor_version: bool + :keyword settings: Json formatted public settings for the extension. + :paramtype settings: any + :keyword protected_settings: The extension can contain either protectedSettings or + protectedSettingsFromKeyVault or no protected settings at all. + :paramtype protected_settings: any + """ super(MachineExtensionUpdate, self).__init__(tags=tags, **kwargs) self.force_update_tag = force_update_tag self.publisher = publisher @@ -1758,8 +2060,8 @@ class NetworkInterface(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param name: Gets or sets the name of the network interface. - :type name: str + :ivar name: Gets or sets the name of the network interface. + :vartype name: str :ivar label: Gets or sets the label of the virtual network in vCenter that the nic is connected to. :vartype label: str @@ -1767,15 +2069,15 @@ class NetworkInterface(msrest.serialization.Model): :vartype ip_addresses: list[str] :ivar mac_address: Gets or sets the NIC MAC address. :vartype mac_address: str - :param network_id: Gets or sets the ARM Id of the network resource to connect the virtual + :ivar network_id: Gets or sets the ARM Id of the network resource to connect the virtual machine. - :type network_id: str - :param nic_type: NIC type. Possible values include: "vmxnet3", "vmxnet2", "vmxnet", "e1000", + :vartype network_id: str + :ivar nic_type: NIC type. Possible values include: "vmxnet3", "vmxnet2", "vmxnet", "e1000", "e1000e", "pcnet32". - :type nic_type: str or ~azure.mgmt.connectedvmware.models.NICType - :param power_on_boot: Gets or sets the power on boot. Possible values include: "enabled", + :vartype nic_type: str or ~azure.mgmt.connectedvmware.models.NICType + :ivar power_on_boot: Gets or sets the power on boot. Possible values include: "enabled", "disabled". - :type power_on_boot: str or ~azure.mgmt.connectedvmware.models.PowerOnBootOption + :vartype power_on_boot: str or ~azure.mgmt.connectedvmware.models.PowerOnBootOption :ivar network_mo_ref_id: Gets or sets the vCenter MoRef (Managed Object Reference) ID of the virtual network that the nic is connected to. @@ -1783,10 +2085,10 @@ class NetworkInterface(msrest.serialization.Model): :ivar network_mo_name: Gets or sets the name of the virtual network in vCenter that the nic is connected to. :vartype network_mo_name: str - :param device_key: Gets or sets the device key value. - :type device_key: int - :param ip_settings: Gets or sets the ipsettings. - :type ip_settings: ~azure.mgmt.connectedvmware.models.NicIPSettings + :ivar device_key: Gets or sets the device key value. + :vartype device_key: int + :ivar ip_settings: Gets or sets the ipsettings. + :vartype ip_settings: ~azure.mgmt.connectedvmware.models.NicIPSettings """ _validation = { @@ -1822,6 +2124,23 @@ def __init__( ip_settings: Optional["NicIPSettings"] = None, **kwargs ): + """ + :keyword name: Gets or sets the name of the network interface. + :paramtype name: str + :keyword network_id: Gets or sets the ARM Id of the network resource to connect the virtual + machine. + :paramtype network_id: str + :keyword nic_type: NIC type. Possible values include: "vmxnet3", "vmxnet2", "vmxnet", "e1000", + "e1000e", "pcnet32". + :paramtype nic_type: str or ~azure.mgmt.connectedvmware.models.NICType + :keyword power_on_boot: Gets or sets the power on boot. Possible values include: "enabled", + "disabled". + :paramtype power_on_boot: str or ~azure.mgmt.connectedvmware.models.PowerOnBootOption + :keyword device_key: Gets or sets the device key value. + :paramtype device_key: int + :keyword ip_settings: Gets or sets the ipsettings. + :paramtype ip_settings: ~azure.mgmt.connectedvmware.models.NicIPSettings + """ super(NetworkInterface, self).__init__(**kwargs) self.name = name self.label = None @@ -1839,19 +2158,19 @@ def __init__( class NetworkInterfaceUpdate(msrest.serialization.Model): """Defines the network interface update. - :param name: Gets or sets the name of the network interface. - :type name: str - :param network_id: Gets or sets the ARM Id of the network resource to connect the virtual + :ivar name: Gets or sets the name of the network interface. + :vartype name: str + :ivar network_id: Gets or sets the ARM Id of the network resource to connect the virtual machine. - :type network_id: str - :param nic_type: NIC type. Possible values include: "vmxnet3", "vmxnet2", "vmxnet", "e1000", + :vartype network_id: str + :ivar nic_type: NIC type. Possible values include: "vmxnet3", "vmxnet2", "vmxnet", "e1000", "e1000e", "pcnet32". - :type nic_type: str or ~azure.mgmt.connectedvmware.models.NICType - :param power_on_boot: Gets or sets the power on boot. Possible values include: "enabled", + :vartype nic_type: str or ~azure.mgmt.connectedvmware.models.NICType + :ivar power_on_boot: Gets or sets the power on boot. Possible values include: "enabled", "disabled". - :type power_on_boot: str or ~azure.mgmt.connectedvmware.models.PowerOnBootOption - :param device_key: Gets or sets the device key value. - :type device_key: int + :vartype power_on_boot: str or ~azure.mgmt.connectedvmware.models.PowerOnBootOption + :ivar device_key: Gets or sets the device key value. + :vartype device_key: int """ _attribute_map = { @@ -1872,6 +2191,21 @@ def __init__( device_key: Optional[int] = None, **kwargs ): + """ + :keyword name: Gets or sets the name of the network interface. + :paramtype name: str + :keyword network_id: Gets or sets the ARM Id of the network resource to connect the virtual + machine. + :paramtype network_id: str + :keyword nic_type: NIC type. Possible values include: "vmxnet3", "vmxnet2", "vmxnet", "e1000", + "e1000e", "pcnet32". + :paramtype nic_type: str or ~azure.mgmt.connectedvmware.models.NICType + :keyword power_on_boot: Gets or sets the power on boot. Possible values include: "enabled", + "disabled". + :paramtype power_on_boot: str or ~azure.mgmt.connectedvmware.models.PowerOnBootOption + :keyword device_key: Gets or sets the device key value. + :paramtype device_key: int + """ super(NetworkInterfaceUpdate, self).__init__(**kwargs) self.name = name self.network_id = network_id @@ -1883,9 +2217,9 @@ def __init__( class NetworkProfile(msrest.serialization.Model): """Defines the resource properties. - :param network_interfaces: Gets or sets the list of network interfaces associated with the + :ivar network_interfaces: Gets or sets the list of network interfaces associated with the virtual machine. - :type network_interfaces: list[~azure.mgmt.connectedvmware.models.NetworkInterface] + :vartype network_interfaces: list[~azure.mgmt.connectedvmware.models.NetworkInterface] """ _attribute_map = { @@ -1898,6 +2232,11 @@ def __init__( network_interfaces: Optional[List["NetworkInterface"]] = None, **kwargs ): + """ + :keyword network_interfaces: Gets or sets the list of network interfaces associated with the + virtual machine. + :paramtype network_interfaces: list[~azure.mgmt.connectedvmware.models.NetworkInterface] + """ super(NetworkProfile, self).__init__(**kwargs) self.network_interfaces = network_interfaces @@ -1905,9 +2244,9 @@ def __init__( class NetworkProfileUpdate(msrest.serialization.Model): """Defines the update resource properties. - :param network_interfaces: Gets or sets the list of network interfaces associated with the + :ivar network_interfaces: Gets or sets the list of network interfaces associated with the virtual machine. - :type network_interfaces: list[~azure.mgmt.connectedvmware.models.NetworkInterfaceUpdate] + :vartype network_interfaces: list[~azure.mgmt.connectedvmware.models.NetworkInterfaceUpdate] """ _attribute_map = { @@ -1920,6 +2259,11 @@ def __init__( network_interfaces: Optional[List["NetworkInterfaceUpdate"]] = None, **kwargs ): + """ + :keyword network_interfaces: Gets or sets the list of network interfaces associated with the + virtual machine. + :paramtype network_interfaces: list[~azure.mgmt.connectedvmware.models.NetworkInterfaceUpdate] + """ super(NetworkProfileUpdate, self).__init__(**kwargs) self.network_interfaces = network_interfaces @@ -1953,6 +2297,8 @@ def __init__( self, **kwargs ): + """ + """ super(NicIPAddressSettings, self).__init__(**kwargs) self.allocation_method = None self.ip_address = None @@ -1964,17 +2310,17 @@ class NicIPSettings(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param allocation_method: Gets or sets the nic allocation method. Possible values include: + :ivar allocation_method: Gets or sets the nic allocation method. Possible values include: "unset", "dynamic", "static", "linklayer", "random", "other". - :type allocation_method: str or ~azure.mgmt.connectedvmware.models.IPAddressAllocationMethod - :param dns_servers: Gets or sets the dns servers. - :type dns_servers: list[str] - :param gateway: Gets or sets the gateway. - :type gateway: list[str] - :param ip_address: Gets or sets the ip address for the nic. - :type ip_address: str - :param subnet_mask: Gets or sets the mask. - :type subnet_mask: str + :vartype allocation_method: str or ~azure.mgmt.connectedvmware.models.IPAddressAllocationMethod + :ivar dns_servers: Gets or sets the dns servers. + :vartype dns_servers: list[str] + :ivar gateway: Gets or sets the gateway. + :vartype gateway: list[str] + :ivar ip_address: Gets or sets the ip address for the nic. + :vartype ip_address: str + :ivar subnet_mask: Gets or sets the mask. + :vartype subnet_mask: str :ivar primary_wins_server: Gets or sets the primary server. :vartype primary_wins_server: str :ivar secondary_wins_server: Gets or sets the secondary server. @@ -2011,6 +2357,20 @@ def __init__( subnet_mask: Optional[str] = None, **kwargs ): + """ + :keyword allocation_method: Gets or sets the nic allocation method. Possible values include: + "unset", "dynamic", "static", "linklayer", "random", "other". + :paramtype allocation_method: str or + ~azure.mgmt.connectedvmware.models.IPAddressAllocationMethod + :keyword dns_servers: Gets or sets the dns servers. + :paramtype dns_servers: list[str] + :keyword gateway: Gets or sets the gateway. + :paramtype gateway: list[str] + :keyword ip_address: Gets or sets the ip address for the nic. + :paramtype ip_address: str + :keyword subnet_mask: Gets or sets the mask. + :paramtype subnet_mask: str + """ super(NicIPSettings, self).__init__(**kwargs) self.allocation_method = allocation_method self.dns_servers = dns_servers @@ -2025,12 +2385,12 @@ def __init__( class Operation(msrest.serialization.Model): """Operation provided by provider. - :param name: Name of the operation. - :type name: str - :param is_data_action: Indicates whether the operation is data action or not. - :type is_data_action: bool - :param display: Properties of the operation. - :type display: ~azure.mgmt.connectedvmware.models.OperationDisplay + :ivar name: Name of the operation. + :vartype name: str + :ivar is_data_action: Indicates whether the operation is data action or not. + :vartype is_data_action: bool + :ivar display: Properties of the operation. + :vartype display: ~azure.mgmt.connectedvmware.models.OperationDisplay """ _attribute_map = { @@ -2047,6 +2407,14 @@ def __init__( display: Optional["OperationDisplay"] = None, **kwargs ): + """ + :keyword name: Name of the operation. + :paramtype name: str + :keyword is_data_action: Indicates whether the operation is data action or not. + :paramtype is_data_action: bool + :keyword display: Properties of the operation. + :paramtype display: ~azure.mgmt.connectedvmware.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = name self.is_data_action = is_data_action @@ -2056,14 +2424,14 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """Properties of the operation. - :param provider: Provider name. - :type provider: str - :param resource: Resource name. - :type resource: str - :param operation: Operation name. - :type operation: str - :param description: Description of the operation. - :type description: str + :ivar provider: Provider name. + :vartype provider: str + :ivar resource: Resource name. + :vartype resource: str + :ivar operation: Operation name. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str """ _attribute_map = { @@ -2082,6 +2450,16 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword provider: Provider name. + :paramtype provider: str + :keyword resource: Resource name. + :paramtype resource: str + :keyword operation: Operation name. + :paramtype operation: str + :keyword description: Description of the operation. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -2094,10 +2472,10 @@ class OperationsList(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param next_link: Url to follow for getting next page of operations. - :type next_link: str - :param value: Required. Array of operations. - :type value: list[~azure.mgmt.connectedvmware.models.Operation] + :ivar next_link: Url to follow for getting next page of operations. + :vartype next_link: str + :ivar value: Required. Array of operations. + :vartype value: list[~azure.mgmt.connectedvmware.models.Operation] """ _validation = { @@ -2116,6 +2494,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword next_link: Url to follow for getting next page of operations. + :paramtype next_link: str + :keyword value: Required. Array of operations. + :paramtype value: list[~azure.mgmt.connectedvmware.models.Operation] + """ super(OperationsList, self).__init__(**kwargs) self.next_link = next_link self.value = value @@ -2126,15 +2510,15 @@ class OsProfile(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param computer_name: Gets or sets computer name. - :type computer_name: str - :param admin_username: Gets or sets administrator username. - :type admin_username: str - :param admin_password: Gets or sets administrator password. - :type admin_password: str - :param os_type: Gets or sets the type of the os. Possible values include: "Windows", "Linux", + :ivar computer_name: Gets or sets computer name. + :vartype computer_name: str + :ivar admin_username: Gets or sets administrator username. + :vartype admin_username: str + :ivar admin_password: Gets or sets administrator password. + :vartype admin_password: str + :ivar os_type: Gets or sets the type of the os. Possible values include: "Windows", "Linux", "Other". - :type os_type: str or ~azure.mgmt.connectedvmware.models.OsType + :vartype os_type: str or ~azure.mgmt.connectedvmware.models.OsType :ivar os_name: Gets or sets os name. :vartype os_name: str :ivar tools_running_status: Gets or sets the current running status of VMware Tools running in @@ -2174,6 +2558,17 @@ def __init__( os_type: Optional[Union[str, "OsType"]] = None, **kwargs ): + """ + :keyword computer_name: Gets or sets computer name. + :paramtype computer_name: str + :keyword admin_username: Gets or sets administrator username. + :paramtype admin_username: str + :keyword admin_password: Gets or sets administrator password. + :paramtype admin_password: str + :keyword os_type: Gets or sets the type of the os. Possible values include: "Windows", "Linux", + "Other". + :paramtype os_type: str or ~azure.mgmt.connectedvmware.models.OsType + """ super(OsProfile, self).__init__(**kwargs) self.computer_name = computer_name self.admin_username = admin_username @@ -2188,18 +2583,18 @@ def __init__( class PlacementProfile(msrest.serialization.Model): """Defines the resource properties. - :param resource_pool_id: Gets or sets the ARM Id of the resourcePool resource on which this + :ivar resource_pool_id: Gets or sets the ARM Id of the resourcePool resource on which this virtual machine will deploy. - :type resource_pool_id: str - :param cluster_id: Gets or sets the ARM Id of the cluster resource on which this virtual - machine will deploy. - :type cluster_id: str - :param host_id: Gets or sets the ARM Id of the host resource on which this virtual machine will + :vartype resource_pool_id: str + :ivar cluster_id: Gets or sets the ARM Id of the cluster resource on which this virtual machine + will deploy. + :vartype cluster_id: str + :ivar host_id: Gets or sets the ARM Id of the host resource on which this virtual machine will deploy. - :type host_id: str - :param datastore_id: Gets or sets the ARM Id of the datastore resource on which the data for - the virtual machine will be kept. - :type datastore_id: str + :vartype host_id: str + :ivar datastore_id: Gets or sets the ARM Id of the datastore resource on which the data for the + virtual machine will be kept. + :vartype datastore_id: str """ _attribute_map = { @@ -2218,6 +2613,20 @@ def __init__( datastore_id: Optional[str] = None, **kwargs ): + """ + :keyword resource_pool_id: Gets or sets the ARM Id of the resourcePool resource on which this + virtual machine will deploy. + :paramtype resource_pool_id: str + :keyword cluster_id: Gets or sets the ARM Id of the cluster resource on which this virtual + machine will deploy. + :paramtype cluster_id: str + :keyword host_id: Gets or sets the ARM Id of the host resource on which this virtual machine + will deploy. + :paramtype host_id: str + :keyword datastore_id: Gets or sets the ARM Id of the datastore resource on which the data for + the virtual machine will be kept. + :paramtype datastore_id: str + """ super(PlacementProfile, self).__init__(**kwargs) self.resource_pool_id = resource_pool_id self.cluster_id = cluster_id @@ -2232,34 +2641,34 @@ class ResourcePool(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: Required. Gets or sets the location. - :type location: str - :param extended_location: Gets or sets the extended location. - :type extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation + :ivar location: Required. Gets or sets the location. + :vartype location: str + :ivar extended_location: Gets or sets the extended location. + :vartype extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation :ivar system_data: The system data. :vartype system_data: ~azure.mgmt.connectedvmware.models.SystemData - :param tags: A set of tags. Gets or sets the Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Gets or sets the Resource tags. + :vartype tags: dict[str, str] :ivar name: Gets or sets the name. :vartype name: str :ivar id: Gets or sets the Id. :vartype id: str :ivar type: Gets or sets the type of the resource. :vartype type: str - :param kind: Metadata used by portal/tooling/etc to render different UX experiences for + :ivar kind: Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, the resource provider must validate and persist this value. - :type kind: str + :vartype kind: str :ivar uuid: Gets or sets a unique identifier for this resource. :vartype uuid: str - :param v_center_id: Gets or sets the ARM Id of the vCenter resource in which this resource pool + :ivar v_center_id: Gets or sets the ARM Id of the vCenter resource in which this resource pool resides. - :type v_center_id: str - :param mo_ref_id: Gets or sets the vCenter MoRef (Managed Object Reference) ID for the resource + :vartype v_center_id: str + :ivar mo_ref_id: Gets or sets the vCenter MoRef (Managed Object Reference) ID for the resource pool. - :type mo_ref_id: str - :param inventory_item_id: Gets or sets the inventory Item ID for the resource pool. - :type inventory_item_id: str + :vartype mo_ref_id: str + :ivar inventory_item_id: Gets or sets the inventory Item ID for the resource pool. + :vartype inventory_item_id: str :ivar mo_name: Gets or sets the vCenter Managed Object name for the resource pool. :vartype mo_name: str :ivar cpu_shares_level: Gets or sets CPUSharesLevel which specifies the CPU allocation level @@ -2348,6 +2757,26 @@ def __init__( inventory_item_id: Optional[str] = None, **kwargs ): + """ + :keyword location: Required. Gets or sets the location. + :paramtype location: str + :keyword extended_location: Gets or sets the extended location. + :paramtype extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation + :keyword tags: A set of tags. Gets or sets the Resource tags. + :paramtype tags: dict[str, str] + :keyword kind: Metadata used by portal/tooling/etc to render different UX experiences for + resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, + the resource provider must validate and persist this value. + :paramtype kind: str + :keyword v_center_id: Gets or sets the ARM Id of the vCenter resource in which this resource + pool resides. + :paramtype v_center_id: str + :keyword mo_ref_id: Gets or sets the vCenter MoRef (Managed Object Reference) ID for the + resource pool. + :paramtype mo_ref_id: str + :keyword inventory_item_id: Gets or sets the inventory Item ID for the resource pool. + :paramtype inventory_item_id: str + """ super(ResourcePool, self).__init__(**kwargs) self.location = location self.extended_location = extended_location @@ -2380,21 +2809,21 @@ class ResourcePoolInventoryItem(InventoryItemProperties): All required parameters must be populated in order to send to Azure. - :param inventory_type: Required. They inventory type.Constant filled by server. Possible - values include: "ResourcePool", "VirtualMachine", "VirtualMachineTemplate", "VirtualNetwork", + :ivar inventory_type: Required. They inventory type.Constant filled by server. Possible values + include: "ResourcePool", "VirtualMachine", "VirtualMachineTemplate", "VirtualNetwork", "Cluster", "Datastore", "Host". - :type inventory_type: str or ~azure.mgmt.connectedvmware.models.InventoryType - :param managed_resource_id: Gets or sets the tracked resource id corresponding to the inventory + :vartype inventory_type: str or ~azure.mgmt.connectedvmware.models.InventoryType + :ivar managed_resource_id: Gets or sets the tracked resource id corresponding to the inventory resource. - :type managed_resource_id: str - :param mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory item. - :type mo_ref_id: str - :param mo_name: Gets or sets the vCenter Managed Object name for the inventory item. - :type mo_name: str + :vartype managed_resource_id: str + :ivar mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory item. + :vartype mo_ref_id: str + :ivar mo_name: Gets or sets the vCenter Managed Object name for the inventory item. + :vartype mo_name: str :ivar provisioning_state: Gets or sets the provisioning state. :vartype provisioning_state: str - :param parent: Parent resourcePool inventory resource details. - :type parent: ~azure.mgmt.connectedvmware.models.InventoryItemDetails + :ivar parent: Parent resourcePool inventory resource details. + :vartype parent: ~azure.mgmt.connectedvmware.models.InventoryItemDetails """ _validation = { @@ -2420,6 +2849,18 @@ def __init__( parent: Optional["InventoryItemDetails"] = None, **kwargs ): + """ + :keyword managed_resource_id: Gets or sets the tracked resource id corresponding to the + inventory resource. + :paramtype managed_resource_id: str + :keyword mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory + item. + :paramtype mo_ref_id: str + :keyword mo_name: Gets or sets the vCenter Managed Object name for the inventory item. + :paramtype mo_name: str + :keyword parent: Parent resourcePool inventory resource details. + :paramtype parent: ~azure.mgmt.connectedvmware.models.InventoryItemDetails + """ super(ResourcePoolInventoryItem, self).__init__(managed_resource_id=managed_resource_id, mo_ref_id=mo_ref_id, mo_name=mo_name, **kwargs) self.inventory_type = 'ResourcePool' # type: str self.parent = parent @@ -2430,10 +2871,10 @@ class ResourcePoolsList(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param next_link: Url to follow for getting next page of ResourcePools. - :type next_link: str - :param value: Required. Array of ResourcePools. - :type value: list[~azure.mgmt.connectedvmware.models.ResourcePool] + :ivar next_link: Url to follow for getting next page of ResourcePools. + :vartype next_link: str + :ivar value: Required. Array of ResourcePools. + :vartype value: list[~azure.mgmt.connectedvmware.models.ResourcePool] """ _validation = { @@ -2452,6 +2893,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword next_link: Url to follow for getting next page of ResourcePools. + :paramtype next_link: str + :keyword value: Required. Array of ResourcePools. + :paramtype value: list[~azure.mgmt.connectedvmware.models.ResourcePool] + """ super(ResourcePoolsList, self).__init__(**kwargs) self.next_link = next_link self.value = value @@ -2498,6 +2945,8 @@ def __init__( self, **kwargs ): + """ + """ super(ResourceStatus, self).__init__(**kwargs) self.type = None self.status = None @@ -2510,10 +2959,10 @@ def __init__( class StopVirtualMachineOptions(msrest.serialization.Model): """Defines the stop action properties. - :param skip_shutdown: Gets or sets a value indicating whether to request non-graceful VM + :ivar skip_shutdown: Gets or sets a value indicating whether to request non-graceful VM shutdown. True value for this flag indicates non-graceful shutdown whereas false indicates otherwise. Defaults to false. - :type skip_shutdown: bool + :vartype skip_shutdown: bool """ _attribute_map = { @@ -2526,6 +2975,12 @@ def __init__( skip_shutdown: Optional[bool] = False, **kwargs ): + """ + :keyword skip_shutdown: Gets or sets a value indicating whether to request non-graceful VM + shutdown. True value for this flag indicates non-graceful shutdown whereas false indicates + otherwise. Defaults to false. + :paramtype skip_shutdown: bool + """ super(StopVirtualMachineOptions, self).__init__(**kwargs) self.skip_shutdown = skip_shutdown @@ -2535,8 +2990,8 @@ class StorageProfile(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param disks: Gets or sets the list of virtual disks associated with the virtual machine. - :type disks: list[~azure.mgmt.connectedvmware.models.VirtualDisk] + :ivar disks: Gets or sets the list of virtual disks associated with the virtual machine. + :vartype disks: list[~azure.mgmt.connectedvmware.models.VirtualDisk] :ivar scsi_controllers: Gets or sets the list of virtual SCSI controllers associated with the virtual machine. :vartype scsi_controllers: list[~azure.mgmt.connectedvmware.models.VirtualSCSIController] @@ -2557,6 +3012,10 @@ def __init__( disks: Optional[List["VirtualDisk"]] = None, **kwargs ): + """ + :keyword disks: Gets or sets the list of virtual disks associated with the virtual machine. + :paramtype disks: list[~azure.mgmt.connectedvmware.models.VirtualDisk] + """ super(StorageProfile, self).__init__(**kwargs) self.disks = disks self.scsi_controllers = None @@ -2565,8 +3024,8 @@ def __init__( class StorageProfileUpdate(msrest.serialization.Model): """Defines the resource update properties. - :param disks: Gets or sets the list of virtual disks associated with the virtual machine. - :type disks: list[~azure.mgmt.connectedvmware.models.VirtualDiskUpdate] + :ivar disks: Gets or sets the list of virtual disks associated with the virtual machine. + :vartype disks: list[~azure.mgmt.connectedvmware.models.VirtualDiskUpdate] """ _attribute_map = { @@ -2579,6 +3038,10 @@ def __init__( disks: Optional[List["VirtualDiskUpdate"]] = None, **kwargs ): + """ + :keyword disks: Gets or sets the list of virtual disks associated with the virtual machine. + :paramtype disks: list[~azure.mgmt.connectedvmware.models.VirtualDiskUpdate] + """ super(StorageProfileUpdate, self).__init__(**kwargs) self.disks = disks @@ -2586,20 +3049,20 @@ def __init__( class SystemData(msrest.serialization.Model): """Metadata pertaining to creation and last modification of the resource. - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~azure.mgmt.connectedvmware.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Possible values include: + "User", "Application", "ManagedIdentity", "Key". + :vartype created_by_type: str or ~azure.mgmt.connectedvmware.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or ~azure.mgmt.connectedvmware.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime + :vartype last_modified_by_type: str or ~azure.mgmt.connectedvmware.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { @@ -2622,6 +3085,22 @@ def __init__( last_modified_at: Optional[datetime.datetime] = None, **kwargs ): + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or ~azure.mgmt.connectedvmware.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :paramtype last_modified_by_type: str or ~azure.mgmt.connectedvmware.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ super(SystemData, self).__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type @@ -2638,30 +3117,30 @@ class VCenter(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: Required. Gets or sets the location. - :type location: str - :param extended_location: Gets or sets the extended location. - :type extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation + :ivar location: Required. Gets or sets the location. + :vartype location: str + :ivar extended_location: Gets or sets the extended location. + :vartype extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation :ivar system_data: The system data. :vartype system_data: ~azure.mgmt.connectedvmware.models.SystemData - :param tags: A set of tags. Gets or sets the Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Gets or sets the Resource tags. + :vartype tags: dict[str, str] :ivar name: Gets or sets the name. :vartype name: str :ivar id: Gets or sets the Id. :vartype id: str :ivar type: Gets or sets the type of the resource. :vartype type: str - :param kind: Metadata used by portal/tooling/etc to render different UX experiences for + :ivar kind: Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, the resource provider must validate and persist this value. - :type kind: str + :vartype kind: str :ivar uuid: Gets or sets a unique identifier for this resource. :vartype uuid: str - :param fqdn: Required. Gets or sets the FQDN/IPAddress of the vCenter. - :type fqdn: str - :param port: Gets or sets the port of the vCenter. - :type port: int + :ivar fqdn: Required. Gets or sets the FQDN/IPAddress of the vCenter. + :vartype fqdn: str + :ivar port: Gets or sets the port of the vCenter. + :vartype port: int :ivar version: Gets or sets the version of the vCenter. :vartype version: str :ivar instance_uuid: Gets or sets the instance UUID of the vCenter. @@ -2670,8 +3149,8 @@ class VCenter(msrest.serialization.Model): :vartype connection_status: str :ivar custom_resource_name: Gets the name of the corresponding resource in Kubernetes. :vartype custom_resource_name: str - :param credentials: Username / Password Credentials to connect to vcenter. - :type credentials: ~azure.mgmt.connectedvmware.models.VICredential + :ivar credentials: Username / Password Credentials to connect to vcenter. + :vartype credentials: ~azure.mgmt.connectedvmware.models.VICredential :ivar statuses: The resource status information. :vartype statuses: list[~azure.mgmt.connectedvmware.models.ResourceStatus] :ivar provisioning_state: Gets or sets the provisioning state. @@ -2728,6 +3207,24 @@ def __init__( credentials: Optional["VICredential"] = None, **kwargs ): + """ + :keyword location: Required. Gets or sets the location. + :paramtype location: str + :keyword extended_location: Gets or sets the extended location. + :paramtype extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation + :keyword tags: A set of tags. Gets or sets the Resource tags. + :paramtype tags: dict[str, str] + :keyword kind: Metadata used by portal/tooling/etc to render different UX experiences for + resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, + the resource provider must validate and persist this value. + :paramtype kind: str + :keyword fqdn: Required. Gets or sets the FQDN/IPAddress of the vCenter. + :paramtype fqdn: str + :keyword port: Gets or sets the port of the vCenter. + :paramtype port: int + :keyword credentials: Username / Password Credentials to connect to vcenter. + :paramtype credentials: ~azure.mgmt.connectedvmware.models.VICredential + """ super(VCenter, self).__init__(**kwargs) self.location = location self.extended_location = extended_location @@ -2754,10 +3251,10 @@ class VCentersList(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param next_link: Url to follow for getting next page of VCenters. - :type next_link: str - :param value: Required. Array of VCenters. - :type value: list[~azure.mgmt.connectedvmware.models.VCenter] + :ivar next_link: Url to follow for getting next page of VCenters. + :vartype next_link: str + :ivar value: Required. Array of VCenters. + :vartype value: list[~azure.mgmt.connectedvmware.models.VCenter] """ _validation = { @@ -2776,6 +3273,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword next_link: Url to follow for getting next page of VCenters. + :paramtype next_link: str + :keyword value: Required. Array of VCenters. + :paramtype value: list[~azure.mgmt.connectedvmware.models.VCenter] + """ super(VCentersList, self).__init__(**kwargs) self.next_link = next_link self.value = value @@ -2784,10 +3287,10 @@ def __init__( class VICredential(msrest.serialization.Model): """Username / Password Credentials to connect to vcenter. - :param username: Gets or sets username to connect with the vCenter. - :type username: str - :param password: Gets or sets the password to connect with the vCenter. - :type password: str + :ivar username: Gets or sets username to connect with the vCenter. + :vartype username: str + :ivar password: Gets or sets the password to connect with the vCenter. + :vartype password: str """ _attribute_map = { @@ -2802,6 +3305,12 @@ def __init__( password: Optional[str] = None, **kwargs ): + """ + :keyword username: Gets or sets username to connect with the vCenter. + :paramtype username: str + :keyword password: Gets or sets the password to connect with the vCenter. + :paramtype password: str + """ super(VICredential, self).__init__(**kwargs) self.username = username self.password = password @@ -2812,28 +3321,28 @@ class VirtualDisk(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param name: Gets or sets the name of the virtual disk. - :type name: str + :ivar name: Gets or sets the name of the virtual disk. + :vartype name: str :ivar label: Gets or sets the label of the virtual disk in vCenter. :vartype label: str :ivar disk_object_id: Gets or sets the disk object id. :vartype disk_object_id: str - :param disk_size_gb: Gets or sets the disk total size. - :type disk_size_gb: int - :param device_key: Gets or sets the device key value. - :type device_key: int - :param disk_mode: Gets or sets the disk mode. Possible values include: "persistent", + :ivar disk_size_gb: Gets or sets the disk total size. + :vartype disk_size_gb: int + :ivar device_key: Gets or sets the device key value. + :vartype device_key: int + :ivar disk_mode: Gets or sets the disk mode. Possible values include: "persistent", "independent_persistent", "independent_nonpersistent". - :type disk_mode: str or ~azure.mgmt.connectedvmware.models.DiskMode - :param controller_key: Gets or sets the controller id. - :type controller_key: int - :param unit_number: Gets or sets the unit number of the disk on the controller. - :type unit_number: int - :param device_name: Gets or sets the device name. - :type device_name: str - :param disk_type: Gets or sets the disk backing type. Possible values include: "flat", "pmem", + :vartype disk_mode: str or ~azure.mgmt.connectedvmware.models.DiskMode + :ivar controller_key: Gets or sets the controller id. + :vartype controller_key: int + :ivar unit_number: Gets or sets the unit number of the disk on the controller. + :vartype unit_number: int + :ivar device_name: Gets or sets the device name. + :vartype device_name: str + :ivar disk_type: Gets or sets the disk backing type. Possible values include: "flat", "pmem", "rawphysical", "rawvirtual", "sparse", "sesparse", "unknown". - :type disk_type: str or ~azure.mgmt.connectedvmware.models.DiskType + :vartype disk_type: str or ~azure.mgmt.connectedvmware.models.DiskType """ _validation = { @@ -2867,6 +3376,26 @@ def __init__( disk_type: Optional[Union[str, "DiskType"]] = None, **kwargs ): + """ + :keyword name: Gets or sets the name of the virtual disk. + :paramtype name: str + :keyword disk_size_gb: Gets or sets the disk total size. + :paramtype disk_size_gb: int + :keyword device_key: Gets or sets the device key value. + :paramtype device_key: int + :keyword disk_mode: Gets or sets the disk mode. Possible values include: "persistent", + "independent_persistent", "independent_nonpersistent". + :paramtype disk_mode: str or ~azure.mgmt.connectedvmware.models.DiskMode + :keyword controller_key: Gets or sets the controller id. + :paramtype controller_key: int + :keyword unit_number: Gets or sets the unit number of the disk on the controller. + :paramtype unit_number: int + :keyword device_name: Gets or sets the device name. + :paramtype device_name: str + :keyword disk_type: Gets or sets the disk backing type. Possible values include: "flat", + "pmem", "rawphysical", "rawvirtual", "sparse", "sesparse", "unknown". + :paramtype disk_type: str or ~azure.mgmt.connectedvmware.models.DiskType + """ super(VirtualDisk, self).__init__(**kwargs) self.name = name self.label = None @@ -2883,24 +3412,24 @@ def __init__( class VirtualDiskUpdate(msrest.serialization.Model): """Defines the virtual disk update. - :param name: Gets or sets the name of the virtual disk. - :type name: str - :param disk_size_gb: Gets or sets the disk total size. - :type disk_size_gb: int - :param device_key: Gets or sets the device key value. - :type device_key: int - :param disk_mode: Gets or sets the disk mode. Possible values include: "persistent", + :ivar name: Gets or sets the name of the virtual disk. + :vartype name: str + :ivar disk_size_gb: Gets or sets the disk total size. + :vartype disk_size_gb: int + :ivar device_key: Gets or sets the device key value. + :vartype device_key: int + :ivar disk_mode: Gets or sets the disk mode. Possible values include: "persistent", "independent_persistent", "independent_nonpersistent". - :type disk_mode: str or ~azure.mgmt.connectedvmware.models.DiskMode - :param controller_key: Gets or sets the controller id. - :type controller_key: int - :param unit_number: Gets or sets the unit number of the disk on the controller. - :type unit_number: int - :param device_name: Gets or sets the device name. - :type device_name: str - :param disk_type: Gets or sets the disk backing type. Possible values include: "flat", "pmem", + :vartype disk_mode: str or ~azure.mgmt.connectedvmware.models.DiskMode + :ivar controller_key: Gets or sets the controller id. + :vartype controller_key: int + :ivar unit_number: Gets or sets the unit number of the disk on the controller. + :vartype unit_number: int + :ivar device_name: Gets or sets the device name. + :vartype device_name: str + :ivar disk_type: Gets or sets the disk backing type. Possible values include: "flat", "pmem", "rawphysical", "rawvirtual", "sparse", "sesparse", "unknown". - :type disk_type: str or ~azure.mgmt.connectedvmware.models.DiskType + :vartype disk_type: str or ~azure.mgmt.connectedvmware.models.DiskType """ _attribute_map = { @@ -2927,6 +3456,26 @@ def __init__( disk_type: Optional[Union[str, "DiskType"]] = None, **kwargs ): + """ + :keyword name: Gets or sets the name of the virtual disk. + :paramtype name: str + :keyword disk_size_gb: Gets or sets the disk total size. + :paramtype disk_size_gb: int + :keyword device_key: Gets or sets the device key value. + :paramtype device_key: int + :keyword disk_mode: Gets or sets the disk mode. Possible values include: "persistent", + "independent_persistent", "independent_nonpersistent". + :paramtype disk_mode: str or ~azure.mgmt.connectedvmware.models.DiskMode + :keyword controller_key: Gets or sets the controller id. + :paramtype controller_key: int + :keyword unit_number: Gets or sets the unit number of the disk on the controller. + :paramtype unit_number: int + :keyword device_name: Gets or sets the device name. + :paramtype device_name: str + :keyword disk_type: Gets or sets the disk backing type. Possible values include: "flat", + "pmem", "rawphysical", "rawvirtual", "sparse", "sesparse", "unknown". + :paramtype disk_type: str or ~azure.mgmt.connectedvmware.models.DiskType + """ super(VirtualDiskUpdate, self).__init__(**kwargs) self.name = name self.disk_size_gb = disk_size_gb @@ -2945,63 +3494,63 @@ class VirtualMachine(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: Required. Gets or sets the location. - :type location: str - :param extended_location: Gets or sets the extended location. - :type extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation + :ivar location: Required. Gets or sets the location. + :vartype location: str + :ivar extended_location: Gets or sets the extended location. + :vartype extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation :ivar system_data: The system data. :vartype system_data: ~azure.mgmt.connectedvmware.models.SystemData - :param tags: A set of tags. Gets or sets the Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Gets or sets the Resource tags. + :vartype tags: dict[str, str] :ivar name: Gets or sets the name. :vartype name: str :ivar id: Gets or sets the Id. :vartype id: str :ivar type: Gets or sets the type of the resource. :vartype type: str - :param kind: Metadata used by portal/tooling/etc to render different UX experiences for + :ivar kind: Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, the resource provider must validate and persist this value. - :type kind: str - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.connectedvmware.models.Identity - :param resource_pool_id: Gets or sets the ARM Id of the resourcePool resource on which this + :vartype kind: str + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.connectedvmware.models.Identity + :ivar resource_pool_id: Gets or sets the ARM Id of the resourcePool resource on which this virtual machine will deploy. - :type resource_pool_id: str - :param template_id: Gets or sets the ARM Id of the template resource to deploy the virtual + :vartype resource_pool_id: str + :ivar template_id: Gets or sets the ARM Id of the template resource to deploy the virtual machine. - :type template_id: str - :param v_center_id: Gets or sets the ARM Id of the vCenter resource in which this resource pool + :vartype template_id: str + :ivar v_center_id: Gets or sets the ARM Id of the vCenter resource in which this resource pool resides. - :type v_center_id: str - :param placement_profile: Placement properties. - :type placement_profile: ~azure.mgmt.connectedvmware.models.PlacementProfile - :param os_profile: OS properties. - :type os_profile: ~azure.mgmt.connectedvmware.models.OsProfile - :param hardware_profile: Hardware properties. - :type hardware_profile: ~azure.mgmt.connectedvmware.models.HardwareProfile - :param network_profile: Network properties. - :type network_profile: ~azure.mgmt.connectedvmware.models.NetworkProfile - :param storage_profile: Storage properties. - :type storage_profile: ~azure.mgmt.connectedvmware.models.StorageProfile - :param guest_agent_profile: Guest agent status properties. - :type guest_agent_profile: ~azure.mgmt.connectedvmware.models.GuestAgentProfile - :param mo_ref_id: Gets or sets the vCenter MoRef (Managed Object Reference) ID for the virtual + :vartype v_center_id: str + :ivar placement_profile: Placement properties. + :vartype placement_profile: ~azure.mgmt.connectedvmware.models.PlacementProfile + :ivar os_profile: OS properties. + :vartype os_profile: ~azure.mgmt.connectedvmware.models.OsProfile + :ivar hardware_profile: Hardware properties. + :vartype hardware_profile: ~azure.mgmt.connectedvmware.models.HardwareProfile + :ivar network_profile: Network properties. + :vartype network_profile: ~azure.mgmt.connectedvmware.models.NetworkProfile + :ivar storage_profile: Storage properties. + :vartype storage_profile: ~azure.mgmt.connectedvmware.models.StorageProfile + :ivar guest_agent_profile: Guest agent status properties. + :vartype guest_agent_profile: ~azure.mgmt.connectedvmware.models.GuestAgentProfile + :ivar mo_ref_id: Gets or sets the vCenter MoRef (Managed Object Reference) ID for the virtual machine. - :type mo_ref_id: str - :param inventory_item_id: Gets or sets the inventory Item ID for the virtual machine. - :type inventory_item_id: str + :vartype mo_ref_id: str + :ivar inventory_item_id: Gets or sets the inventory Item ID for the virtual machine. + :vartype inventory_item_id: str :ivar mo_name: Gets or sets the vCenter Managed Object name for the virtual machine. :vartype mo_name: str :ivar folder_path: Gets or sets the folder path of the vm. :vartype folder_path: str :ivar instance_uuid: Gets or sets the instance uuid of the vm. :vartype instance_uuid: str - :param smbios_uuid: Gets or sets the SMBIOS UUID of the vm. - :type smbios_uuid: str - :param firmware_type: Firmware type. Possible values include: "bios", "efi". - :type firmware_type: str or ~azure.mgmt.connectedvmware.models.FirmwareType + :ivar smbios_uuid: Gets or sets the SMBIOS UUID of the vm. + :vartype smbios_uuid: str + :ivar firmware_type: Firmware type. Possible values include: "bios", "efi". + :vartype firmware_type: str or ~azure.mgmt.connectedvmware.models.FirmwareType :ivar power_state: Gets the power state of the virtual machine. :vartype power_state: str :ivar custom_resource_name: Gets the name of the corresponding resource in Kubernetes. @@ -3090,6 +3639,51 @@ def __init__( firmware_type: Optional[Union[str, "FirmwareType"]] = None, **kwargs ): + """ + :keyword location: Required. Gets or sets the location. + :paramtype location: str + :keyword extended_location: Gets or sets the extended location. + :paramtype extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation + :keyword tags: A set of tags. Gets or sets the Resource tags. + :paramtype tags: dict[str, str] + :keyword kind: Metadata used by portal/tooling/etc to render different UX experiences for + resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, + the resource provider must validate and persist this value. + :paramtype kind: str + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.connectedvmware.models.Identity + :keyword resource_pool_id: Gets or sets the ARM Id of the resourcePool resource on which this + virtual machine will + deploy. + :paramtype resource_pool_id: str + :keyword template_id: Gets or sets the ARM Id of the template resource to deploy the virtual + machine. + :paramtype template_id: str + :keyword v_center_id: Gets or sets the ARM Id of the vCenter resource in which this resource + pool resides. + :paramtype v_center_id: str + :keyword placement_profile: Placement properties. + :paramtype placement_profile: ~azure.mgmt.connectedvmware.models.PlacementProfile + :keyword os_profile: OS properties. + :paramtype os_profile: ~azure.mgmt.connectedvmware.models.OsProfile + :keyword hardware_profile: Hardware properties. + :paramtype hardware_profile: ~azure.mgmt.connectedvmware.models.HardwareProfile + :keyword network_profile: Network properties. + :paramtype network_profile: ~azure.mgmt.connectedvmware.models.NetworkProfile + :keyword storage_profile: Storage properties. + :paramtype storage_profile: ~azure.mgmt.connectedvmware.models.StorageProfile + :keyword guest_agent_profile: Guest agent status properties. + :paramtype guest_agent_profile: ~azure.mgmt.connectedvmware.models.GuestAgentProfile + :keyword mo_ref_id: Gets or sets the vCenter MoRef (Managed Object Reference) ID for the + virtual machine. + :paramtype mo_ref_id: str + :keyword inventory_item_id: Gets or sets the inventory Item ID for the virtual machine. + :paramtype inventory_item_id: str + :keyword smbios_uuid: Gets or sets the SMBIOS UUID of the vm. + :paramtype smbios_uuid: str + :keyword firmware_type: Firmware type. Possible values include: "bios", "efi". + :paramtype firmware_type: str or ~azure.mgmt.connectedvmware.models.FirmwareType + """ super(VirtualMachine, self).__init__(**kwargs) self.location = location self.extended_location = extended_location @@ -3131,36 +3725,36 @@ class VirtualMachineInventoryItem(InventoryItemProperties): All required parameters must be populated in order to send to Azure. - :param inventory_type: Required. They inventory type.Constant filled by server. Possible - values include: "ResourcePool", "VirtualMachine", "VirtualMachineTemplate", "VirtualNetwork", + :ivar inventory_type: Required. They inventory type.Constant filled by server. Possible values + include: "ResourcePool", "VirtualMachine", "VirtualMachineTemplate", "VirtualNetwork", "Cluster", "Datastore", "Host". - :type inventory_type: str or ~azure.mgmt.connectedvmware.models.InventoryType - :param managed_resource_id: Gets or sets the tracked resource id corresponding to the inventory + :vartype inventory_type: str or ~azure.mgmt.connectedvmware.models.InventoryType + :ivar managed_resource_id: Gets or sets the tracked resource id corresponding to the inventory resource. - :type managed_resource_id: str - :param mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory item. - :type mo_ref_id: str - :param mo_name: Gets or sets the vCenter Managed Object name for the inventory item. - :type mo_name: str + :vartype managed_resource_id: str + :ivar mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory item. + :vartype mo_ref_id: str + :ivar mo_name: Gets or sets the vCenter Managed Object name for the inventory item. + :vartype mo_name: str :ivar provisioning_state: Gets or sets the provisioning state. :vartype provisioning_state: str - :param os_type: Gets or sets the type of the os. Possible values include: "Windows", "Linux", + :ivar os_type: Gets or sets the type of the os. Possible values include: "Windows", "Linux", "Other". - :type os_type: str or ~azure.mgmt.connectedvmware.models.OsType - :param os_name: Gets or sets os name. - :type os_name: str - :param ip_addresses: Gets or sets the nic ip addresses. - :type ip_addresses: list[str] - :param folder_path: Gets or sets the folder path of the vm. - :type folder_path: str - :param host: Host inventory resource details. - :type host: ~azure.mgmt.connectedvmware.models.InventoryItemDetails - :param resource_pool: ResourcePool inventory resource details. - :type resource_pool: ~azure.mgmt.connectedvmware.models.InventoryItemDetails - :param instance_uuid: Gets or sets the instance uuid of the vm. - :type instance_uuid: str - :param smbios_uuid: Gets or sets the SMBIOS UUID of the vm. - :type smbios_uuid: str + :vartype os_type: str or ~azure.mgmt.connectedvmware.models.OsType + :ivar os_name: Gets or sets os name. + :vartype os_name: str + :ivar ip_addresses: Gets or sets the nic ip addresses. + :vartype ip_addresses: list[str] + :ivar folder_path: Gets or sets the folder path of the vm. + :vartype folder_path: str + :ivar host: Host inventory resource details. + :vartype host: ~azure.mgmt.connectedvmware.models.InventoryItemDetails + :ivar resource_pool: ResourcePool inventory resource details. + :vartype resource_pool: ~azure.mgmt.connectedvmware.models.InventoryItemDetails + :ivar instance_uuid: Gets or sets the instance uuid of the vm. + :vartype instance_uuid: str + :ivar smbios_uuid: Gets or sets the SMBIOS UUID of the vm. + :vartype smbios_uuid: str :ivar power_state: Gets the power state of the virtual machine. :vartype power_state: str :ivar tools_running_status: Gets or sets the current running status of VMware Tools running in @@ -3218,6 +3812,33 @@ def __init__( smbios_uuid: Optional[str] = None, **kwargs ): + """ + :keyword managed_resource_id: Gets or sets the tracked resource id corresponding to the + inventory resource. + :paramtype managed_resource_id: str + :keyword mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory + item. + :paramtype mo_ref_id: str + :keyword mo_name: Gets or sets the vCenter Managed Object name for the inventory item. + :paramtype mo_name: str + :keyword os_type: Gets or sets the type of the os. Possible values include: "Windows", "Linux", + "Other". + :paramtype os_type: str or ~azure.mgmt.connectedvmware.models.OsType + :keyword os_name: Gets or sets os name. + :paramtype os_name: str + :keyword ip_addresses: Gets or sets the nic ip addresses. + :paramtype ip_addresses: list[str] + :keyword folder_path: Gets or sets the folder path of the vm. + :paramtype folder_path: str + :keyword host: Host inventory resource details. + :paramtype host: ~azure.mgmt.connectedvmware.models.InventoryItemDetails + :keyword resource_pool: ResourcePool inventory resource details. + :paramtype resource_pool: ~azure.mgmt.connectedvmware.models.InventoryItemDetails + :keyword instance_uuid: Gets or sets the instance uuid of the vm. + :paramtype instance_uuid: str + :keyword smbios_uuid: Gets or sets the SMBIOS UUID of the vm. + :paramtype smbios_uuid: str + """ super(VirtualMachineInventoryItem, self).__init__(managed_resource_id=managed_resource_id, mo_ref_id=mo_ref_id, mo_name=mo_name, **kwargs) self.inventory_type = 'VirtualMachine' # type: str self.os_type = os_type @@ -3239,10 +3860,10 @@ class VirtualMachinesList(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param next_link: Url to follow for getting next page of VirtualMachines. - :type next_link: str - :param value: Required. Array of VirtualMachines. - :type value: list[~azure.mgmt.connectedvmware.models.VirtualMachine] + :ivar next_link: Url to follow for getting next page of VirtualMachines. + :vartype next_link: str + :ivar value: Required. Array of VirtualMachines. + :vartype value: list[~azure.mgmt.connectedvmware.models.VirtualMachine] """ _validation = { @@ -3261,6 +3882,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword next_link: Url to follow for getting next page of VirtualMachines. + :paramtype next_link: str + :keyword value: Required. Array of VirtualMachines. + :paramtype value: list[~azure.mgmt.connectedvmware.models.VirtualMachine] + """ super(VirtualMachinesList, self).__init__(**kwargs) self.next_link = next_link self.value = value @@ -3273,35 +3900,35 @@ class VirtualMachineTemplate(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: Required. Gets or sets the location. - :type location: str - :param extended_location: Gets or sets the extended location. - :type extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation + :ivar location: Required. Gets or sets the location. + :vartype location: str + :ivar extended_location: Gets or sets the extended location. + :vartype extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation :ivar system_data: The system data. :vartype system_data: ~azure.mgmt.connectedvmware.models.SystemData - :param tags: A set of tags. Gets or sets the Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Gets or sets the Resource tags. + :vartype tags: dict[str, str] :ivar name: Gets or sets the name. :vartype name: str :ivar id: Gets or sets the Id. :vartype id: str :ivar type: Gets or sets the type of the resource. :vartype type: str - :param kind: Metadata used by portal/tooling/etc to render different UX experiences for + :ivar kind: Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, the resource provider must validate and persist this value. - :type kind: str + :vartype kind: str :ivar uuid: Gets or sets a unique identifier for this resource. :vartype uuid: str - :param v_center_id: Gets or sets the ARM Id of the vCenter resource in which this template + :ivar v_center_id: Gets or sets the ARM Id of the vCenter resource in which this template resides. - :type v_center_id: str - :param mo_ref_id: Gets or sets the vCenter MoRef (Managed Object Reference) ID for the virtual + :vartype v_center_id: str + :ivar mo_ref_id: Gets or sets the vCenter MoRef (Managed Object Reference) ID for the virtual machine template. - :type mo_ref_id: str - :param inventory_item_id: Gets or sets the inventory Item ID for the virtual machine template. - :type inventory_item_id: str + :vartype mo_ref_id: str + :ivar inventory_item_id: Gets or sets the inventory Item ID for the virtual machine template. + :vartype inventory_item_id: str :ivar mo_name: Gets or sets the vCenter Managed Object name for the virtual machine template. :vartype mo_name: str :ivar memory_size_mb: Gets or sets memory size in MBs for the template. @@ -3403,6 +4030,28 @@ def __init__( inventory_item_id: Optional[str] = None, **kwargs ): + """ + :keyword location: Required. Gets or sets the location. + :paramtype location: str + :keyword extended_location: Gets or sets the extended location. + :paramtype extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation + :keyword tags: A set of tags. Gets or sets the Resource tags. + :paramtype tags: dict[str, str] + :keyword kind: Metadata used by portal/tooling/etc to render different UX experiences for + resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, + the resource provider must validate and persist this value. + :paramtype kind: str + :keyword v_center_id: Gets or sets the ARM Id of the vCenter resource in which this template + resides. + :paramtype v_center_id: str + :keyword mo_ref_id: Gets or sets the vCenter MoRef (Managed Object Reference) ID for the + virtual machine + template. + :paramtype mo_ref_id: str + :keyword inventory_item_id: Gets or sets the inventory Item ID for the virtual machine + template. + :paramtype inventory_item_id: str + """ super(VirtualMachineTemplate, self).__init__(**kwargs) self.location = location self.extended_location = extended_location @@ -3440,33 +4089,33 @@ class VirtualMachineTemplateInventoryItem(InventoryItemProperties): All required parameters must be populated in order to send to Azure. - :param inventory_type: Required. They inventory type.Constant filled by server. Possible - values include: "ResourcePool", "VirtualMachine", "VirtualMachineTemplate", "VirtualNetwork", + :ivar inventory_type: Required. They inventory type.Constant filled by server. Possible values + include: "ResourcePool", "VirtualMachine", "VirtualMachineTemplate", "VirtualNetwork", "Cluster", "Datastore", "Host". - :type inventory_type: str or ~azure.mgmt.connectedvmware.models.InventoryType - :param managed_resource_id: Gets or sets the tracked resource id corresponding to the inventory + :vartype inventory_type: str or ~azure.mgmt.connectedvmware.models.InventoryType + :ivar managed_resource_id: Gets or sets the tracked resource id corresponding to the inventory resource. - :type managed_resource_id: str - :param mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory item. - :type mo_ref_id: str - :param mo_name: Gets or sets the vCenter Managed Object name for the inventory item. - :type mo_name: str + :vartype managed_resource_id: str + :ivar mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory item. + :vartype mo_ref_id: str + :ivar mo_name: Gets or sets the vCenter Managed Object name for the inventory item. + :vartype mo_name: str :ivar provisioning_state: Gets or sets the provisioning state. :vartype provisioning_state: str - :param memory_size_mb: Gets or sets memory size in MBs for the template. - :type memory_size_mb: int - :param num_cp_us: Gets or sets the number of vCPUs for the template. - :type num_cp_us: int - :param num_cores_per_socket: Gets or sets the number of cores per socket for the template. + :ivar memory_size_mb: Gets or sets memory size in MBs for the template. + :vartype memory_size_mb: int + :ivar num_cp_us: Gets or sets the number of vCPUs for the template. + :vartype num_cp_us: int + :ivar num_cores_per_socket: Gets or sets the number of cores per socket for the template. Defaults to 1 if unspecified. - :type num_cores_per_socket: int - :param os_type: Gets or sets the type of the os. Possible values include: "Windows", "Linux", + :vartype num_cores_per_socket: int + :ivar os_type: Gets or sets the type of the os. Possible values include: "Windows", "Linux", "Other". - :type os_type: str or ~azure.mgmt.connectedvmware.models.OsType - :param os_name: Gets or sets os name. - :type os_name: str - :param folder_path: Gets or sets the folder path of the template. - :type folder_path: str + :vartype os_type: str or ~azure.mgmt.connectedvmware.models.OsType + :ivar os_name: Gets or sets os name. + :vartype os_name: str + :ivar folder_path: Gets or sets the folder path of the template. + :vartype folder_path: str """ _validation = { @@ -3502,6 +4151,30 @@ def __init__( folder_path: Optional[str] = None, **kwargs ): + """ + :keyword managed_resource_id: Gets or sets the tracked resource id corresponding to the + inventory resource. + :paramtype managed_resource_id: str + :keyword mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory + item. + :paramtype mo_ref_id: str + :keyword mo_name: Gets or sets the vCenter Managed Object name for the inventory item. + :paramtype mo_name: str + :keyword memory_size_mb: Gets or sets memory size in MBs for the template. + :paramtype memory_size_mb: int + :keyword num_cp_us: Gets or sets the number of vCPUs for the template. + :paramtype num_cp_us: int + :keyword num_cores_per_socket: Gets or sets the number of cores per socket for the template. + Defaults to 1 if unspecified. + :paramtype num_cores_per_socket: int + :keyword os_type: Gets or sets the type of the os. Possible values include: "Windows", "Linux", + "Other". + :paramtype os_type: str or ~azure.mgmt.connectedvmware.models.OsType + :keyword os_name: Gets or sets os name. + :paramtype os_name: str + :keyword folder_path: Gets or sets the folder path of the template. + :paramtype folder_path: str + """ super(VirtualMachineTemplateInventoryItem, self).__init__(managed_resource_id=managed_resource_id, mo_ref_id=mo_ref_id, mo_name=mo_name, **kwargs) self.inventory_type = 'VirtualMachineTemplate' # type: str self.memory_size_mb = memory_size_mb @@ -3517,10 +4190,10 @@ class VirtualMachineTemplatesList(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param next_link: Url to follow for getting next page of VirtualMachineTemplates. - :type next_link: str - :param value: Required. Array of VirtualMachineTemplates. - :type value: list[~azure.mgmt.connectedvmware.models.VirtualMachineTemplate] + :ivar next_link: Url to follow for getting next page of VirtualMachineTemplates. + :vartype next_link: str + :ivar value: Required. Array of VirtualMachineTemplates. + :vartype value: list[~azure.mgmt.connectedvmware.models.VirtualMachineTemplate] """ _validation = { @@ -3539,6 +4212,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword next_link: Url to follow for getting next page of VirtualMachineTemplates. + :paramtype next_link: str + :keyword value: Required. Array of VirtualMachineTemplates. + :paramtype value: list[~azure.mgmt.connectedvmware.models.VirtualMachineTemplate] + """ super(VirtualMachineTemplatesList, self).__init__(**kwargs) self.next_link = next_link self.value = value @@ -3547,16 +4226,16 @@ def __init__( class VirtualMachineUpdate(msrest.serialization.Model): """Defines the virtualMachineUpdate. - :param tags: A set of tags. Gets or sets the Resource tags. - :type tags: dict[str, str] - :param identity: The identity of the resource. - :type identity: ~azure.mgmt.connectedvmware.models.Identity - :param hardware_profile: Defines the resource properties. - :type hardware_profile: ~azure.mgmt.connectedvmware.models.HardwareProfile - :param storage_profile: Defines the resource update properties. - :type storage_profile: ~azure.mgmt.connectedvmware.models.StorageProfileUpdate - :param network_profile: Defines the update resource properties. - :type network_profile: ~azure.mgmt.connectedvmware.models.NetworkProfileUpdate + :ivar tags: A set of tags. Gets or sets the Resource tags. + :vartype tags: dict[str, str] + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.connectedvmware.models.Identity + :ivar hardware_profile: Defines the resource properties. + :vartype hardware_profile: ~azure.mgmt.connectedvmware.models.HardwareProfile + :ivar storage_profile: Defines the resource update properties. + :vartype storage_profile: ~azure.mgmt.connectedvmware.models.StorageProfileUpdate + :ivar network_profile: Defines the update resource properties. + :vartype network_profile: ~azure.mgmt.connectedvmware.models.NetworkProfileUpdate """ _attribute_map = { @@ -3577,6 +4256,18 @@ def __init__( network_profile: Optional["NetworkProfileUpdate"] = None, **kwargs ): + """ + :keyword tags: A set of tags. Gets or sets the Resource tags. + :paramtype tags: dict[str, str] + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.connectedvmware.models.Identity + :keyword hardware_profile: Defines the resource properties. + :paramtype hardware_profile: ~azure.mgmt.connectedvmware.models.HardwareProfile + :keyword storage_profile: Defines the resource update properties. + :paramtype storage_profile: ~azure.mgmt.connectedvmware.models.StorageProfileUpdate + :keyword network_profile: Defines the update resource properties. + :paramtype network_profile: ~azure.mgmt.connectedvmware.models.NetworkProfileUpdate + """ super(VirtualMachineUpdate, self).__init__(**kwargs) self.tags = tags self.identity = identity @@ -3592,34 +4283,34 @@ class VirtualNetwork(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: Required. Gets or sets the location. - :type location: str - :param extended_location: Gets or sets the extended location. - :type extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation + :ivar location: Required. Gets or sets the location. + :vartype location: str + :ivar extended_location: Gets or sets the extended location. + :vartype extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation :ivar system_data: The system data. :vartype system_data: ~azure.mgmt.connectedvmware.models.SystemData - :param tags: A set of tags. Gets or sets the Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Gets or sets the Resource tags. + :vartype tags: dict[str, str] :ivar name: Gets or sets the name. :vartype name: str :ivar id: Gets or sets the Id. :vartype id: str :ivar type: Gets or sets the type of the resource. :vartype type: str - :param kind: Metadata used by portal/tooling/etc to render different UX experiences for + :ivar kind: Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, the resource provider must validate and persist this value. - :type kind: str + :vartype kind: str :ivar uuid: Gets or sets a unique identifier for this resource. :vartype uuid: str - :param v_center_id: Gets or sets the ARM Id of the vCenter resource in which this template + :ivar v_center_id: Gets or sets the ARM Id of the vCenter resource in which this template resides. - :type v_center_id: str - :param mo_ref_id: Gets or sets the vCenter MoRef (Managed Object Reference) ID for the virtual + :vartype v_center_id: str + :ivar mo_ref_id: Gets or sets the vCenter MoRef (Managed Object Reference) ID for the virtual network. - :type mo_ref_id: str - :param inventory_item_id: Gets or sets the inventory Item ID for the virtual network. - :type inventory_item_id: str + :vartype mo_ref_id: str + :ivar inventory_item_id: Gets or sets the inventory Item ID for the virtual network. + :vartype inventory_item_id: str :ivar mo_name: Gets or sets the vCenter Managed Object name for the virtual network. :vartype mo_name: str :ivar custom_resource_name: Gets the name of the corresponding resource in Kubernetes. @@ -3674,6 +4365,26 @@ def __init__( inventory_item_id: Optional[str] = None, **kwargs ): + """ + :keyword location: Required. Gets or sets the location. + :paramtype location: str + :keyword extended_location: Gets or sets the extended location. + :paramtype extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation + :keyword tags: A set of tags. Gets or sets the Resource tags. + :paramtype tags: dict[str, str] + :keyword kind: Metadata used by portal/tooling/etc to render different UX experiences for + resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, + the resource provider must validate and persist this value. + :paramtype kind: str + :keyword v_center_id: Gets or sets the ARM Id of the vCenter resource in which this template + resides. + :paramtype v_center_id: str + :keyword mo_ref_id: Gets or sets the vCenter MoRef (Managed Object Reference) ID for the + virtual network. + :paramtype mo_ref_id: str + :keyword inventory_item_id: Gets or sets the inventory Item ID for the virtual network. + :paramtype inventory_item_id: str + """ super(VirtualNetwork, self).__init__(**kwargs) self.location = location self.extended_location = extended_location @@ -3700,17 +4411,17 @@ class VirtualNetworkInventoryItem(InventoryItemProperties): All required parameters must be populated in order to send to Azure. - :param inventory_type: Required. They inventory type.Constant filled by server. Possible - values include: "ResourcePool", "VirtualMachine", "VirtualMachineTemplate", "VirtualNetwork", + :ivar inventory_type: Required. They inventory type.Constant filled by server. Possible values + include: "ResourcePool", "VirtualMachine", "VirtualMachineTemplate", "VirtualNetwork", "Cluster", "Datastore", "Host". - :type inventory_type: str or ~azure.mgmt.connectedvmware.models.InventoryType - :param managed_resource_id: Gets or sets the tracked resource id corresponding to the inventory + :vartype inventory_type: str or ~azure.mgmt.connectedvmware.models.InventoryType + :ivar managed_resource_id: Gets or sets the tracked resource id corresponding to the inventory resource. - :type managed_resource_id: str - :param mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory item. - :type mo_ref_id: str - :param mo_name: Gets or sets the vCenter Managed Object name for the inventory item. - :type mo_name: str + :vartype managed_resource_id: str + :ivar mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory item. + :vartype mo_ref_id: str + :ivar mo_name: Gets or sets the vCenter Managed Object name for the inventory item. + :vartype mo_name: str :ivar provisioning_state: Gets or sets the provisioning state. :vartype provisioning_state: str """ @@ -3736,6 +4447,16 @@ def __init__( mo_name: Optional[str] = None, **kwargs ): + """ + :keyword managed_resource_id: Gets or sets the tracked resource id corresponding to the + inventory resource. + :paramtype managed_resource_id: str + :keyword mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory + item. + :paramtype mo_ref_id: str + :keyword mo_name: Gets or sets the vCenter Managed Object name for the inventory item. + :paramtype mo_name: str + """ super(VirtualNetworkInventoryItem, self).__init__(managed_resource_id=managed_resource_id, mo_ref_id=mo_ref_id, mo_name=mo_name, **kwargs) self.inventory_type = 'VirtualNetwork' # type: str @@ -3745,10 +4466,10 @@ class VirtualNetworksList(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param next_link: Url to follow for getting next page of VirtualNetworks. - :type next_link: str - :param value: Required. Array of VirtualNetworks. - :type value: list[~azure.mgmt.connectedvmware.models.VirtualNetwork] + :ivar next_link: Url to follow for getting next page of VirtualNetworks. + :vartype next_link: str + :ivar value: Required. Array of VirtualNetworks. + :vartype value: list[~azure.mgmt.connectedvmware.models.VirtualNetwork] """ _validation = { @@ -3767,6 +4488,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword next_link: Url to follow for getting next page of VirtualNetworks. + :paramtype next_link: str + :keyword value: Required. Array of VirtualNetworks. + :paramtype value: list[~azure.mgmt.connectedvmware.models.VirtualNetwork] + """ super(VirtualNetworksList, self).__init__(**kwargs) self.next_link = next_link self.value = value @@ -3775,18 +4502,18 @@ def __init__( class VirtualSCSIController(msrest.serialization.Model): """This data object type contains the properties of a SCSI controller device attached to a virtual machine that is reported by the controller. - :param type: Gets or sets the controller type. Possible values include: "lsilogic", "buslogic", + :ivar type: Gets or sets the controller type. Possible values include: "lsilogic", "buslogic", "pvscsi", "lsilogicsas". - :type type: str or ~azure.mgmt.connectedvmware.models.SCSIControllerType - :param controller_key: Gets or sets the key of the controller. - :type controller_key: int - :param bus_number: Gets or sets the bus number of the controller. - :type bus_number: int - :param scsi_ctlr_unit_number: Gets or sets the SCSI controller unit number. - :type scsi_ctlr_unit_number: int - :param sharing: Gets or sets the sharing mode. Possible values include: "noSharing", + :vartype type: str or ~azure.mgmt.connectedvmware.models.SCSIControllerType + :ivar controller_key: Gets or sets the key of the controller. + :vartype controller_key: int + :ivar bus_number: Gets or sets the bus number of the controller. + :vartype bus_number: int + :ivar scsi_ctlr_unit_number: Gets or sets the SCSI controller unit number. + :vartype scsi_ctlr_unit_number: int + :ivar sharing: Gets or sets the sharing mode. Possible values include: "noSharing", "physicalSharing", "virtualSharing". - :type sharing: str or ~azure.mgmt.connectedvmware.models.VirtualSCSISharing + :vartype sharing: str or ~azure.mgmt.connectedvmware.models.VirtualSCSISharing """ _attribute_map = { @@ -3807,6 +4534,20 @@ def __init__( sharing: Optional[Union[str, "VirtualSCSISharing"]] = None, **kwargs ): + """ + :keyword type: Gets or sets the controller type. Possible values include: "lsilogic", + "buslogic", "pvscsi", "lsilogicsas". + :paramtype type: str or ~azure.mgmt.connectedvmware.models.SCSIControllerType + :keyword controller_key: Gets or sets the key of the controller. + :paramtype controller_key: int + :keyword bus_number: Gets or sets the bus number of the controller. + :paramtype bus_number: int + :keyword scsi_ctlr_unit_number: Gets or sets the SCSI controller unit number. + :paramtype scsi_ctlr_unit_number: int + :keyword sharing: Gets or sets the sharing mode. Possible values include: "noSharing", + "physicalSharing", "virtualSharing". + :paramtype sharing: str or ~azure.mgmt.connectedvmware.models.VirtualSCSISharing + """ super(VirtualSCSIController, self).__init__(**kwargs) self.type = type self.controller_key = controller_key diff --git a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_clusters_operations.py b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_clusters_operations.py index 5fa8af04a2c6..70cd435a6255 100644 --- a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_clusters_operations.py +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_clusters_operations.py @@ -5,25 +5,254 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_request_initial( + subscription_id: str, + resource_group_name: str, + cluster_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters/{clusterName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + cluster_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters/{clusterName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "clusterName": _SERIALIZER.url("cluster_name", cluster_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_update_request( + subscription_id: str, + resource_group_name: str, + cluster_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters/{clusterName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + cluster_name: str, + *, + force: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters/{clusterName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "clusterName": _SERIALIZER.url("cluster_name", cluster_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') + if force is not None: + query_parameters['force'] = _SERIALIZER.query("force", force, 'bool') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/clusters') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ClustersOperations(object): """ClustersOperations operations. @@ -49,53 +278,41 @@ def __init__(self, client, config, serializer, deserializer): def _create_initial( self, - resource_group_name, # type: str - cluster_name, # type: str - body=None, # type: Optional["_models.Cluster"] - **kwargs # type: Any - ): - # type: (...) -> "_models.Cluster" + resource_group_name: str, + cluster_name: str, + body: Optional["_models.Cluster"] = None, + **kwargs: Any + ) -> "_models.Cluster": cls = kwargs.pop('cls', None) # type: ClsType["_models.Cluster"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'Cluster') + _json = self._serialize.body(body, 'Cluster') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('Cluster', pipeline_response) @@ -107,16 +324,18 @@ def _create_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters/{clusterName}'} # type: ignore + + @distributed_trace def begin_create( self, - resource_group_name, # type: str - cluster_name, # type: str - body=None, # type: Optional["_models.Cluster"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Cluster"] + resource_group_name: str, + cluster_name: str, + body: Optional["_models.Cluster"] = None, + **kwargs: Any + ) -> LROPoller["_models.Cluster"]: """Implements cluster PUT method. Create Or Update cluster. @@ -129,15 +348,18 @@ def begin_create( :type body: ~azure.mgmt.connectedvmware.models.Cluster :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Cluster or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.connectedvmware.models.Cluster] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Cluster"] lro_delay = kwargs.pop( 'polling_interval', @@ -149,27 +371,21 @@ def begin_create( resource_group_name=resource_group_name, cluster_name=cluster_name, body=body, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('Cluster', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -181,15 +397,16 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters/{clusterName}'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - cluster_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Cluster" + resource_group_name: str, + cluster_name: str, + **kwargs: Any + ) -> "_models.Cluster": """Gets a cluster. Implements cluster GET method. @@ -208,33 +425,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Cluster', pipeline_response) @@ -243,16 +450,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters/{clusterName}'} # type: ignore + + @distributed_trace def update( self, - resource_group_name, # type: str - cluster_name, # type: str - body=None, # type: Optional["_models.ResourcePatch"] - **kwargs # type: Any - ): - # type: (...) -> "_models.Cluster" + resource_group_name: str, + cluster_name: str, + body: Optional["_models.ResourcePatch"] = None, + **kwargs: Any + ) -> "_models.Cluster": """Updates a cluster. API to update certain properties of the cluster resource. @@ -273,41 +482,31 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'ResourcePatch') + _json = self._serialize.body(body, 'ResourcePatch') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Cluster', pipeline_response) @@ -316,65 +515,55 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters/{clusterName}'} # type: ignore + def _delete_initial( self, - resource_group_name, # type: str - cluster_name, # type: str - force=None, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + cluster_name: str, + force: Optional[bool] = None, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if force is not None: - query_parameters['force'] = self._serialize.query("force", force, 'bool') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + force=force, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters/{clusterName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - cluster_name, # type: str - force=None, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + cluster_name: str, + force: Optional[bool] = None, + **kwargs: Any + ) -> LROPoller[None]: """Deletes an cluster. Implements cluster DELETE method. @@ -387,15 +576,17 @@ def begin_delete( :type force: bool :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -410,21 +601,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -436,13 +620,14 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters/{clusterName}'} # type: ignore + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ClustersList"] + **kwargs: Any + ) -> Iterable["_models.ClustersList"]: """Implements GET clusters in a subscription. List of clusters in a subscription. @@ -457,34 +642,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ClustersList', pipeline_response) + deserialized = self._deserialize("ClustersList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -497,23 +677,24 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/clusters'} # type: ignore + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ClustersList"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.ClustersList"]: """Implements GET clusters in a resource group. List of clusters in a resource group. @@ -530,35 +711,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ClustersList', pipeline_response) + deserialized = self._deserialize("ClustersList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -571,12 +748,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_datastores_operations.py b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_datastores_operations.py index d5f88939bed4..8ffd530a6550 100644 --- a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_datastores_operations.py +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_datastores_operations.py @@ -5,25 +5,254 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_request_initial( + subscription_id: str, + resource_group_name: str, + datastore_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores/{datastoreName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "datastoreName": _SERIALIZER.url("datastore_name", datastore_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + datastore_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores/{datastoreName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "datastoreName": _SERIALIZER.url("datastore_name", datastore_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_update_request( + subscription_id: str, + resource_group_name: str, + datastore_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores/{datastoreName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "datastoreName": _SERIALIZER.url("datastore_name", datastore_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + datastore_name: str, + *, + force: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores/{datastoreName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "datastoreName": _SERIALIZER.url("datastore_name", datastore_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') + if force is not None: + query_parameters['force'] = _SERIALIZER.query("force", force, 'bool') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/datastores') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class DatastoresOperations(object): """DatastoresOperations operations. @@ -49,53 +278,41 @@ def __init__(self, client, config, serializer, deserializer): def _create_initial( self, - resource_group_name, # type: str - datastore_name, # type: str - body=None, # type: Optional["_models.Datastore"] - **kwargs # type: Any - ): - # type: (...) -> "_models.Datastore" + resource_group_name: str, + datastore_name: str, + body: Optional["_models.Datastore"] = None, + **kwargs: Any + ) -> "_models.Datastore": cls = kwargs.pop('cls', None) # type: ClsType["_models.Datastore"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'datastoreName': self._serialize.url("datastore_name", datastore_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'Datastore') + _json = self._serialize.body(body, 'Datastore') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + datastore_name=datastore_name, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('Datastore', pipeline_response) @@ -107,16 +324,18 @@ def _create_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores/{datastoreName}'} # type: ignore + + @distributed_trace def begin_create( self, - resource_group_name, # type: str - datastore_name, # type: str - body=None, # type: Optional["_models.Datastore"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Datastore"] + resource_group_name: str, + datastore_name: str, + body: Optional["_models.Datastore"] = None, + **kwargs: Any + ) -> LROPoller["_models.Datastore"]: """Implements datastore PUT method. Create Or Update datastore. @@ -129,15 +348,18 @@ def begin_create( :type body: ~azure.mgmt.connectedvmware.models.Datastore :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Datastore or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.connectedvmware.models.Datastore] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Datastore"] lro_delay = kwargs.pop( 'polling_interval', @@ -149,27 +371,21 @@ def begin_create( resource_group_name=resource_group_name, datastore_name=datastore_name, body=body, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('Datastore', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'datastoreName': self._serialize.url("datastore_name", datastore_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -181,15 +397,16 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores/{datastoreName}'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - datastore_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Datastore" + resource_group_name: str, + datastore_name: str, + **kwargs: Any + ) -> "_models.Datastore": """Gets a datastore. Implements datastore GET method. @@ -208,33 +425,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'datastoreName': self._serialize.url("datastore_name", datastore_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + datastore_name=datastore_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Datastore', pipeline_response) @@ -243,16 +450,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores/{datastoreName}'} # type: ignore + + @distributed_trace def update( self, - resource_group_name, # type: str - datastore_name, # type: str - body=None, # type: Optional["_models.ResourcePatch"] - **kwargs # type: Any - ): - # type: (...) -> "_models.Datastore" + resource_group_name: str, + datastore_name: str, + body: Optional["_models.ResourcePatch"] = None, + **kwargs: Any + ) -> "_models.Datastore": """Updates a datastore. API to update certain properties of the datastore resource. @@ -273,41 +482,31 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'datastoreName': self._serialize.url("datastore_name", datastore_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'ResourcePatch') + _json = self._serialize.body(body, 'ResourcePatch') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + datastore_name=datastore_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Datastore', pipeline_response) @@ -316,65 +515,55 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores/{datastoreName}'} # type: ignore + def _delete_initial( self, - resource_group_name, # type: str - datastore_name, # type: str - force=None, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + datastore_name: str, + force: Optional[bool] = None, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'datastoreName': self._serialize.url("datastore_name", datastore_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if force is not None: - query_parameters['force'] = self._serialize.query("force", force, 'bool') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + datastore_name=datastore_name, + force=force, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores/{datastoreName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - datastore_name, # type: str - force=None, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + datastore_name: str, + force: Optional[bool] = None, + **kwargs: Any + ) -> LROPoller[None]: """Deletes an datastore. Implements datastore DELETE method. @@ -387,15 +576,17 @@ def begin_delete( :type force: bool :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -410,21 +601,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'datastoreName': self._serialize.url("datastore_name", datastore_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -436,13 +620,14 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores/{datastoreName}'} # type: ignore + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DatastoresList"] + **kwargs: Any + ) -> Iterable["_models.DatastoresList"]: """Implements GET datastores in a subscription. List of datastores in a subscription. @@ -457,34 +642,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DatastoresList', pipeline_response) + deserialized = self._deserialize("DatastoresList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -497,23 +677,24 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/datastores'} # type: ignore + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DatastoresList"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.DatastoresList"]: """Implements GET datastores in a resource group. List of datastores in a resource group. @@ -530,35 +711,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DatastoresList', pipeline_response) + deserialized = self._deserialize("DatastoresList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -571,12 +748,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_guest_agents_operations.py b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_guest_agents_operations.py index 07d175b6d9ca..f98c93dd0933 100644 --- a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_guest_agents_operations.py +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_guest_agents_operations.py @@ -5,25 +5,183 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_request_initial( + subscription_id: str, + resource_group_name: str, + virtual_machine_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/guestAgents/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_name, 'str'), + "name": _SERIALIZER.url("name", name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + virtual_machine_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/guestAgents/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_name, 'str'), + "name": _SERIALIZER.url("name", name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + virtual_machine_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/guestAgents/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_name, 'str'), + "name": _SERIALIZER.url("name", name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_vm_request( + subscription_id: str, + resource_group_name: str, + virtual_machine_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/guestAgents') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class GuestAgentsOperations(object): """GuestAgentsOperations operations. @@ -49,55 +207,43 @@ def __init__(self, client, config, serializer, deserializer): def _create_initial( self, - resource_group_name, # type: str - virtual_machine_name, # type: str - name, # type: str - body=None, # type: Optional["_models.GuestAgent"] - **kwargs # type: Any - ): - # type: (...) -> "_models.GuestAgent" + resource_group_name: str, + virtual_machine_name: str, + name: str, + body: Optional["_models.GuestAgent"] = None, + **kwargs: Any + ) -> "_models.GuestAgent": cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestAgent"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'GuestAgent') + _json = self._serialize.body(body, 'GuestAgent') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + name=name, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('GuestAgent', pipeline_response) @@ -109,17 +255,19 @@ def _create_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/guestAgents/{name}'} # type: ignore + + @distributed_trace def begin_create( self, - resource_group_name, # type: str - virtual_machine_name, # type: str - name, # type: str - body=None, # type: Optional["_models.GuestAgent"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.GuestAgent"] + resource_group_name: str, + virtual_machine_name: str, + name: str, + body: Optional["_models.GuestAgent"] = None, + **kwargs: Any + ) -> LROPoller["_models.GuestAgent"]: """Implements GuestAgent PUT method. Create Or Update GuestAgent. @@ -134,15 +282,18 @@ def begin_create( :type body: ~azure.mgmt.connectedvmware.models.GuestAgent :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either GuestAgent or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.connectedvmware.models.GuestAgent] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestAgent"] lro_delay = kwargs.pop( 'polling_interval', @@ -155,28 +306,21 @@ def begin_create( virtual_machine_name=virtual_machine_name, name=name, body=body, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('GuestAgent', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -188,16 +332,17 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/guestAgents/{name}'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - virtual_machine_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.GuestAgent" + resource_group_name: str, + virtual_machine_name: str, + name: str, + **kwargs: Any + ) -> "_models.GuestAgent": """Gets GuestAgent. Implements GuestAgent GET method. @@ -218,34 +363,24 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + name=name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('GuestAgent', pipeline_response) @@ -254,64 +389,55 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/guestAgents/{name}'} # type: ignore + def _delete_initial( self, - resource_group_name, # type: str - virtual_machine_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + virtual_machine_name: str, + name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + name=name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/guestAgents/{name}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - virtual_machine_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + virtual_machine_name: str, + name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes an GuestAgent. Implements GuestAgent DELETE method. @@ -324,15 +450,17 @@ def begin_delete( :type name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -347,22 +475,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -374,15 +494,16 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/guestAgents/{name}'} # type: ignore + @distributed_trace def list_by_vm( self, - resource_group_name, # type: str - virtual_machine_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.GuestAgentList"] + resource_group_name: str, + virtual_machine_name: str, + **kwargs: Any + ) -> Iterable["_models.GuestAgentList"]: """Implements GET GuestAgent in a vm. Returns the list of GuestAgent of the given vm. @@ -401,36 +522,33 @@ def list_by_vm( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_vm.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - 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_vm_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + template_url=self.list_by_vm.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(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_vm_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_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('GuestAgentList', pipeline_response) + deserialized = self._deserialize("GuestAgentList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -443,12 +561,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_hosts_operations.py b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_hosts_operations.py index 94d7caa8278c..ba0ec4174a98 100644 --- a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_hosts_operations.py +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_hosts_operations.py @@ -5,25 +5,254 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_request_initial( + subscription_id: str, + resource_group_name: str, + host_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts/{hostName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "hostName": _SERIALIZER.url("host_name", host_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + host_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts/{hostName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "hostName": _SERIALIZER.url("host_name", host_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_update_request( + subscription_id: str, + resource_group_name: str, + host_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts/{hostName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "hostName": _SERIALIZER.url("host_name", host_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + host_name: str, + *, + force: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts/{hostName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "hostName": _SERIALIZER.url("host_name", host_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') + if force is not None: + query_parameters['force'] = _SERIALIZER.query("force", force, 'bool') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/hosts') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class HostsOperations(object): """HostsOperations operations. @@ -49,53 +278,41 @@ def __init__(self, client, config, serializer, deserializer): def _create_initial( self, - resource_group_name, # type: str - host_name, # type: str - body=None, # type: Optional["_models.Host"] - **kwargs # type: Any - ): - # type: (...) -> "_models.Host" + resource_group_name: str, + host_name: str, + body: Optional["_models.Host"] = None, + **kwargs: Any + ) -> "_models.Host": cls = kwargs.pop('cls', None) # type: ClsType["_models.Host"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'hostName': self._serialize.url("host_name", host_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'Host') + _json = self._serialize.body(body, 'Host') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + host_name=host_name, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('Host', pipeline_response) @@ -107,16 +324,18 @@ def _create_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts/{hostName}'} # type: ignore + + @distributed_trace def begin_create( self, - resource_group_name, # type: str - host_name, # type: str - body=None, # type: Optional["_models.Host"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Host"] + resource_group_name: str, + host_name: str, + body: Optional["_models.Host"] = None, + **kwargs: Any + ) -> LROPoller["_models.Host"]: """Implements host PUT method. Create Or Update host. @@ -129,15 +348,18 @@ def begin_create( :type body: ~azure.mgmt.connectedvmware.models.Host :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either Host or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.connectedvmware.models.Host] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.Host"] lro_delay = kwargs.pop( 'polling_interval', @@ -149,27 +371,21 @@ def begin_create( resource_group_name=resource_group_name, host_name=host_name, body=body, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('Host', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'hostName': self._serialize.url("host_name", host_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -181,15 +397,16 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts/{hostName}'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - host_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Host" + resource_group_name: str, + host_name: str, + **kwargs: Any + ) -> "_models.Host": """Gets a host. Implements host GET method. @@ -208,33 +425,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'hostName': self._serialize.url("host_name", host_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + host_name=host_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Host', pipeline_response) @@ -243,16 +450,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts/{hostName}'} # type: ignore + + @distributed_trace def update( self, - resource_group_name, # type: str - host_name, # type: str - body=None, # type: Optional["_models.ResourcePatch"] - **kwargs # type: Any - ): - # type: (...) -> "_models.Host" + resource_group_name: str, + host_name: str, + body: Optional["_models.ResourcePatch"] = None, + **kwargs: Any + ) -> "_models.Host": """Updates a host. API to update certain properties of the host resource. @@ -273,41 +482,31 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'hostName': self._serialize.url("host_name", host_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'ResourcePatch') + _json = self._serialize.body(body, 'ResourcePatch') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + host_name=host_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Host', pipeline_response) @@ -316,65 +515,55 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts/{hostName}'} # type: ignore + def _delete_initial( self, - resource_group_name, # type: str - host_name, # type: str - force=None, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + host_name: str, + force: Optional[bool] = None, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'hostName': self._serialize.url("host_name", host_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if force is not None: - query_parameters['force'] = self._serialize.query("force", force, 'bool') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + host_name=host_name, + force=force, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts/{hostName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - host_name, # type: str - force=None, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + host_name: str, + force: Optional[bool] = None, + **kwargs: Any + ) -> LROPoller[None]: """Deletes an host. Implements host DELETE method. @@ -387,15 +576,17 @@ def begin_delete( :type force: bool :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -410,21 +601,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'hostName': self._serialize.url("host_name", host_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -436,13 +620,14 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts/{hostName}'} # type: ignore + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.HostsList"] + **kwargs: Any + ) -> Iterable["_models.HostsList"]: """Implements GET hosts in a subscription. List of hosts in a subscription. @@ -457,34 +642,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('HostsList', pipeline_response) + deserialized = self._deserialize("HostsList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -497,23 +677,24 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/hosts'} # type: ignore + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.HostsList"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.HostsList"]: """Implements GET hosts in a resource group. List of hosts in a resource group. @@ -530,35 +711,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('HostsList', pipeline_response) + deserialized = self._deserialize("HostsList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -571,12 +748,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_hybrid_identity_metadata_operations.py b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_hybrid_identity_metadata_operations.py index 3c9de2f08687..217c01856141 100644 --- a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_hybrid_identity_metadata_operations.py +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_hybrid_identity_metadata_operations.py @@ -5,23 +5,181 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_request( + subscription_id: str, + resource_group_name: str, + virtual_machine_name: str, + metadata_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/hybridIdentityMetadata/{metadataName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_name, 'str'), + "metadataName": _SERIALIZER.url("metadata_name", metadata_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + virtual_machine_name: str, + metadata_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/hybridIdentityMetadata/{metadataName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_name, 'str'), + "metadataName": _SERIALIZER.url("metadata_name", metadata_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + virtual_machine_name: str, + metadata_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/hybridIdentityMetadata/{metadataName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_name, 'str'), + "metadataName": _SERIALIZER.url("metadata_name", metadata_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_by_vm_request( + subscription_id: str, + resource_group_name: str, + virtual_machine_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/hybridIdentityMetadata') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class HybridIdentityMetadataOperations(object): """HybridIdentityMetadataOperations operations. @@ -45,15 +203,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def create( self, - resource_group_name, # type: str - virtual_machine_name, # type: str - metadata_name, # type: str - body=None, # type: Optional["_models.HybridIdentityMetadata"] - **kwargs # type: Any - ): - # type: (...) -> "_models.HybridIdentityMetadata" + resource_group_name: str, + virtual_machine_name: str, + metadata_name: str, + body: Optional["_models.HybridIdentityMetadata"] = None, + **kwargs: Any + ) -> "_models.HybridIdentityMetadata": """Implements HybridIdentityMetadata PUT method. Create Or Update HybridIdentityMetadata. @@ -76,42 +234,32 @@ def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - 'metadataName': self._serialize.url("metadata_name", metadata_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'HybridIdentityMetadata') + _json = self._serialize.body(body, 'HybridIdentityMetadata') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_create_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + metadata_name=metadata_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('HybridIdentityMetadata', pipeline_response) @@ -120,16 +268,18 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/hybridIdentityMetadata/{metadataName}'} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - virtual_machine_name, # type: str - metadata_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.HybridIdentityMetadata" + resource_group_name: str, + virtual_machine_name: str, + metadata_name: str, + **kwargs: Any + ) -> "_models.HybridIdentityMetadata": """Gets HybridIdentityMetadata. Implements HybridIdentityMetadata GET method. @@ -150,34 +300,24 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - 'metadataName': self._serialize.url("metadata_name", metadata_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + metadata_name=metadata_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('HybridIdentityMetadata', pipeline_response) @@ -186,16 +326,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/hybridIdentityMetadata/{metadataName}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - virtual_machine_name, # type: str - metadata_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + virtual_machine_name: str, + metadata_name: str, + **kwargs: Any + ) -> None: """Deletes an HybridIdentityMetadata. Implements HybridIdentityMetadata DELETE method. @@ -216,34 +358,24 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - 'metadataName': self._serialize.url("metadata_name", metadata_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + metadata_name=metadata_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -251,13 +383,14 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/hybridIdentityMetadata/{metadataName}'} # type: ignore + + @distributed_trace def list_by_vm( self, - resource_group_name, # type: str - virtual_machine_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.HybridIdentityMetadataList"] + resource_group_name: str, + virtual_machine_name: str, + **kwargs: Any + ) -> Iterable["_models.HybridIdentityMetadataList"]: """Implements GET HybridIdentityMetadata in a vm. Returns the list of HybridIdentityMetadata of the given vm. @@ -267,8 +400,10 @@ def list_by_vm( :param virtual_machine_name: Name of the vm. :type virtual_machine_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either HybridIdentityMetadataList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.connectedvmware.models.HybridIdentityMetadataList] + :return: An iterator like instance of either HybridIdentityMetadataList or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.connectedvmware.models.HybridIdentityMetadataList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.HybridIdentityMetadataList"] @@ -276,36 +411,33 @@ def list_by_vm( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_vm.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - 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_vm_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + template_url=self.list_by_vm.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(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_vm_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_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('HybridIdentityMetadataList', pipeline_response) + deserialized = self._deserialize("HybridIdentityMetadataList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -318,12 +450,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_inventory_items_operations.py b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_inventory_items_operations.py index 1cdcbb485fcc..e4d9a3d7ec57 100644 --- a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_inventory_items_operations.py +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_inventory_items_operations.py @@ -5,23 +5,181 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_request( + subscription_id: str, + resource_group_name: str, + vcenter_name: str, + inventory_item_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}/inventoryItems/{inventoryItemName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "vcenterName": _SERIALIZER.url("vcenter_name", vcenter_name, 'str'), + "inventoryItemName": _SERIALIZER.url("inventory_item_name", inventory_item_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + vcenter_name: str, + inventory_item_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}/inventoryItems/{inventoryItemName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "vcenterName": _SERIALIZER.url("vcenter_name", vcenter_name, 'str'), + "inventoryItemName": _SERIALIZER.url("inventory_item_name", inventory_item_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + vcenter_name: str, + inventory_item_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}/inventoryItems/{inventoryItemName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "vcenterName": _SERIALIZER.url("vcenter_name", vcenter_name, 'str'), + "inventoryItemName": _SERIALIZER.url("inventory_item_name", inventory_item_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_by_v_center_request( + subscription_id: str, + resource_group_name: str, + vcenter_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}/inventoryItems') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "vcenterName": _SERIALIZER.url("vcenter_name", vcenter_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class InventoryItemsOperations(object): """InventoryItemsOperations operations. @@ -45,15 +203,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def create( self, - resource_group_name, # type: str - vcenter_name, # type: str - inventory_item_name, # type: str - body=None, # type: Optional["_models.InventoryItem"] - **kwargs # type: Any - ): - # type: (...) -> "_models.InventoryItem" + resource_group_name: str, + vcenter_name: str, + inventory_item_name: str, + body: Optional["_models.InventoryItem"] = None, + **kwargs: Any + ) -> "_models.InventoryItem": """Implements InventoryItem PUT method. Create Or Update InventoryItem. @@ -76,42 +234,32 @@ def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'vcenterName': self._serialize.url("vcenter_name", vcenter_name, 'str'), - 'inventoryItemName': self._serialize.url("inventory_item_name", inventory_item_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'InventoryItem') + _json = self._serialize.body(body, 'InventoryItem') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_create_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vcenter_name=vcenter_name, + inventory_item_name=inventory_item_name, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('InventoryItem', pipeline_response) @@ -120,16 +268,18 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}/inventoryItems/{inventoryItemName}'} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - vcenter_name, # type: str - inventory_item_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.InventoryItem" + resource_group_name: str, + vcenter_name: str, + inventory_item_name: str, + **kwargs: Any + ) -> "_models.InventoryItem": """Gets InventoryItem. Implements InventoryItem GET method. @@ -150,34 +300,24 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'vcenterName': self._serialize.url("vcenter_name", vcenter_name, 'str'), - 'inventoryItemName': self._serialize.url("inventory_item_name", inventory_item_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vcenter_name=vcenter_name, + inventory_item_name=inventory_item_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('InventoryItem', pipeline_response) @@ -186,16 +326,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}/inventoryItems/{inventoryItemName}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - vcenter_name, # type: str - inventory_item_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + vcenter_name: str, + inventory_item_name: str, + **kwargs: Any + ) -> None: """Deletes an inventoryItem. Implements inventoryItem DELETE method. @@ -216,34 +358,24 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'vcenterName': self._serialize.url("vcenter_name", vcenter_name, 'str'), - 'inventoryItemName': self._serialize.url("inventory_item_name", inventory_item_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vcenter_name=vcenter_name, + inventory_item_name=inventory_item_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -251,13 +383,14 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}/inventoryItems/{inventoryItemName}'} # type: ignore + + @distributed_trace def list_by_v_center( self, - resource_group_name, # type: str - vcenter_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.InventoryItemsList"] + resource_group_name: str, + vcenter_name: str, + **kwargs: Any + ) -> Iterable["_models.InventoryItemsList"]: """Implements GET inventoryItems in a vCenter. Returns the list of inventoryItems of the given vCenter. @@ -276,36 +409,33 @@ def list_by_v_center( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_v_center.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'vcenterName': self._serialize.url("vcenter_name", vcenter_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - 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_v_center_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vcenter_name=vcenter_name, + template_url=self.list_by_v_center.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(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_v_center_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vcenter_name=vcenter_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('InventoryItemsList', pipeline_response) + deserialized = self._deserialize("InventoryItemsList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -318,12 +448,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_machine_extensions_operations.py b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_machine_extensions_operations.py index cb85d62c88c5..6ab9420826d2 100644 --- a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_machine_extensions_operations.py +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_machine_extensions_operations.py @@ -5,25 +5,233 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + name: str, + extension_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "name": _SERIALIZER.url("name", name, 'str'), + "extensionName": _SERIALIZER.url("extension_name", extension_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request_initial( + subscription_id: str, + resource_group_name: str, + name: str, + extension_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "name": _SERIALIZER.url("name", name, 'str'), + "extensionName": _SERIALIZER.url("extension_name", extension_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + name: str, + extension_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "name": _SERIALIZER.url("name", name, 'str'), + "extensionName": _SERIALIZER.url("extension_name", extension_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_get_request( + subscription_id: str, + resource_group_name: str, + name: str, + extension_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "name": _SERIALIZER.url("name", name, 'str'), + "extensionName": _SERIALIZER.url("extension_name", extension_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + resource_group_name: str, + name: str, + *, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "name": _SERIALIZER.url("name", name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: 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 MachineExtensionsOperations(object): """MachineExtensionsOperations operations. @@ -49,52 +257,40 @@ def __init__(self, client, config, serializer, deserializer): def _create_or_update_initial( self, - resource_group_name, # type: str - name, # type: str - extension_name, # type: str - extension_parameters, # type: "_models.MachineExtension" - **kwargs # type: Any - ): - # type: (...) -> "_models.MachineExtension" + resource_group_name: str, + name: str, + extension_name: str, + extension_parameters: "_models.MachineExtension", + **kwargs: Any + ) -> "_models.MachineExtension": cls = kwargs.pop('cls', None) # type: ClsType["_models.MachineExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'extensionName': self._serialize.url("extension_name", extension_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(extension_parameters, 'MachineExtension') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + extension_name=extension_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(extension_parameters, 'MachineExtension') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('MachineExtension', pipeline_response) @@ -106,17 +302,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - name, # type: str - extension_name, # type: str - extension_parameters, # type: "_models.MachineExtension" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.MachineExtension"] + resource_group_name: str, + name: str, + extension_name: str, + extension_parameters: "_models.MachineExtension", + **kwargs: Any + ) -> LROPoller["_models.MachineExtension"]: """The operation to create or update the extension. :param resource_group_name: The Resource Group Name. @@ -129,15 +327,19 @@ def begin_create_or_update( :type extension_parameters: ~azure.mgmt.connectedvmware.models.MachineExtension :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either MachineExtension 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 MachineExtension or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.connectedvmware.models.MachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.MachineExtension"] lro_delay = kwargs.pop( 'polling_interval', @@ -150,28 +352,21 @@ def begin_create_or_update( name=name, extension_name=extension_name, extension_parameters=extension_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('MachineExtension', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'extensionName': self._serialize.url("extension_name", extension_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -183,56 +378,45 @@ 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.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}'} # type: ignore def _update_initial( self, - resource_group_name, # type: str - name, # type: str - extension_name, # type: str - extension_parameters, # type: "_models.MachineExtensionUpdate" - **kwargs # type: Any - ): - # type: (...) -> "_models.MachineExtension" + resource_group_name: str, + name: str, + extension_name: str, + extension_parameters: "_models.MachineExtensionUpdate", + **kwargs: Any + ) -> "_models.MachineExtension": cls = kwargs.pop('cls', None) # type: ClsType["_models.MachineExtension"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'extensionName': self._serialize.url("extension_name", extension_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(extension_parameters, 'MachineExtensionUpdate') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + extension_name=extension_name, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(extension_parameters, 'MachineExtensionUpdate') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('MachineExtension', pipeline_response) @@ -244,17 +428,19 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}'} # type: ignore + + @distributed_trace def begin_update( self, - resource_group_name, # type: str - name, # type: str - extension_name, # type: str - extension_parameters, # type: "_models.MachineExtensionUpdate" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.MachineExtension"] + resource_group_name: str, + name: str, + extension_name: str, + extension_parameters: "_models.MachineExtensionUpdate", + **kwargs: Any + ) -> LROPoller["_models.MachineExtension"]: """The operation to update the extension. :param resource_group_name: The Resource Group Name. @@ -267,15 +453,19 @@ def begin_update( :type extension_parameters: ~azure.mgmt.connectedvmware.models.MachineExtensionUpdate :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either MachineExtension 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 MachineExtension or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.connectedvmware.models.MachineExtension] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.MachineExtension"] lro_delay = kwargs.pop( 'polling_interval', @@ -288,28 +478,21 @@ def begin_update( name=name, extension_name=extension_name, extension_parameters=extension_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('MachineExtension', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'extensionName': self._serialize.url("extension_name", extension_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -321,64 +504,54 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - name, # type: str - extension_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + name: str, + extension_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'extensionName': self._serialize.url("extension_name", extension_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + extension_name=extension_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - name, # type: str - extension_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + name: str, + extension_name: str, + **kwargs: Any + ) -> LROPoller[None]: """The operation to delete the extension. :param resource_group_name: The Resource Group Name. @@ -389,15 +562,17 @@ def begin_delete( :type extension_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -412,22 +587,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'extensionName': self._serialize.url("extension_name", extension_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -439,16 +606,17 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - name, # type: str - extension_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.MachineExtension" + resource_group_name: str, + name: str, + extension_name: str, + **kwargs: Any + ) -> "_models.MachineExtension": """The operation to get the extension. :param resource_group_name: The Resource Group Name. @@ -467,34 +635,24 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - 'extensionName': self._serialize.url("extension_name", extension_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + extension_name=extension_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('MachineExtension', pipeline_response) @@ -503,16 +661,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}'} # type: ignore + + @distributed_trace def list( self, - resource_group_name, # type: str - name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.MachineExtensionsListResult"] + resource_group_name: str, + name: str, + expand: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.MachineExtensionsListResult"]: """The operation to get all extensions of a non-Azure machine. :param resource_group_name: The Resource Group Name. @@ -522,8 +682,10 @@ def list( :param expand: The expand expression to apply on the operation. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MachineExtensionsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.connectedvmware.models.MachineExtensionsListResult] + :return: An iterator like instance of either MachineExtensionsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.connectedvmware.models.MachineExtensionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.MachineExtensionsListResult"] @@ -531,38 +693,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + expand=expand, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + expand=expand, + 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('MachineExtensionsListResult', pipeline_response) + deserialized = self._deserialize("MachineExtensionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -575,12 +734,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_operations.py b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_operations.py index d9ee0445a02d..7cbeb25b8823 100644 --- a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_operations.py +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/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 ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.ConnectedVMwarevSphere/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. @@ -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.OperationsList"] + **kwargs: Any + ) -> Iterable["_models.OperationsList"]: """Returns list of all operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -62,30 +89,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # 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('OperationsList', pipeline_response) + deserialized = self._deserialize("OperationsList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,12 +122,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_resource_pools_operations.py b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_resource_pools_operations.py index 5a7f67c6035c..41aa5b7e5759 100644 --- a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_resource_pools_operations.py +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_resource_pools_operations.py @@ -5,25 +5,254 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_request_initial( + subscription_id: str, + resource_group_name: str, + resource_pool_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools/{resourcePoolName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "resourcePoolName": _SERIALIZER.url("resource_pool_name", resource_pool_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + resource_pool_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools/{resourcePoolName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "resourcePoolName": _SERIALIZER.url("resource_pool_name", resource_pool_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_update_request( + subscription_id: str, + resource_group_name: str, + resource_pool_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools/{resourcePoolName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "resourcePoolName": _SERIALIZER.url("resource_pool_name", resource_pool_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + resource_pool_name: str, + *, + force: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools/{resourcePoolName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "resourcePoolName": _SERIALIZER.url("resource_pool_name", resource_pool_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') + if force is not None: + query_parameters['force'] = _SERIALIZER.query("force", force, 'bool') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ResourcePoolsOperations(object): """ResourcePoolsOperations operations. @@ -49,53 +278,41 @@ def __init__(self, client, config, serializer, deserializer): def _create_initial( self, - resource_group_name, # type: str - resource_pool_name, # type: str - body=None, # type: Optional["_models.ResourcePool"] - **kwargs # type: Any - ): - # type: (...) -> "_models.ResourcePool" + resource_group_name: str, + resource_pool_name: str, + body: Optional["_models.ResourcePool"] = None, + **kwargs: Any + ) -> "_models.ResourcePool": cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourcePool"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourcePoolName': self._serialize.url("resource_pool_name", resource_pool_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'ResourcePool') + _json = self._serialize.body(body, 'ResourcePool') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_pool_name=resource_pool_name, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('ResourcePool', pipeline_response) @@ -107,16 +324,18 @@ def _create_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools/{resourcePoolName}'} # type: ignore + + @distributed_trace def begin_create( self, - resource_group_name, # type: str - resource_pool_name, # type: str - body=None, # type: Optional["_models.ResourcePool"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ResourcePool"] + resource_group_name: str, + resource_pool_name: str, + body: Optional["_models.ResourcePool"] = None, + **kwargs: Any + ) -> LROPoller["_models.ResourcePool"]: """Implements resourcePool PUT method. Create Or Update resourcePool. @@ -129,15 +348,19 @@ def begin_create( :type body: ~azure.mgmt.connectedvmware.models.ResourcePool :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either ResourcePool 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 ResourcePool or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.connectedvmware.models.ResourcePool] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourcePool"] lro_delay = kwargs.pop( 'polling_interval', @@ -149,27 +372,21 @@ def begin_create( resource_group_name=resource_group_name, resource_pool_name=resource_pool_name, body=body, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ResourcePool', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourcePoolName': self._serialize.url("resource_pool_name", resource_pool_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -181,15 +398,16 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools/{resourcePoolName}'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - resource_pool_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ResourcePool" + resource_group_name: str, + resource_pool_name: str, + **kwargs: Any + ) -> "_models.ResourcePool": """Gets a resourcePool. Implements resourcePool GET method. @@ -208,33 +426,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourcePoolName': self._serialize.url("resource_pool_name", resource_pool_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_pool_name=resource_pool_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ResourcePool', pipeline_response) @@ -243,16 +451,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools/{resourcePoolName}'} # type: ignore + + @distributed_trace def update( self, - resource_group_name, # type: str - resource_pool_name, # type: str - body=None, # type: Optional["_models.ResourcePatch"] - **kwargs # type: Any - ): - # type: (...) -> "_models.ResourcePool" + resource_group_name: str, + resource_pool_name: str, + body: Optional["_models.ResourcePatch"] = None, + **kwargs: Any + ) -> "_models.ResourcePool": """Updates a resourcePool. API to update certain properties of the resourcePool resource. @@ -273,41 +483,31 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourcePoolName': self._serialize.url("resource_pool_name", resource_pool_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'ResourcePatch') + _json = self._serialize.body(body, 'ResourcePatch') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_pool_name=resource_pool_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ResourcePool', pipeline_response) @@ -316,65 +516,55 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools/{resourcePoolName}'} # type: ignore + def _delete_initial( self, - resource_group_name, # type: str - resource_pool_name, # type: str - force=None, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + resource_pool_name: str, + force: Optional[bool] = None, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourcePoolName': self._serialize.url("resource_pool_name", resource_pool_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if force is not None: - query_parameters['force'] = self._serialize.query("force", force, 'bool') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_pool_name=resource_pool_name, + force=force, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools/{resourcePoolName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - resource_pool_name, # type: str - force=None, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + resource_pool_name: str, + force: Optional[bool] = None, + **kwargs: Any + ) -> LROPoller[None]: """Deletes an resourcePool. Implements resourcePool DELETE method. @@ -387,15 +577,17 @@ def begin_delete( :type force: bool :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -410,21 +602,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourcePoolName': self._serialize.url("resource_pool_name", resource_pool_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -436,13 +621,14 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools/{resourcePoolName}'} # type: ignore + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ResourcePoolsList"] + **kwargs: Any + ) -> Iterable["_models.ResourcePoolsList"]: """Implements GET resourcePools in a subscription. List of resourcePools in a subscription. @@ -457,34 +643,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ResourcePoolsList', pipeline_response) + deserialized = self._deserialize("ResourcePoolsList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -497,23 +678,24 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools'} # type: ignore + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ResourcePoolsList"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.ResourcePoolsList"]: """Implements GET resourcePools in a resource group. List of resourcePools in a resource group. @@ -530,35 +712,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ResourcePoolsList', pipeline_response) + deserialized = self._deserialize("ResourcePoolsList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -571,12 +749,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_vcenters_operations.py b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_vcenters_operations.py index d959200f8aed..e972a503e198 100644 --- a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_vcenters_operations.py +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_vcenters_operations.py @@ -5,25 +5,254 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_request_initial( + subscription_id: str, + resource_group_name: str, + vcenter_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "vcenterName": _SERIALIZER.url("vcenter_name", vcenter_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + vcenter_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "vcenterName": _SERIALIZER.url("vcenter_name", vcenter_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_update_request( + subscription_id: str, + resource_group_name: str, + vcenter_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "vcenterName": _SERIALIZER.url("vcenter_name", vcenter_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + vcenter_name: str, + *, + force: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "vcenterName": _SERIALIZER.url("vcenter_name", vcenter_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') + if force is not None: + query_parameters['force'] = _SERIALIZER.query("force", force, 'bool') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/vcenters') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class VCentersOperations(object): """VCentersOperations operations. @@ -49,53 +278,41 @@ def __init__(self, client, config, serializer, deserializer): def _create_initial( self, - resource_group_name, # type: str - vcenter_name, # type: str - body=None, # type: Optional["_models.VCenter"] - **kwargs # type: Any - ): - # type: (...) -> "_models.VCenter" + resource_group_name: str, + vcenter_name: str, + body: Optional["_models.VCenter"] = None, + **kwargs: Any + ) -> "_models.VCenter": cls = kwargs.pop('cls', None) # type: ClsType["_models.VCenter"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'vcenterName': self._serialize.url("vcenter_name", vcenter_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'VCenter') + _json = self._serialize.body(body, 'VCenter') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vcenter_name=vcenter_name, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('VCenter', pipeline_response) @@ -107,16 +324,18 @@ def _create_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}'} # type: ignore + + @distributed_trace def begin_create( self, - resource_group_name, # type: str - vcenter_name, # type: str - body=None, # type: Optional["_models.VCenter"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.VCenter"] + resource_group_name: str, + vcenter_name: str, + body: Optional["_models.VCenter"] = None, + **kwargs: Any + ) -> LROPoller["_models.VCenter"]: """Implements vCenter PUT method. Create Or Update vCenter. @@ -129,15 +348,18 @@ def begin_create( :type body: ~azure.mgmt.connectedvmware.models.VCenter :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either VCenter or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.connectedvmware.models.VCenter] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.VCenter"] lro_delay = kwargs.pop( 'polling_interval', @@ -149,27 +371,21 @@ def begin_create( resource_group_name=resource_group_name, vcenter_name=vcenter_name, body=body, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('VCenter', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'vcenterName': self._serialize.url("vcenter_name", vcenter_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -181,15 +397,16 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - vcenter_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.VCenter" + resource_group_name: str, + vcenter_name: str, + **kwargs: Any + ) -> "_models.VCenter": """Gets a vCenter. Implements vCenter GET method. @@ -208,33 +425,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'vcenterName': self._serialize.url("vcenter_name", vcenter_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vcenter_name=vcenter_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('VCenter', pipeline_response) @@ -243,16 +450,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}'} # type: ignore + + @distributed_trace def update( self, - resource_group_name, # type: str - vcenter_name, # type: str - body=None, # type: Optional["_models.ResourcePatch"] - **kwargs # type: Any - ): - # type: (...) -> "_models.VCenter" + resource_group_name: str, + vcenter_name: str, + body: Optional["_models.ResourcePatch"] = None, + **kwargs: Any + ) -> "_models.VCenter": """Updates a vCenter. API to update certain properties of the vCenter resource. @@ -273,41 +482,31 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'vcenterName': self._serialize.url("vcenter_name", vcenter_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'ResourcePatch') + _json = self._serialize.body(body, 'ResourcePatch') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vcenter_name=vcenter_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('VCenter', pipeline_response) @@ -316,65 +515,55 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}'} # type: ignore + def _delete_initial( self, - resource_group_name, # type: str - vcenter_name, # type: str - force=None, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + vcenter_name: str, + force: Optional[bool] = None, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'vcenterName': self._serialize.url("vcenter_name", vcenter_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if force is not None: - query_parameters['force'] = self._serialize.query("force", force, 'bool') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vcenter_name=vcenter_name, + force=force, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - vcenter_name, # type: str - force=None, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + vcenter_name: str, + force: Optional[bool] = None, + **kwargs: Any + ) -> LROPoller[None]: """Deletes an vCenter. Implements vCenter DELETE method. @@ -387,15 +576,17 @@ def begin_delete( :type force: bool :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -410,21 +601,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'vcenterName': self._serialize.url("vcenter_name", vcenter_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -436,13 +620,14 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}'} # type: ignore + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.VCentersList"] + **kwargs: Any + ) -> Iterable["_models.VCentersList"]: """Implements GET vCenters in a subscription. List of vCenters in a subscription. @@ -457,34 +642,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('VCentersList', pipeline_response) + deserialized = self._deserialize("VCentersList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -497,23 +677,24 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/vcenters'} # type: ignore + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.VCentersList"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.VCentersList"]: """Implements GET vCenters in a resource group. List of vCenters in a resource group. @@ -530,35 +711,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('VCentersList', pipeline_response) + deserialized = self._deserialize("VCentersList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -571,12 +748,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_virtual_machine_templates_operations.py b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_virtual_machine_templates_operations.py index 27f8bdcf3118..c38d2bac167e 100644 --- a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_virtual_machine_templates_operations.py +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_virtual_machine_templates_operations.py @@ -5,25 +5,254 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_request_initial( + subscription_id: str, + resource_group_name: str, + virtual_machine_template_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates/{virtualMachineTemplateName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "virtualMachineTemplateName": _SERIALIZER.url("virtual_machine_template_name", virtual_machine_template_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + virtual_machine_template_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates/{virtualMachineTemplateName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "virtualMachineTemplateName": _SERIALIZER.url("virtual_machine_template_name", virtual_machine_template_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_update_request( + subscription_id: str, + resource_group_name: str, + virtual_machine_template_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates/{virtualMachineTemplateName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "virtualMachineTemplateName": _SERIALIZER.url("virtual_machine_template_name", virtual_machine_template_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + virtual_machine_template_name: str, + *, + force: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates/{virtualMachineTemplateName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "virtualMachineTemplateName": _SERIALIZER.url("virtual_machine_template_name", virtual_machine_template_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') + if force is not None: + query_parameters['force'] = _SERIALIZER.query("force", force, 'bool') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class VirtualMachineTemplatesOperations(object): """VirtualMachineTemplatesOperations operations. @@ -49,53 +278,41 @@ def __init__(self, client, config, serializer, deserializer): def _create_initial( self, - resource_group_name, # type: str - virtual_machine_template_name, # type: str - body=None, # type: Optional["_models.VirtualMachineTemplate"] - **kwargs # type: Any - ): - # type: (...) -> "_models.VirtualMachineTemplate" + resource_group_name: str, + virtual_machine_template_name: str, + body: Optional["_models.VirtualMachineTemplate"] = None, + **kwargs: Any + ) -> "_models.VirtualMachineTemplate": cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineTemplate"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineTemplateName': self._serialize.url("virtual_machine_template_name", virtual_machine_template_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'VirtualMachineTemplate') + _json = self._serialize.body(body, 'VirtualMachineTemplate') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_template_name=virtual_machine_template_name, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('VirtualMachineTemplate', pipeline_response) @@ -107,16 +324,18 @@ def _create_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates/{virtualMachineTemplateName}'} # type: ignore + + @distributed_trace def begin_create( self, - resource_group_name, # type: str - virtual_machine_template_name, # type: str - body=None, # type: Optional["_models.VirtualMachineTemplate"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.VirtualMachineTemplate"] + resource_group_name: str, + virtual_machine_template_name: str, + body: Optional["_models.VirtualMachineTemplate"] = None, + **kwargs: Any + ) -> LROPoller["_models.VirtualMachineTemplate"]: """Implements virtual machine template PUT method. Create Or Update virtual machine template. @@ -129,15 +348,20 @@ def begin_create( :type body: ~azure.mgmt.connectedvmware.models.VirtualMachineTemplate :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either VirtualMachineTemplate or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.connectedvmware.models.VirtualMachineTemplate] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either VirtualMachineTemplate or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.connectedvmware.models.VirtualMachineTemplate] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineTemplate"] lro_delay = kwargs.pop( 'polling_interval', @@ -149,27 +373,21 @@ def begin_create( resource_group_name=resource_group_name, virtual_machine_template_name=virtual_machine_template_name, body=body, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('VirtualMachineTemplate', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineTemplateName': self._serialize.url("virtual_machine_template_name", virtual_machine_template_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -181,15 +399,16 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates/{virtualMachineTemplateName}'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - virtual_machine_template_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.VirtualMachineTemplate" + resource_group_name: str, + virtual_machine_template_name: str, + **kwargs: Any + ) -> "_models.VirtualMachineTemplate": """Gets a virtual machine template. Implements virtual machine template GET method. @@ -208,33 +427,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineTemplateName': self._serialize.url("virtual_machine_template_name", virtual_machine_template_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_template_name=virtual_machine_template_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('VirtualMachineTemplate', pipeline_response) @@ -243,16 +452,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates/{virtualMachineTemplateName}'} # type: ignore + + @distributed_trace def update( self, - resource_group_name, # type: str - virtual_machine_template_name, # type: str - body=None, # type: Optional["_models.ResourcePatch"] - **kwargs # type: Any - ): - # type: (...) -> "_models.VirtualMachineTemplate" + resource_group_name: str, + virtual_machine_template_name: str, + body: Optional["_models.ResourcePatch"] = None, + **kwargs: Any + ) -> "_models.VirtualMachineTemplate": """Updates a virtual machine template. API to update certain properties of the virtual machine template resource. @@ -273,41 +484,31 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineTemplateName': self._serialize.url("virtual_machine_template_name", virtual_machine_template_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'ResourcePatch') + _json = self._serialize.body(body, 'ResourcePatch') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_template_name=virtual_machine_template_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('VirtualMachineTemplate', pipeline_response) @@ -316,65 +517,55 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates/{virtualMachineTemplateName}'} # type: ignore + def _delete_initial( self, - resource_group_name, # type: str - virtual_machine_template_name, # type: str - force=None, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + virtual_machine_template_name: str, + force: Optional[bool] = None, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineTemplateName': self._serialize.url("virtual_machine_template_name", virtual_machine_template_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if force is not None: - query_parameters['force'] = self._serialize.query("force", force, 'bool') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_template_name=virtual_machine_template_name, + force=force, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates/{virtualMachineTemplateName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - virtual_machine_template_name, # type: str - force=None, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + virtual_machine_template_name: str, + force: Optional[bool] = None, + **kwargs: Any + ) -> LROPoller[None]: """Deletes an virtual machine template. Implements virtual machine template DELETE method. @@ -387,15 +578,17 @@ def begin_delete( :type force: bool :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -410,21 +603,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineTemplateName': self._serialize.url("virtual_machine_template_name", virtual_machine_template_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -436,20 +622,23 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates/{virtualMachineTemplateName}'} # type: ignore + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.VirtualMachineTemplatesList"] + **kwargs: Any + ) -> Iterable["_models.VirtualMachineTemplatesList"]: """Implements GET virtualMachineTemplates in a subscription. List of virtualMachineTemplates in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either VirtualMachineTemplatesList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.connectedvmware.models.VirtualMachineTemplatesList] + :return: An iterator like instance of either VirtualMachineTemplatesList or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.connectedvmware.models.VirtualMachineTemplatesList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineTemplatesList"] @@ -457,34 +646,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('VirtualMachineTemplatesList', pipeline_response) + deserialized = self._deserialize("VirtualMachineTemplatesList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -497,23 +681,24 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates'} # type: ignore + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.VirtualMachineTemplatesList"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.VirtualMachineTemplatesList"]: """Implements GET virtualMachineTemplates in a resource group. List of virtualMachineTemplates in a resource group. @@ -521,8 +706,10 @@ def list_by_resource_group( :param resource_group_name: The Resource Group Name. :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 VirtualMachineTemplatesList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.connectedvmware.models.VirtualMachineTemplatesList] + :return: An iterator like instance of either VirtualMachineTemplatesList or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.connectedvmware.models.VirtualMachineTemplatesList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineTemplatesList"] @@ -530,35 +717,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('VirtualMachineTemplatesList', pipeline_response) + deserialized = self._deserialize("VirtualMachineTemplatesList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -571,12 +754,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_virtual_machines_operations.py b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_virtual_machines_operations.py index 15163c2eac4f..7d8dc60a72f8 100644 --- a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_virtual_machines_operations.py +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_virtual_machines_operations.py @@ -5,25 +5,368 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_request_initial( + subscription_id: str, + resource_group_name: str, + virtual_machine_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + virtual_machine_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_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_update_request_initial( + subscription_id: str, + resource_group_name: str, + virtual_machine_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + virtual_machine_name: str, + *, + force: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_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') + if force is not None: + query_parameters['force'] = _SERIALIZER.query("force", force, 'bool') + + # 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_stop_request_initial( + subscription_id: str, + resource_group_name: str, + virtual_machine_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/stop') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_start_request_initial( + subscription_id: str, + resource_group_name: str, + virtual_machine_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/start') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_restart_request_initial( + subscription_id: str, + resource_group_name: str, + virtual_machine_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/restart') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class VirtualMachinesOperations(object): """VirtualMachinesOperations operations. @@ -49,53 +392,41 @@ def __init__(self, client, config, serializer, deserializer): def _create_initial( self, - resource_group_name, # type: str - virtual_machine_name, # type: str - body=None, # type: Optional["_models.VirtualMachine"] - **kwargs # type: Any - ): - # type: (...) -> "_models.VirtualMachine" + resource_group_name: str, + virtual_machine_name: str, + body: Optional["_models.VirtualMachine"] = None, + **kwargs: Any + ) -> "_models.VirtualMachine": cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'VirtualMachine') + _json = self._serialize.body(body, 'VirtualMachine') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('VirtualMachine', pipeline_response) @@ -107,16 +438,18 @@ def _create_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}'} # type: ignore + + @distributed_trace def begin_create( self, - resource_group_name, # type: str - virtual_machine_name, # type: str - body=None, # type: Optional["_models.VirtualMachine"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.VirtualMachine"] + resource_group_name: str, + virtual_machine_name: str, + body: Optional["_models.VirtualMachine"] = None, + **kwargs: Any + ) -> LROPoller["_models.VirtualMachine"]: """Implements virtual machine PUT method. Create Or Update virtual machine. @@ -129,15 +462,19 @@ def begin_create( :type body: ~azure.mgmt.connectedvmware.models.VirtualMachine :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either VirtualMachine 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 VirtualMachine or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.connectedvmware.models.VirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', @@ -149,27 +486,21 @@ def begin_create( resource_group_name=resource_group_name, virtual_machine_name=virtual_machine_name, body=body, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('VirtualMachine', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -181,15 +512,16 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - virtual_machine_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.VirtualMachine" + resource_group_name: str, + virtual_machine_name: str, + **kwargs: Any + ) -> "_models.VirtualMachine": """Gets a virtual machine. Implements virtual machine GET method. @@ -208,33 +540,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('VirtualMachine', pipeline_response) @@ -243,58 +565,49 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}'} # type: ignore + def _update_initial( self, - resource_group_name, # type: str - virtual_machine_name, # type: str - body=None, # type: Optional["_models.VirtualMachineUpdate"] - **kwargs # type: Any - ): - # type: (...) -> "_models.VirtualMachine" - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] + resource_group_name: str, + virtual_machine_name: str, + body: Optional["_models.VirtualMachineUpdate"] = None, + **kwargs: Any + ) -> Optional["_models.VirtualMachine"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.VirtualMachine"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'VirtualMachineUpdate') + _json = self._serialize.body(body, 'VirtualMachineUpdate') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + content_type=content_type, + json=_json, + template_url=self._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]: + if response.status_code not in [200, 201, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + deserialized = None if response.status_code == 200: deserialized = self._deserialize('VirtualMachine', pipeline_response) @@ -305,16 +618,18 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}'} # type: ignore + + @distributed_trace def begin_update( self, - resource_group_name, # type: str - virtual_machine_name, # type: str - body=None, # type: Optional["_models.VirtualMachineUpdate"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.VirtualMachine"] + resource_group_name: str, + virtual_machine_name: str, + body: Optional["_models.VirtualMachineUpdate"] = None, + **kwargs: Any + ) -> LROPoller["_models.VirtualMachine"]: """Updates a virtual machine. API to update certain properties of the virtual machine resource. @@ -327,15 +642,19 @@ def begin_update( :type body: ~azure.mgmt.connectedvmware.models.VirtualMachineUpdate :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either VirtualMachine 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 VirtualMachine or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.connectedvmware.models.VirtualMachine] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] lro_delay = kwargs.pop( 'polling_interval', @@ -347,27 +666,21 @@ def begin_update( resource_group_name=resource_group_name, virtual_machine_name=virtual_machine_name, body=body, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('VirtualMachine', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -379,65 +692,54 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - virtual_machine_name, # type: str - force=None, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + virtual_machine_name: str, + force: Optional[bool] = None, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if force is not None: - query_parameters['force'] = self._serialize.query("force", force, 'bool') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + force=force, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - virtual_machine_name, # type: str - force=None, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + virtual_machine_name: str, + force: Optional[bool] = None, + **kwargs: Any + ) -> LROPoller[None]: """Deletes an virtual machine. Implements virtual machine DELETE method. @@ -450,15 +752,17 @@ def begin_delete( :type force: bool :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -473,21 +777,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -499,71 +796,61 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}'} # type: ignore def _stop_initial( self, - resource_group_name, # type: str - virtual_machine_name, # type: str - body=None, # type: Optional["_models.StopVirtualMachineOptions"] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + virtual_machine_name: str, + body: Optional["_models.StopVirtualMachineOptions"] = None, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._stop_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'StopVirtualMachineOptions') + _json = self._serialize.body(body, 'StopVirtualMachineOptions') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_stop_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + content_type=content_type, + json=_json, + template_url=self._stop_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, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _stop_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/stop'} # type: ignore + + @distributed_trace def begin_stop( self, - resource_group_name, # type: str - virtual_machine_name, # type: str - body=None, # type: Optional["_models.StopVirtualMachineOptions"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + virtual_machine_name: str, + body: Optional["_models.StopVirtualMachineOptions"] = None, + **kwargs: Any + ) -> LROPoller[None]: """Implements the operation to stop a virtual machine. Stop virtual machine. @@ -576,15 +863,18 @@ def begin_stop( :type body: ~azure.mgmt.connectedvmware.models.StopVirtualMachineOptions :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + 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[None] lro_delay = kwargs.pop( 'polling_interval', @@ -596,24 +886,18 @@ def begin_stop( resource_group_name=resource_group_name, virtual_machine_name=virtual_machine_name, body=body, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -625,61 +909,51 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_stop.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/stop'} # type: ignore def _start_initial( self, - resource_group_name, # type: str - virtual_machine_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + virtual_machine_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self._start_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_start_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + template_url=self._start_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _start_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/start'} # type: ignore + + @distributed_trace def begin_start( self, - resource_group_name, # type: str - virtual_machine_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + virtual_machine_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Implements the operation to start a virtual machine. Start virtual machine. @@ -690,15 +964,17 @@ def begin_start( :type virtual_machine_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -712,21 +988,14 @@ def begin_start( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -738,61 +1007,51 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_start.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/start'} # type: ignore def _restart_initial( self, - resource_group_name, # type: str - virtual_machine_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + virtual_machine_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self._restart_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_restart_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + template_url=self._restart_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _restart_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/restart'} # type: ignore + + @distributed_trace def begin_restart( self, - resource_group_name, # type: str - virtual_machine_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + virtual_machine_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Implements the operation to restart a virtual machine. Restart virtual machine. @@ -803,15 +1062,17 @@ def begin_restart( :type virtual_machine_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -825,21 +1086,14 @@ def begin_restart( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualMachineName': self._serialize.url("virtual_machine_name", virtual_machine_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -851,13 +1105,14 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_restart.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/restart'} # type: ignore + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.VirtualMachinesList"] + **kwargs: Any + ) -> Iterable["_models.VirtualMachinesList"]: """Implements GET virtualMachines in a subscription. List of virtualMachines in a subscription. @@ -872,34 +1127,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('VirtualMachinesList', pipeline_response) + deserialized = self._deserialize("VirtualMachinesList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -912,23 +1162,24 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines'} # type: ignore + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.VirtualMachinesList"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.VirtualMachinesList"]: """Implements GET virtualMachines in a resource group. List of virtualMachines in a resource group. @@ -945,35 +1196,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('VirtualMachinesList', pipeline_response) + deserialized = self._deserialize("VirtualMachinesList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -986,12 +1233,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_virtual_networks_operations.py b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_virtual_networks_operations.py index c0d69a608783..1c8be7493bf0 100644 --- a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_virtual_networks_operations.py +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_virtual_networks_operations.py @@ -5,25 +5,254 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_request_initial( + subscription_id: str, + resource_group_name: str, + virtual_network_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks/{virtualNetworkName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "virtualNetworkName": _SERIALIZER.url("virtual_network_name", virtual_network_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + virtual_network_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks/{virtualNetworkName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "virtualNetworkName": _SERIALIZER.url("virtual_network_name", virtual_network_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_update_request( + subscription_id: str, + resource_group_name: str, + virtual_network_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks/{virtualNetworkName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "virtualNetworkName": _SERIALIZER.url("virtual_network_name", virtual_network_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + virtual_network_name: str, + *, + force: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks/{virtualNetworkName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "virtualNetworkName": _SERIALIZER.url("virtual_network_name", virtual_network_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') + if force is not None: + query_parameters['force'] = _SERIALIZER.query("force", force, 'bool') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class VirtualNetworksOperations(object): """VirtualNetworksOperations operations. @@ -49,53 +278,41 @@ def __init__(self, client, config, serializer, deserializer): def _create_initial( self, - resource_group_name, # type: str - virtual_network_name, # type: str - body=None, # type: Optional["_models.VirtualNetwork"] - **kwargs # type: Any - ): - # type: (...) -> "_models.VirtualNetwork" + resource_group_name: str, + virtual_network_name: str, + body: Optional["_models.VirtualNetwork"] = None, + **kwargs: Any + ) -> "_models.VirtualNetwork": cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetwork"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualNetworkName': self._serialize.url("virtual_network_name", virtual_network_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'VirtualNetwork') + _json = self._serialize.body(body, 'VirtualNetwork') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_network_name=virtual_network_name, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('VirtualNetwork', pipeline_response) @@ -107,16 +324,18 @@ def _create_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks/{virtualNetworkName}'} # type: ignore + + @distributed_trace def begin_create( self, - resource_group_name, # type: str - virtual_network_name, # type: str - body=None, # type: Optional["_models.VirtualNetwork"] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.VirtualNetwork"] + resource_group_name: str, + virtual_network_name: str, + body: Optional["_models.VirtualNetwork"] = None, + **kwargs: Any + ) -> LROPoller["_models.VirtualNetwork"]: """Implements virtual network PUT method. Create Or Update virtual network. @@ -129,15 +348,19 @@ def begin_create( :type body: ~azure.mgmt.connectedvmware.models.VirtualNetwork :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either VirtualNetwork 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 VirtualNetwork or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.connectedvmware.models.VirtualNetwork] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetwork"] lro_delay = kwargs.pop( 'polling_interval', @@ -149,27 +372,21 @@ def begin_create( resource_group_name=resource_group_name, virtual_network_name=virtual_network_name, body=body, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('VirtualNetwork', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualNetworkName': self._serialize.url("virtual_network_name", virtual_network_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -181,15 +398,16 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks/{virtualNetworkName}'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - virtual_network_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.VirtualNetwork" + resource_group_name: str, + virtual_network_name: str, + **kwargs: Any + ) -> "_models.VirtualNetwork": """Gets a virtual network. Implements virtual network GET method. @@ -208,33 +426,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualNetworkName': self._serialize.url("virtual_network_name", virtual_network_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_network_name=virtual_network_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('VirtualNetwork', pipeline_response) @@ -243,16 +451,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks/{virtualNetworkName}'} # type: ignore + + @distributed_trace def update( self, - resource_group_name, # type: str - virtual_network_name, # type: str - body=None, # type: Optional["_models.ResourcePatch"] - **kwargs # type: Any - ): - # type: (...) -> "_models.VirtualNetwork" + resource_group_name: str, + virtual_network_name: str, + body: Optional["_models.ResourcePatch"] = None, + **kwargs: Any + ) -> "_models.VirtualNetwork": """Updates a virtual network. API to update certain properties of the virtual network resource. @@ -273,41 +483,31 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualNetworkName': self._serialize.url("virtual_network_name", virtual_network_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - body_content_kwargs = {} # type: Dict[str, Any] if body is not None: - body_content = self._serialize.body(body, 'ResourcePatch') + _json = self._serialize.body(body, 'ResourcePatch') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_network_name=virtual_network_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('VirtualNetwork', pipeline_response) @@ -316,65 +516,55 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks/{virtualNetworkName}'} # type: ignore + def _delete_initial( self, - resource_group_name, # type: str - virtual_network_name, # type: str - force=None, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + virtual_network_name: str, + force: Optional[bool] = None, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualNetworkName': self._serialize.url("virtual_network_name", virtual_network_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if force is not None: - query_parameters['force'] = self._serialize.query("force", force, 'bool') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_network_name=virtual_network_name, + force=force, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks/{virtualNetworkName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - virtual_network_name, # type: str - force=None, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + virtual_network_name: str, + force: Optional[bool] = None, + **kwargs: Any + ) -> LROPoller[None]: """Deletes an virtual network. Implements virtual network DELETE method. @@ -387,15 +577,17 @@ def begin_delete( :type force: bool :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -410,21 +602,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'virtualNetworkName': self._serialize.url("virtual_network_name", virtual_network_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -436,13 +621,14 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks/{virtualNetworkName}'} # type: ignore + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.VirtualNetworksList"] + **kwargs: Any + ) -> Iterable["_models.VirtualNetworksList"]: """Implements GET virtualNetworks in a subscription. List of virtualNetworks in a subscription. @@ -457,34 +643,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('VirtualNetworksList', pipeline_response) + deserialized = self._deserialize("VirtualNetworksList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -497,23 +678,24 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks'} # type: ignore + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.VirtualNetworksList"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.VirtualNetworksList"]: """Implements GET virtualNetworks in a resource group. List of virtualNetworks in a resource group. @@ -530,35 +712,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('VirtualNetworksList', pipeline_response) + deserialized = self._deserialize("VirtualNetworksList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -571,12 +749,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data )