diff --git a/sdk/connectedvmware/azure-mgmt-connectedvmware/_meta.json b/sdk/connectedvmware/azure-mgmt-connectedvmware/_meta.json index 63c837f6b944..b674197eadf7 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.8.4", "use": [ - "@autorest/python@5.8.4", - "@autorest/modelerfour@4.19.2" + "@autorest/python@6.0.1", + "@autorest/modelerfour@4.23.5" ], - "commit": "bd288bec4a31b114a29630cebc9b0c6c4c0686ed", + "commit": "5ea8973a7caa11508b8f5be14f68b06dd9d36db9", "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 --models-mode=msrest --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.0.1 --use=@autorest/modelerfour@4.23.5 --version=3.8.4 --version-tolerant=False", "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..afedca0e6e5e 100644 --- a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/__init__.py +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/__init__.py @@ -10,10 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['AzureArcVMwareManagementServiceAPI'] try: - from ._patch import patch_sdk # type: ignore - patch_sdk() + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import except ImportError: - pass + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["AzureArcVMwareManagementServiceAPI"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_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..f1a76600148f 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,40 +6,43 @@ # 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, 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 ._serialization import Deserializer, Serializer +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: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Self service experience for VMware. :ivar operations: Operations operations :vartype operations: azure.mgmt.connectedvmware.operations.Operations + :ivar virtual_machines: VirtualMachinesOperations operations + :vartype virtual_machines: azure.mgmt.connectedvmware.operations.VirtualMachinesOperations :ivar resource_pools: ResourcePoolsOperations operations :vartype resource_pools: azure.mgmt.connectedvmware.operations.ResourcePoolsOperations :ivar clusters: ClustersOperations operations @@ -50,90 +53,94 @@ class AzureArcVMwareManagementServiceAPI(object): :vartype datastores: azure.mgmt.connectedvmware.operations.DatastoresOperations :ivar vcenters: VCentersOperations operations :vartype vcenters: azure.mgmt.connectedvmware.operations.VCentersOperations - :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 :vartype guest_agents: azure.mgmt.connectedvmware.operations.GuestAgentsOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The Subscription ID. + :param subscription_id: The Subscription ID. Required. :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 api_version: Api Version. Default value is "2022-01-10-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: 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._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.virtual_machines = VirtualMachinesOperations( - self._client, self._config, self._serialize, self._deserialize) + 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_machine_templates = VirtualMachineTemplatesOperations( - self._client, self._config, self._serialize, self._deserialize) + 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._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._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._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 + def _send_request(self, request: 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/dpcodegen/python/send_request + + :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..a16dfb63c7f3 100644 --- a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/_configuration.py +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/_configuration.py @@ -6,66 +6,64 @@ # 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 -class AzureArcVMwareManagementServiceAPIConfiguration(Configuration): +class AzureArcVMwareManagementServiceAPIConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AzureArcVMwareManagementServiceAPI. Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The Subscription ID. + :param subscription_id: The Subscription ID. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-01-10-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ - def __init__( - self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(AzureArcVMwareManagementServiceAPIConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2022-01-10-preview") # type: str + 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 - self.api_version = "2020-10-01-preview" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-connectedvmware/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-connectedvmware/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> None - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/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..f7dd32510333 --- /dev/null +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/_serialization.py b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/_serialization.py new file mode 100644 index 000000000000..648f84cc4e65 --- /dev/null +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/_serialization.py @@ -0,0 +1,1970 @@ +# -------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------- + +# pylint: skip-file + +from base64 import b64decode, b64encode +import calendar +import datetime +import decimal +import email +from enum import Enum +import json +import logging +import re +import sys +import codecs + +try: + from urllib import quote # type: ignore +except ImportError: + from urllib.parse import quote # type: ignore +import xml.etree.ElementTree as ET + +import isodate + +from typing import Dict, Any, cast, TYPE_CHECKING + +from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback + +_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") + +if TYPE_CHECKING: + from typing import Optional, Union, AnyStr, IO, Mapping + + +class RawDeserializer: + + # Accept "text" because we're open minded people... + JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") + + # Name used in context + CONTEXT_NAME = "deserialized_data" + + @classmethod + def deserialize_from_text(cls, data, content_type=None): + # type: (Optional[Union[AnyStr, IO]], Optional[str]) -> Any + """Decode data according to content-type. + + Accept a stream of data as well, but will be load at once in memory for now. + + If no content-type, will return the string version (not bytes, not stream) + + :param data: Input, could be bytes or stream (will be decoded with UTF8) or text + :type data: str or bytes or IO + :param str content_type: The content type. + """ + if hasattr(data, "read"): + # Assume a stream + data = cast(IO, data).read() + + if isinstance(data, bytes): + data_as_str = data.decode(encoding="utf-8-sig") + else: + # Explain to mypy the correct type. + data_as_str = cast(str, data) + + # Remove Byte Order Mark if present in string + data_as_str = data_as_str.lstrip(_BOM) + + if content_type is None: + return data + + if cls.JSON_REGEXP.match(content_type): + try: + return json.loads(data_as_str) + except ValueError as err: + raise DeserializationError("JSON is invalid: {}".format(err), err) + elif "xml" in (content_type or []): + try: + + try: + if isinstance(data, unicode): # type: ignore + # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string + data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore + except NameError: + pass + + return ET.fromstring(data_as_str) # nosec + except ET.ParseError: + # It might be because the server has an issue, and returned JSON with + # content-type XML.... + # So let's try a JSON load, and if it's still broken + # let's flow the initial exception + def _json_attemp(data): + try: + return True, json.loads(data) + except ValueError: + return False, None # Don't care about this one + + success, json_result = _json_attemp(data) + if success: + return json_result + # If i'm here, it's not JSON, it's not XML, let's scream + # and raise the last context in this block (the XML exception) + # The function hack is because Py2.7 messes up with exception + # context otherwise. + _LOGGER.critical("Wasn't XML not JSON, failing") + raise_with_traceback(DeserializationError, "XML is invalid") + raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) + + @classmethod + def deserialize_from_http_generics(cls, body_bytes, headers): + # type: (Optional[Union[AnyStr, IO]], Mapping) -> Any + """Deserialize from HTTP response. + + Use bytes and headers to NOT use any requests/aiohttp or whatever + specific implementation. + Headers will tested for "content-type" + """ + # Try to use content-type from headers if available + content_type = None + if "content-type" in headers: + content_type = headers["content-type"].split(";")[0].strip().lower() + # Ouch, this server did not declare what it sent... + # Let's guess it's JSON... + # Also, since Autorest was considering that an empty body was a valid JSON, + # need that test as well.... + else: + content_type = "application/json" + + if body_bytes: + return cls.deserialize_from_text(body_bytes, content_type) + return None + + +try: + basestring # type: ignore + unicode_str = unicode # type: ignore +except NameError: + basestring = str # type: ignore + unicode_str = str # type: ignore + +_LOGGER = logging.getLogger(__name__) + +try: + _long_type = long # type: ignore +except NameError: + _long_type = int + + +class UTC(datetime.tzinfo): + """Time Zone info for handling UTC""" + + def utcoffset(self, dt): + """UTF offset for UTC is 0.""" + return datetime.timedelta(0) + + def tzname(self, dt): + """Timestamp representation.""" + return "Z" + + def dst(self, dt): + """No daylight saving for UTC.""" + return datetime.timedelta(hours=1) + + +try: + from datetime import timezone as _FixedOffset +except ImportError: # Python 2.7 + + class _FixedOffset(datetime.tzinfo): # type: ignore + """Fixed offset in minutes east from UTC. + Copy/pasted from Python doc + :param datetime.timedelta offset: offset in timedelta format + """ + + def __init__(self, offset): + self.__offset = offset + + def utcoffset(self, dt): + return self.__offset + + def tzname(self, dt): + return str(self.__offset.total_seconds() / 3600) + + def __repr__(self): + return "".format(self.tzname(None)) + + def dst(self, dt): + return datetime.timedelta(0) + + def __getinitargs__(self): + return (self.__offset,) + + +try: + from datetime import timezone + + TZ_UTC = timezone.utc # type: ignore +except ImportError: + TZ_UTC = UTC() # type: ignore + +_FLATTEN = re.compile(r"(? y, + "minimum": lambda x, y: x < y, + "maximum": lambda x, y: x > y, + "minimum_ex": lambda x, y: x <= y, + "maximum_ex": lambda x, y: x >= y, + "min_items": lambda x, y: len(x) < y, + "max_items": lambda x, y: len(x) > y, + "pattern": lambda x, y: not re.match(y, x, re.UNICODE), + "unique": lambda x, y: len(x) != len(set(x)), + "multiple": lambda x, y: x % y != 0, + } + + def __init__(self, classes=None): + self.serialize_type = { + "iso-8601": Serializer.serialize_iso, + "rfc-1123": Serializer.serialize_rfc, + "unix-time": Serializer.serialize_unix, + "duration": Serializer.serialize_duration, + "date": Serializer.serialize_date, + "time": Serializer.serialize_time, + "decimal": Serializer.serialize_decimal, + "long": Serializer.serialize_long, + "bytearray": Serializer.serialize_bytearray, + "base64": Serializer.serialize_base64, + "object": self.serialize_object, + "[]": self.serialize_iter, + "{}": self.serialize_dict, + } + self.dependencies = dict(classes) if classes else {} + self.key_transformer = full_restapi_key_transformer + self.client_side_validation = True + + def _serialize(self, target_obj, data_type=None, **kwargs): + """Serialize data into a string according to type. + + :param target_obj: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, dict + :raises: SerializationError if serialization fails. + """ + key_transformer = kwargs.get("key_transformer", self.key_transformer) + keep_readonly = kwargs.get("keep_readonly", False) + if target_obj is None: + return None + + attr_name = None + class_name = target_obj.__class__.__name__ + + if data_type: + return self.serialize_data(target_obj, data_type, **kwargs) + + if not hasattr(target_obj, "_attribute_map"): + data_type = type(target_obj).__name__ + if data_type in self.basic_types.values(): + return self.serialize_data(target_obj, data_type, **kwargs) + + # Force "is_xml" kwargs if we detect a XML model + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) + + serialized = {} + if is_xml_model_serialization: + serialized = target_obj._create_xml_node() + try: + attributes = target_obj._attribute_map + for attr, attr_desc in attributes.items(): + attr_name = attr + if not keep_readonly and target_obj._validation.get(attr_name, {}).get("readonly", False): + continue + + if attr_name == "additional_properties" and attr_desc["key"] == "": + if target_obj.additional_properties is not None: + serialized.update(target_obj.additional_properties) + continue + try: + + orig_attr = getattr(target_obj, attr) + if is_xml_model_serialization: + pass # Don't provide "transformer" for XML for now. Keep "orig_attr" + else: # JSON + keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) + keys = keys if isinstance(keys, list) else [keys] + + kwargs["serialization_ctxt"] = attr_desc + new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) + + if is_xml_model_serialization: + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + xml_prefix = xml_desc.get("prefix", None) + xml_ns = xml_desc.get("ns", None) + if xml_desc.get("attr", False): + if xml_ns: + ET.register_namespace(xml_prefix, xml_ns) + xml_name = "{}{}".format(xml_ns, xml_name) + serialized.set(xml_name, new_attr) + continue + if xml_desc.get("text", False): + serialized.text = new_attr + continue + if isinstance(new_attr, list): + serialized.extend(new_attr) + elif isinstance(new_attr, ET.Element): + # If the down XML has no XML/Name, we MUST replace the tag with the local tag. But keeping the namespaces. + if "name" not in getattr(orig_attr, "_xml_map", {}): + splitted_tag = new_attr.tag.split("}") + if len(splitted_tag) == 2: # Namespace + new_attr.tag = "}".join([splitted_tag[0], xml_name]) + else: + new_attr.tag = xml_name + serialized.append(new_attr) + else: # That's a basic type + # Integrate namespace if necessary + local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) + local_node.text = unicode_str(new_attr) + serialized.append(local_node) + else: # JSON + for k in reversed(keys): + unflattened = {k: new_attr} + new_attr = unflattened + + _new_attr = new_attr + _serialized = serialized + for k in keys: + if k not in _serialized: + _serialized.update(_new_attr) + _new_attr = _new_attr[k] + _serialized = _serialized[k] + except ValueError: + continue + + except (AttributeError, KeyError, TypeError) as err: + msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) + raise_with_traceback(SerializationError, msg, err) + else: + return serialized + + def body(self, data, data_type, **kwargs): + """Serialize data intended for a request body. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: dict + :raises: SerializationError if serialization fails. + :raises: ValueError if data is None + """ + + # Just in case this is a dict + internal_data_type = data_type.strip("[]{}") + internal_data_type = self.dependencies.get(internal_data_type, None) + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + if internal_data_type and issubclass(internal_data_type, Model): + is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) + else: + is_xml_model_serialization = False + if internal_data_type and not isinstance(internal_data_type, Enum): + try: + deserializer = Deserializer(self.dependencies) + # Since it's on serialization, it's almost sure that format is not JSON REST + # We're not able to deal with additional properties for now. + deserializer.additional_properties_detection = False + if is_xml_model_serialization: + deserializer.key_extractors = [ + attribute_key_case_insensitive_extractor, + ] + else: + deserializer.key_extractors = [ + rest_key_case_insensitive_extractor, + attribute_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor, + ] + data = deserializer._deserialize(data_type, data) + except DeserializationError as err: + raise_with_traceback(SerializationError, "Unable to build a model: " + str(err), err) + + return self._serialize(data, data_type, **kwargs) + + def url(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL path. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + + if kwargs.get("skip_quote") is True: + output = str(output) + else: + output = quote(str(output), safe="") + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return output + + def query(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL query. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + # Treat the list aside, since we don't want to encode the div separator + if data_type.startswith("["): + internal_data_type = data_type[1:-1] + data = [self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" for d in data] + if not kwargs.get("skip_quote", False): + data = [quote(str(d), safe="") for d in data] + return str(self.serialize_iter(data, internal_data_type, **kwargs)) + + # Not a list, regular serialization + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + if kwargs.get("skip_quote") is True: + output = str(output) + else: + output = quote(str(output), safe="") + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def header(self, name, data, data_type, **kwargs): + """Serialize data intended for a request header. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + if data_type in ["[str]"]: + data = ["" if d is None else d for d in data] + + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def serialize_data(self, data, data_type, **kwargs): + """Serialize generic data according to supplied data type. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :param bool required: Whether it's essential that the data not be + empty or None + :raises: AttributeError if required data is None. + :raises: ValueError if data is None + :raises: SerializationError if serialization fails. + """ + if data is None: + raise ValueError("No value for given attribute") + + try: + if data_type in self.basic_types.values(): + return self.serialize_basic(data, data_type, **kwargs) + + elif data_type in self.serialize_type: + return self.serialize_type[data_type](data, **kwargs) + + # If dependencies is empty, try with current data class + # It has to be a subclass of Enum anyway + enum_type = self.dependencies.get(data_type, data.__class__) + if issubclass(enum_type, Enum): + return Serializer.serialize_enum(data, enum_obj=enum_type) + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.serialize_type: + return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) + + except (ValueError, TypeError) as err: + msg = "Unable to serialize value: {!r} as type: {!r}." + raise_with_traceback(SerializationError, msg.format(data, data_type), err) + else: + return self._serialize(data, **kwargs) + + @classmethod + def _get_custom_serializers(cls, data_type, **kwargs): + custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) + if custom_serializer: + return custom_serializer + if kwargs.get("is_xml", False): + return cls._xml_basic_types_serializers.get(data_type) + + @classmethod + def serialize_basic(cls, data, data_type, **kwargs): + """Serialize basic builting data type. + Serializes objects to str, int, float or bool. + + Possible kwargs: + - basic_types_serializers dict[str, callable] : If set, use the callable as serializer + - is_xml bool : If set, use xml_basic_types_serializers + + :param data: Object to be serialized. + :param str data_type: Type of object in the iterable. + """ + custom_serializer = cls._get_custom_serializers(data_type, **kwargs) + if custom_serializer: + return custom_serializer(data) + if data_type == "str": + return cls.serialize_unicode(data) + return eval(data_type)(data) # nosec + + @classmethod + def serialize_unicode(cls, data): + """Special handling for serializing unicode strings in Py2. + Encode to UTF-8 if unicode, otherwise handle as a str. + + :param data: Object to be serialized. + :rtype: str + """ + try: # If I received an enum, return its value + return data.value + except AttributeError: + pass + + try: + if isinstance(data, unicode): + # Don't change it, JSON and XML ElementTree are totally able + # to serialize correctly u'' strings + return data + except NameError: + return str(data) + else: + return str(data) + + def serialize_iter(self, data, iter_type, div=None, **kwargs): + """Serialize iterable. + + Supported kwargs: + - serialization_ctxt dict : The current entry of _attribute_map, or same format. + serialization_ctxt['type'] should be same as data_type. + - is_xml bool : If set, serialize as XML + + :param list attr: Object to be serialized. + :param str iter_type: Type of object in the iterable. + :param bool required: Whether the objects in the iterable must + not be None or empty. + :param str div: If set, this str will be used to combine the elements + in the iterable into a combined string. Default is 'None'. + :rtype: list, str + """ + if isinstance(data, str): + raise SerializationError("Refuse str type as a valid iter type.") + + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + is_xml = kwargs.get("is_xml", False) + + serialized = [] + for d in data: + try: + serialized.append(self.serialize_data(d, iter_type, **kwargs)) + except ValueError: + serialized.append(None) + + if div: + serialized = ["" if s is None else str(s) for s in serialized] + serialized = div.join(serialized) + + if "xml" in serialization_ctxt or is_xml: + # XML serialization is more complicated + xml_desc = serialization_ctxt.get("xml", {}) + xml_name = xml_desc.get("name") + if not xml_name: + xml_name = serialization_ctxt["key"] + + # Create a wrap node if necessary (use the fact that Element and list have "append") + is_wrapped = xml_desc.get("wrapped", False) + node_name = xml_desc.get("itemsName", xml_name) + if is_wrapped: + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + else: + final_result = [] + # All list elements to "local_node" + for el in serialized: + if isinstance(el, ET.Element): + el_node = el + else: + el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + if el is not None: # Otherwise it writes "None" :-p + el_node.text = str(el) + final_result.append(el_node) + return final_result + return serialized + + def serialize_dict(self, attr, dict_type, **kwargs): + """Serialize a dictionary of objects. + + :param dict attr: Object to be serialized. + :param str dict_type: Type of object in the dictionary. + :param bool required: Whether the objects in the dictionary must + not be None or empty. + :rtype: dict + """ + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + + if "xml" in serialization_ctxt: + # XML serialization is more complicated + xml_desc = serialization_ctxt["xml"] + xml_name = xml_desc["name"] + + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + for key, value in serialized.items(): + ET.SubElement(final_result, key).text = value + return final_result + + return serialized + + def serialize_object(self, attr, **kwargs): + """Serialize a generic object. + This will be handled as a dictionary. If object passed in is not + a basic type (str, int, float, dict, list) it will simply be + cast to str. + + :param dict attr: Object to be serialized. + :rtype: dict or str + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + return attr + obj_type = type(attr) + if obj_type in self.basic_types: + return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) + if obj_type is _long_type: + return self.serialize_long(attr) + if obj_type is unicode_str: + return self.serialize_unicode(attr) + if obj_type is datetime.datetime: + return self.serialize_iso(attr) + if obj_type is datetime.date: + return self.serialize_date(attr) + if obj_type is datetime.time: + return self.serialize_time(attr) + if obj_type is datetime.timedelta: + return self.serialize_duration(attr) + if obj_type is decimal.Decimal: + return self.serialize_decimal(attr) + + # If it's a model or I know this dependency, serialize as a Model + elif obj_type in self.dependencies.values() or isinstance(attr, Model): + return self._serialize(attr) + + if obj_type == dict: + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + return serialized + + if obj_type == list: + serialized = [] + for obj in attr: + try: + serialized.append(self.serialize_object(obj, **kwargs)) + except ValueError: + pass + return serialized + return str(attr) + + @staticmethod + def serialize_enum(attr, enum_obj=None): + try: + result = attr.value + except AttributeError: + result = attr + try: + enum_obj(result) + return result + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(attr).lower(): + return enum_value.value + error = "{!r} is not valid value for enum {!r}" + raise SerializationError(error.format(attr, enum_obj)) + + @staticmethod + def serialize_bytearray(attr, **kwargs): + """Serialize bytearray into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + return b64encode(attr).decode() + + @staticmethod + def serialize_base64(attr, **kwargs): + """Serialize str into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + encoded = b64encode(attr).decode("ascii") + return encoded.strip("=").replace("+", "-").replace("/", "_") + + @staticmethod + def serialize_decimal(attr, **kwargs): + """Serialize Decimal object to float. + + :param attr: Object to be serialized. + :rtype: float + """ + return float(attr) + + @staticmethod + def serialize_long(attr, **kwargs): + """Serialize long (Py2) or int (Py3). + + :param attr: Object to be serialized. + :rtype: int/long + """ + return _long_type(attr) + + @staticmethod + def serialize_date(attr, **kwargs): + """Serialize Date object into ISO-8601 formatted string. + + :param Date attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_date(attr) + t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) + return t + + @staticmethod + def serialize_time(attr, **kwargs): + """Serialize Time object into ISO-8601 formatted string. + + :param datetime.time attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_time(attr) + t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) + if attr.microsecond: + t += ".{:02}".format(attr.microsecond) + return t + + @staticmethod + def serialize_duration(attr, **kwargs): + """Serialize TimeDelta object into ISO-8601 formatted string. + + :param TimeDelta attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_duration(attr) + return isodate.duration_isoformat(attr) + + @staticmethod + def serialize_rfc(attr, **kwargs): + """Serialize Datetime object into RFC-1123 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: TypeError if format invalid. + """ + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + except AttributeError: + raise TypeError("RFC1123 object must be valid Datetime object.") + + return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( + Serializer.days[utc.tm_wday], + utc.tm_mday, + Serializer.months[utc.tm_mon], + utc.tm_year, + utc.tm_hour, + utc.tm_min, + utc.tm_sec, + ) + + @staticmethod + def serialize_iso(attr, **kwargs): + """Serialize Datetime object into ISO-8601 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: SerializationError if format invalid. + """ + if isinstance(attr, str): + attr = isodate.parse_datetime(attr) + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + if utc.tm_year > 9999 or utc.tm_year < 1: + raise OverflowError("Hit max or min date") + + microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") + if microseconds: + microseconds = "." + microseconds + date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( + utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec + ) + return date + microseconds + "Z" + except (ValueError, OverflowError) as err: + msg = "Unable to serialize datetime object." + raise_with_traceback(SerializationError, msg, err) + except AttributeError as err: + msg = "ISO-8601 object must be valid Datetime object." + raise_with_traceback(TypeError, msg, err) + + @staticmethod + def serialize_unix(attr, **kwargs): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param Datetime attr: Object to be serialized. + :rtype: int + :raises: SerializationError if format invalid + """ + if isinstance(attr, int): + return attr + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + return int(calendar.timegm(attr.utctimetuple())) + except AttributeError: + raise TypeError("Unix time object must be valid Datetime object.") + + +def rest_key_extractor(attr, attr_desc, data): + key = attr_desc["key"] + working_data = data + + while "." in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = working_data.get(working_key, data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = ".".join(dict_keys[1:]) + + return working_data.get(key) + + +def rest_key_case_insensitive_extractor(attr, attr_desc, data): + key = attr_desc["key"] + working_data = data + + while "." in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = ".".join(dict_keys[1:]) + + if working_data: + return attribute_key_case_insensitive_extractor(key, None, working_data) + + +def last_rest_key_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key.""" + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_extractor(dict_keys[-1], None, data) + + +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key. + + This is the case insensitive version of "last_rest_key_extractor" + """ + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) + + +def attribute_key_extractor(attr, _, data): + return data.get(attr) + + +def attribute_key_case_insensitive_extractor(attr, _, data): + found_key = None + lower_attr = attr.lower() + for key in data: + if lower_attr == key.lower(): + found_key = key + break + + return data.get(found_key) + + +def _extract_name_from_internal_type(internal_type): + """Given an internal type XML description, extract correct XML name with namespace. + + :param dict internal_type: An model type + :rtype: tuple + :returns: A tuple XML name + namespace dict + """ + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + xml_name = internal_type_xml_map.get("name", internal_type.__name__) + xml_ns = internal_type_xml_map.get("ns", None) + if xml_ns: + xml_name = "{}{}".format(xml_ns, xml_name) + return xml_name + + +def xml_key_extractor(attr, attr_desc, data): + if isinstance(data, dict): + return None + + # Test if this model is XML ready first + if not isinstance(data, ET.Element): + return None + + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + + # Look for a children + is_iter_type = attr_desc["type"].startswith("[") + is_wrapped = xml_desc.get("wrapped", False) + internal_type = attr_desc.get("internalType", None) + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + + # Integrate namespace if necessary + xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) + if xml_ns: + xml_name = "{}{}".format(xml_ns, xml_name) + + # If it's an attribute, that's simple + if xml_desc.get("attr", False): + return data.get(xml_name) + + # If it's x-ms-text, that's simple too + if xml_desc.get("text", False): + return data.text + + # Scenario where I take the local name: + # - Wrapped node + # - Internal type is an enum (considered basic types) + # - Internal type has no XML/Name node + if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): + children = data.findall(xml_name) + # If internal type has a local name and it's not a list, I use that name + elif not is_iter_type and internal_type and "name" in internal_type_xml_map: + xml_name = _extract_name_from_internal_type(internal_type) + children = data.findall(xml_name) + # That's an array + else: + if internal_type: # Complex type, ignore itemsName and use the complex type name + items_name = _extract_name_from_internal_type(internal_type) + else: + items_name = xml_desc.get("itemsName", xml_name) + children = data.findall(items_name) + + if len(children) == 0: + if is_iter_type: + if is_wrapped: + return None # is_wrapped no node, we want None + else: + return [] # not wrapped, assume empty list + return None # Assume it's not there, maybe an optional node. + + # If is_iter_type and not wrapped, return all found children + if is_iter_type: + if not is_wrapped: + return children + else: # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( + xml_name + ) + ) + return list(children[0]) # Might be empty list and that's ok. + + # Here it's not a itertype, we should have found one element only or empty + if len(children) > 1: + raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) + return children[0] + + +class Deserializer(object): + """Response object model deserializer. + + :param dict classes: Class type dictionary for deserializing complex types. + :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. + """ + + basic_types = {str: "str", int: "int", bool: "bool", float: "float"} + + valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") + + def __init__(self, classes=None): + self.deserialize_type = { + "iso-8601": Deserializer.deserialize_iso, + "rfc-1123": Deserializer.deserialize_rfc, + "unix-time": Deserializer.deserialize_unix, + "duration": Deserializer.deserialize_duration, + "date": Deserializer.deserialize_date, + "time": Deserializer.deserialize_time, + "decimal": Deserializer.deserialize_decimal, + "long": Deserializer.deserialize_long, + "bytearray": Deserializer.deserialize_bytearray, + "base64": Deserializer.deserialize_base64, + "object": self.deserialize_object, + "[]": self.deserialize_iter, + "{}": self.deserialize_dict, + } + self.deserialize_expected_types = { + "duration": (isodate.Duration, datetime.timedelta), + "iso-8601": (datetime.datetime), + } + self.dependencies = dict(classes) if classes else {} + self.key_extractors = [rest_key_extractor, xml_key_extractor] + # Additional properties only works if the "rest_key_extractor" is used to + # extract the keys. Making it to work whatever the key extractor is too much + # complicated, with no real scenario for now. + # So adding a flag to disable additional properties detection. This flag should be + # used if your expect the deserialization to NOT come from a JSON REST syntax. + # Otherwise, result are unexpected + self.additional_properties_detection = True + + def __call__(self, target_obj, response_data, content_type=None): + """Call the deserializer to process a REST response. + + :param str target_obj: Target data type to deserialize to. + :param requests.Response response_data: REST response object. + :param str content_type: Swagger "produces" if available. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + data = self._unpack_content(response_data, content_type) + return self._deserialize(target_obj, data) + + def _deserialize(self, target_obj, data): + """Call the deserializer on a model. + + Data needs to be already deserialized as JSON or XML ElementTree + + :param str target_obj: Target data type to deserialize to. + :param object data: Object to deserialize. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + # This is already a model, go recursive just in case + if hasattr(data, "_attribute_map"): + constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] + try: + for attr, mapconfig in data._attribute_map.items(): + if attr in constants: + continue + value = getattr(data, attr) + if value is None: + continue + local_type = mapconfig["type"] + internal_data_type = local_type.strip("[]{}") + if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): + continue + setattr(data, attr, self._deserialize(local_type, value)) + return data + except AttributeError: + return + + response, class_name = self._classify_target(target_obj, data) + + if isinstance(response, basestring): + return self.deserialize_data(data, response) + elif isinstance(response, type) and issubclass(response, Enum): + return self.deserialize_enum(data, response) + + if data is None: + return data + try: + attributes = response._attribute_map + d_attrs = {} + for attr, attr_desc in attributes.items(): + # Check empty string. If it's not empty, someone has a real "additionalProperties"... + if attr == "additional_properties" and attr_desc["key"] == "": + continue + raw_value = None + # Enhance attr_desc with some dynamic data + attr_desc = attr_desc.copy() # Do a copy, do not change the real one + internal_data_type = attr_desc["type"].strip("[]{}") + if internal_data_type in self.dependencies: + attr_desc["internalType"] = self.dependencies[internal_data_type] + + for key_extractor in self.key_extractors: + found_value = key_extractor(attr, attr_desc, data) + if found_value is not None: + if raw_value is not None and raw_value != found_value: + msg = ( + "Ignoring extracted value '%s' from %s for key '%s'" + " (duplicate extraction, follow extractors order)" + ) + _LOGGER.warning(msg, found_value, key_extractor, attr) + continue + raw_value = found_value + + value = self.deserialize_data(raw_value, attr_desc["type"]) + d_attrs[attr] = value + except (AttributeError, TypeError, KeyError) as err: + msg = "Unable to deserialize to object: " + class_name + raise_with_traceback(DeserializationError, msg, err) + else: + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) + + def _build_additional_properties(self, attribute_map, data): + if not self.additional_properties_detection: + return None + if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": + # Check empty string. If it's not empty, someone has a real "additionalProperties" + return None + if isinstance(data, ET.Element): + data = {el.tag: el.text for el in data} + + known_keys = { + _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) + for desc in attribute_map.values() + if desc["key"] != "" + } + present_keys = set(data.keys()) + missing_keys = present_keys - known_keys + return {key: data[key] for key in missing_keys} + + def _classify_target(self, target, data): + """Check to see whether the deserialization target object can + be classified into a subclass. + Once classification has been determined, initialize object. + + :param str target: The target object type to deserialize to. + :param str/dict data: The response data to deseralize. + """ + if target is None: + return None, None + + if isinstance(target, basestring): + try: + target = self.dependencies[target] + except KeyError: + return target, target + + try: + target = target._classify(data, self.dependencies) + except AttributeError: + pass # Target is not a Model, no classify + return target, target.__class__.__name__ + + def failsafe_deserialize(self, target_obj, data, content_type=None): + """Ignores any errors encountered in deserialization, + and falls back to not deserializing the object. Recommended + for use in error deserialization, as we want to return the + HttpResponseError to users, and not have them deal with + a deserialization error. + + :param str target_obj: The target object type to deserialize to. + :param str/dict data: The response data to deseralize. + :param str content_type: Swagger "produces" if available. + """ + try: + return self(target_obj, data, content_type=content_type) + except: + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + @staticmethod + def _unpack_content(raw_data, content_type=None): + """Extract the correct structure for deserialization. + + If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. + if we can't, raise. Your Pipeline should have a RawDeserializer. + + If not a pipeline response and raw_data is bytes or string, use content-type + to decode it. If no content-type, try JSON. + + If raw_data is something else, bypass all logic and return it directly. + + :param raw_data: Data to be processed. + :param content_type: How to parse if raw_data is a string/bytes. + :raises JSONDecodeError: If JSON is requested and parsing is impossible. + :raises UnicodeDecodeError: If bytes is not UTF8 + """ + # Assume this is enough to detect a Pipeline Response without importing it + context = getattr(raw_data, "context", {}) + if context: + if RawDeserializer.CONTEXT_NAME in context: + return context[RawDeserializer.CONTEXT_NAME] + raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") + + # Assume this is enough to recognize universal_http.ClientResponse without importing it + if hasattr(raw_data, "body"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) + + # Assume this enough to recognize requests.Response without importing it. + if hasattr(raw_data, "_content_consumed"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) + + if isinstance(raw_data, (basestring, bytes)) or hasattr(raw_data, "read"): + return RawDeserializer.deserialize_from_text(raw_data, content_type) + return raw_data + + def _instantiate_model(self, response, attrs, additional_properties=None): + """Instantiate a response model passing in deserialized args. + + :param response: The response model class. + :param d_attrs: The deserialized response attributes. + """ + if callable(response): + subtype = getattr(response, "_subtype_map", {}) + try: + readonly = [k for k, v in response._validation.items() if v.get("readonly")] + const = [k for k, v in response._validation.items() if v.get("constant")] + kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} + response_obj = response(**kwargs) + for attr in readonly: + setattr(response_obj, attr, attrs.get(attr)) + if additional_properties: + response_obj.additional_properties = additional_properties + return response_obj + except TypeError as err: + msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) + raise DeserializationError(msg + str(err)) + else: + try: + for attr, value in attrs.items(): + setattr(response, attr, value) + return response + except Exception as exp: + msg = "Unable to populate response model. " + msg += "Type: {}, Error: {}".format(type(response), exp) + raise DeserializationError(msg) + + def deserialize_data(self, data, data_type): + """Process data for deserialization according to data type. + + :param str data: The response string to be deserialized. + :param str data_type: The type to deserialize to. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + if data is None: + return data + + try: + if not data_type: + return data + if data_type in self.basic_types.values(): + return self.deserialize_basic(data, data_type) + if data_type in self.deserialize_type: + if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): + return data + + is_a_text_parsing_type = lambda x: x not in ["object", "[]", r"{}"] + if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: + return None + data_val = self.deserialize_type[data_type](data) + return data_val + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.deserialize_type: + return self.deserialize_type[iter_type](data, data_type[1:-1]) + + obj_type = self.dependencies[data_type] + if issubclass(obj_type, Enum): + if isinstance(data, ET.Element): + data = data.text + return self.deserialize_enum(data, obj_type) + + except (ValueError, TypeError, AttributeError) as err: + msg = "Unable to deserialize response data." + msg += " Data: {}, {}".format(data, data_type) + raise_with_traceback(DeserializationError, msg, err) + else: + return self._deserialize(obj_type, data) + + def deserialize_iter(self, attr, iter_type): + """Deserialize an iterable. + + :param list attr: Iterable to be deserialized. + :param str iter_type: The type of object in the iterable. + :rtype: list + """ + if attr is None: + return None + if isinstance(attr, ET.Element): # If I receive an element here, get the children + attr = list(attr) + if not isinstance(attr, (list, set)): + raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) + return [self.deserialize_data(a, iter_type) for a in attr] + + def deserialize_dict(self, attr, dict_type): + """Deserialize a dictionary. + + :param dict/list attr: Dictionary to be deserialized. Also accepts + a list of key, value pairs. + :param str dict_type: The object type of the items in the dictionary. + :rtype: dict + """ + if isinstance(attr, list): + return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} + + if isinstance(attr, ET.Element): + # Transform value into {"Key": "value"} + attr = {el.tag: el.text for el in attr} + return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} + + def deserialize_object(self, attr, **kwargs): + """Deserialize a generic object. + This will be handled as a dictionary. + + :param dict attr: Dictionary to be deserialized. + :rtype: dict + :raises: TypeError if non-builtin datatype encountered. + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + # Do no recurse on XML, just return the tree as-is + return attr + if isinstance(attr, basestring): + return self.deserialize_basic(attr, "str") + obj_type = type(attr) + if obj_type in self.basic_types: + return self.deserialize_basic(attr, self.basic_types[obj_type]) + if obj_type is _long_type: + return self.deserialize_long(attr) + + if obj_type == dict: + deserialized = {} + for key, value in attr.items(): + try: + deserialized[key] = self.deserialize_object(value, **kwargs) + except ValueError: + deserialized[key] = None + return deserialized + + if obj_type == list: + deserialized = [] + for obj in attr: + try: + deserialized.append(self.deserialize_object(obj, **kwargs)) + except ValueError: + pass + return deserialized + + else: + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) + + def deserialize_basic(self, attr, data_type): + """Deserialize basic builtin data type from string. + Will attempt to convert to str, int, float and bool. + This function will also accept '1', '0', 'true' and 'false' as + valid bool values. + + :param str attr: response string to be deserialized. + :param str data_type: deserialization data type. + :rtype: str, int, float or bool + :raises: TypeError if string format is not valid. + """ + # If we're here, data is supposed to be a basic type. + # If it's still an XML node, take the text + if isinstance(attr, ET.Element): + attr = attr.text + if not attr: + if data_type == "str": + # None or '', node is empty string. + return "" + else: + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None + + if data_type == "bool": + if attr in [True, False, 1, 0]: + return bool(attr) + elif isinstance(attr, basestring): + if attr.lower() in ["true", "1"]: + return True + elif attr.lower() in ["false", "0"]: + return False + raise TypeError("Invalid boolean value: {}".format(attr)) + + if data_type == "str": + return self.deserialize_unicode(attr) + return eval(data_type)(attr) # nosec + + @staticmethod + def deserialize_unicode(data): + """Preserve unicode objects in Python 2, otherwise return data + as a string. + + :param str data: response string to be deserialized. + :rtype: str or unicode + """ + # We might be here because we have an enum modeled as string, + # and we try to deserialize a partial dict with enum inside + if isinstance(data, Enum): + return data + + # Consider this is real string + try: + if isinstance(data, unicode): + return data + except NameError: + return str(data) + else: + return str(data) + + @staticmethod + def deserialize_enum(data, enum_obj): + """Deserialize string into enum object. + + If the string is not a valid enum value it will be returned as-is + and a warning will be logged. + + :param str data: Response string to be deserialized. If this value is + None or invalid it will be returned as-is. + :param Enum enum_obj: Enum object to deserialize to. + :rtype: Enum + """ + if isinstance(data, enum_obj) or data is None: + return data + if isinstance(data, Enum): + data = data.value + if isinstance(data, int): + # Workaround. We might consider remove it in the future. + # https://github.com/Azure/azure-rest-api-specs/issues/141 + try: + return list(enum_obj.__members__.values())[data] + except IndexError: + error = "{!r} is not a valid index for enum {!r}" + raise DeserializationError(error.format(data, enum_obj)) + try: + return enum_obj(str(data)) + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(data).lower(): + return enum_value + # We don't fail anymore for unknown value, we deserialize as a string + _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) + return Deserializer.deserialize_unicode(data) + + @staticmethod + def deserialize_bytearray(attr): + """Deserialize string into bytearray. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return bytearray(b64decode(attr)) + + @staticmethod + def deserialize_base64(attr): + """Deserialize base64 encoded string into string. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + padding = "=" * (3 - (len(attr) + 3) % 4) + attr = attr + padding + encoded = attr.replace("-", "+").replace("_", "/") + return b64decode(encoded) + + @staticmethod + def deserialize_decimal(attr): + """Deserialize string into Decimal object. + + :param str attr: response string to be deserialized. + :rtype: Decimal + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + return decimal.Decimal(attr) + except decimal.DecimalException as err: + msg = "Invalid decimal {}".format(attr) + raise_with_traceback(DeserializationError, msg, err) + + @staticmethod + def deserialize_long(attr): + """Deserialize string into long (Py2) or int (Py3). + + :param str attr: response string to be deserialized. + :rtype: long or int + :raises: ValueError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return _long_type(attr) + + @staticmethod + def deserialize_duration(attr): + """Deserialize ISO-8601 formatted string into TimeDelta object. + + :param str attr: response string to be deserialized. + :rtype: TimeDelta + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + duration = isodate.parse_duration(attr) + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize duration object." + raise_with_traceback(DeserializationError, msg, err) + else: + return duration + + @staticmethod + def deserialize_date(attr): + """Deserialize ISO-8601 formatted string into Date object. + + :param str attr: response string to be deserialized. + :rtype: Date + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. + return isodate.parse_date(attr, defaultmonth=None, defaultday=None) + + @staticmethod + def deserialize_time(attr): + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + return isodate.parse_time(attr) + + @staticmethod + def deserialize_rfc(attr): + """Deserialize RFC-1123 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + parsed_date = email.utils.parsedate_tz(attr) + date_obj = datetime.datetime( + *parsed_date[:6], tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) + ) + if not date_obj.tzinfo: + date_obj = date_obj.astimezone(tz=TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to rfc datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_iso(attr): + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + attr = attr.upper() + match = Deserializer.valid_date.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split(".") + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_unix(attr): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param int attr: Object to be serialized. + :rtype: Datetime + :raises: DeserializationError if format invalid + """ + if isinstance(attr, ET.Element): + attr = int(attr.text) + try: + date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to unix datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj 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..9aad73fc743e --- /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/aio/__init__.py b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/__init__.py index 9bee3ede0ebd..0776826a3696 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 @@ -7,4 +7,15 @@ # -------------------------------------------------------------------------- from ._azure_arc_vmware_management_service_api import AzureArcVMwareManagementServiceAPI -__all__ = ['AzureArcVMwareManagementServiceAPI'] + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["AzureArcVMwareManagementServiceAPI"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_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..7fa8b6c96b3b 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,38 +6,43 @@ # 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, 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 .._serialization import Deserializer, Serializer +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: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Self service experience for VMware. :ivar operations: Operations operations :vartype operations: azure.mgmt.connectedvmware.aio.operations.Operations + :ivar virtual_machines: VirtualMachinesOperations operations + :vartype virtual_machines: azure.mgmt.connectedvmware.aio.operations.VirtualMachinesOperations :ivar resource_pools: ResourcePoolsOperations operations :vartype resource_pools: azure.mgmt.connectedvmware.aio.operations.ResourcePoolsOperations :ivar clusters: ClustersOperations operations @@ -48,88 +53,95 @@ class AzureArcVMwareManagementServiceAPI(object): :vartype datastores: azure.mgmt.connectedvmware.aio.operations.DatastoresOperations :ivar vcenters: VCentersOperations operations :vartype vcenters: azure.mgmt.connectedvmware.aio.operations.VCentersOperations - :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. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The Subscription ID. + :param subscription_id: The Subscription ID. Required. :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 api_version: Api Version. Default value is "2022-01-10-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: 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.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._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.virtual_machines = VirtualMachinesOperations( - self._client, self._config, self._serialize, self._deserialize) + 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_machine_templates = VirtualMachineTemplatesOperations( - self._client, self._config, self._serialize, self._deserialize) + 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._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._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._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/dpcodegen/python/send_request + + :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..0b31aa27ba94 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 @@ -19,49 +19,48 @@ from azure.core.credentials_async import AsyncTokenCredential -class AzureArcVMwareManagementServiceAPIConfiguration(Configuration): +class AzureArcVMwareManagementServiceAPIConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AzureArcVMwareManagementServiceAPI. Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The Subscription ID. + :param subscription_id: The Subscription ID. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-01-10-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(AzureArcVMwareManagementServiceAPIConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2022-01-10-preview") # type: str + 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 - self.api_version = "2020-10-01-preview" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-connectedvmware/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-connectedvmware/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ) -> None: - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/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..f7dd32510333 --- /dev/null +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/__init__.py b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/__init__.py index de63ef86d5dd..f3aa61c6c8b8 100644 --- a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/__init__.py +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/__init__.py @@ -7,12 +7,12 @@ # -------------------------------------------------------------------------- from ._operations import Operations +from ._virtual_machines_operations import VirtualMachinesOperations from ._resource_pools_operations import ResourcePoolsOperations from ._clusters_operations import ClustersOperations from ._hosts_operations import HostsOperations from ._datastores_operations import DatastoresOperations from ._vcenters_operations import VCentersOperations -from ._virtual_machines_operations import VirtualMachinesOperations from ._virtual_machine_templates_operations import VirtualMachineTemplatesOperations from ._virtual_networks_operations import VirtualNetworksOperations from ._inventory_items_operations import InventoryItemsOperations @@ -20,18 +20,24 @@ from ._machine_extensions_operations import MachineExtensionsOperations from ._guest_agents_operations import GuestAgentsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'ResourcePoolsOperations', - 'ClustersOperations', - 'HostsOperations', - 'DatastoresOperations', - 'VCentersOperations', - 'VirtualMachinesOperations', - 'VirtualMachineTemplatesOperations', - 'VirtualNetworksOperations', - 'InventoryItemsOperations', - 'HybridIdentityMetadataOperations', - 'MachineExtensionsOperations', - 'GuestAgentsOperations', + "Operations", + "VirtualMachinesOperations", + "ResourcePoolsOperations", + "ClustersOperations", + "HostsOperations", + "DatastoresOperations", + "VCentersOperations", + "VirtualMachineTemplatesOperations", + "VirtualNetworksOperations", + "InventoryItemsOperations", + "HybridIdentityMetadataOperations", + "MachineExtensionsOperations", + "GuestAgentsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() 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..c764376f195d 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,475 +6,637 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._clusters_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ClustersOperations: - """ClustersOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ClustersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.connectedvmware.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.connectedvmware.aio.AzureArcVMwareManagementServiceAPI`'s + :attr:`clusters` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _create_initial( self, resource_group_name: str, cluster_name: str, - body: Optional["_models.Cluster"] = None, + body: Optional[Union[_models.Cluster, IO]] = 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') - - # 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') + ) -> _models.Cluster: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Cluster] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - body_content = None - 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) + if body is not None: + _json = self._serialize.body(body, "Cluster") + else: + _json = None + + request = build_create_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Cluster', pipeline_response) + deserialized = self._deserialize("Cluster", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Cluster', pipeline_response) + deserialized = self._deserialize("Cluster", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters/{clusterName}'} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters/{clusterName}"} # type: ignore + + @overload async def begin_create( self, resource_group_name: str, cluster_name: str, - body: Optional["_models.Cluster"] = None, + body: Optional[_models.Cluster] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.Cluster"]: + ) -> AsyncLROPoller[_models.Cluster]: """Implements cluster PUT method. Create Or Update cluster. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param cluster_name: Name of the cluster. + :param cluster_name: Name of the cluster. Required. :type cluster_name: str - :param body: Request payload. + :param body: Request payload. Default value is None. :type body: ~azure.mgmt.connectedvmware.models.Cluster + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. - :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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Cluster"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create( + self, + resource_group_name: str, + cluster_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Cluster]: + """Implements cluster PUT method. + + Create Or Update cluster. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param cluster_name: Name of the cluster. Required. + :type cluster_name: str + :param body: Request payload. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + cluster_name: str, + body: Optional[Union[_models.Cluster, IO]] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.Cluster]: + """Implements cluster PUT method. + + Create Or Update cluster. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param cluster_name: Name of the cluster. Required. + :type cluster_name: str + :param body: Request payload. Is either a model type or a IO type. Default value is None. + :type body: ~azure.mgmt.connectedvmware.models.Cluster or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Cluster] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_initial( + raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, body=body, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Cluster', pipeline_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) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - 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 + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - async def get( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> "_models.Cluster": + 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, cluster_name: str, **kwargs: Any) -> _models.Cluster: """Gets a cluster. Implements cluster GET method. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param cluster_name: Name of the cluster. + :param cluster_name: Name of the cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Cluster, or the result of cls(response) + :return: Cluster or the result of cls(response) :rtype: ~azure.mgmt.connectedvmware.models.Cluster - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - 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" - 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 = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Cluster] + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + deserialized = self._deserialize("Cluster", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters/{clusterName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters/{clusterName}"} # type: ignore + + @overload async def update( self, resource_group_name: str, cluster_name: str, - body: Optional["_models.ResourcePatch"] = None, + body: Optional[_models.ResourcePatch] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.Cluster": + ) -> _models.Cluster: """Updates a cluster. API to update certain properties of the cluster resource. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param cluster_name: Name of the cluster. + :param cluster_name: Name of the cluster. Required. :type cluster_name: str - :param body: Resource properties to update. + :param body: Resource properties to update. Default value is None. :type body: ~azure.mgmt.connectedvmware.models.ResourcePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Cluster, or the result of cls(response) + :return: Cluster or the result of cls(response) :rtype: ~azure.mgmt.connectedvmware.models.Cluster - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - 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.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') - - body_content_kwargs = {} # type: Dict[str, Any] - if body is not None: - body_content = self._serialize.body(body, 'ResourcePatch') + + @overload + async def update( + self, + resource_group_name: str, + cluster_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Cluster: + """Updates a cluster. + + API to update certain properties of the cluster resource. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param cluster_name: Name of the cluster. Required. + :type cluster_name: str + :param body: Resource properties to update. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Cluster or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.Cluster + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + cluster_name: str, + body: Optional[Union[_models.ResourcePatch, IO]] = None, + **kwargs: Any + ) -> _models.Cluster: + """Updates a cluster. + + API to update certain properties of the cluster resource. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param cluster_name: Name of the cluster. Required. + :type cluster_name: str + :param body: Resource properties to update. Is either a model type or a IO type. Default value + is None. + :type body: ~azure.mgmt.connectedvmware.models.ResourcePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Cluster or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.Cluster + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Cluster] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - body_content = None - 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) + if body is not None: + _json = self._serialize.body(body, "ResourcePatch") + else: + _json = None + + request = build_update_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + deserialized = self._deserialize("Cluster", pipeline_response) if cls: 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, - cluster_name: str, - force: Optional[bool] = None, - **kwargs: Any + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters/{clusterName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, 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 = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + force=force, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters/{clusterName}'} # type: ignore + _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, - cluster_name: str, - force: Optional[bool] = None, - **kwargs: Any + self, resource_group_name: str, cluster_name: str, force: Optional[bool] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes an cluster. Implements cluster DELETE method. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param cluster_name: Name of the cluster. + :param cluster_name: Name of the cluster. Required. :type cluster_name: str - :param force: Whether force delete was specified. + :param force: Whether force delete was specified. Default value is None. :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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, force=force, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements 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) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - 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 + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.ClustersList"]: + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters/{clusterName}"} # type: ignore + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.Cluster"]: """Implements GET clusters in a subscription. List of clusters 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 ClustersList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.ClustersList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Cluster or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClustersList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ClustersList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): 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, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -482,71 +645,71 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) 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 + return AsyncItemPaged(get_next, extract_data) - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ClustersList"]: + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/clusters"} # type: ignore + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Cluster"]: """Implements GET clusters in a resource group. List of clusters in a resource group. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :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] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Cluster or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClustersList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ClustersList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): 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( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -555,17 +718,18 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters"} # type: ignore 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..3de68351ce5f 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,475 +6,637 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._datastores_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class DatastoresOperations: - """DatastoresOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DatastoresOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.connectedvmware.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.connectedvmware.aio.AzureArcVMwareManagementServiceAPI`'s + :attr:`datastores` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _create_initial( self, resource_group_name: str, datastore_name: str, - body: Optional["_models.Datastore"] = None, + body: Optional[Union[_models.Datastore, IO]] = 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') - - # 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') + ) -> _models.Datastore: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Datastore] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - body_content = None - 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) + if body is not None: + _json = self._serialize.body(body, "Datastore") + else: + _json = None + + request = build_create_request( + resource_group_name=resource_group_name, + datastore_name=datastore_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Datastore', pipeline_response) + deserialized = self._deserialize("Datastore", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Datastore', pipeline_response) + deserialized = self._deserialize("Datastore", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores/{datastoreName}'} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores/{datastoreName}"} # type: ignore + + @overload async def begin_create( self, resource_group_name: str, datastore_name: str, - body: Optional["_models.Datastore"] = None, + body: Optional[_models.Datastore] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.Datastore"]: + ) -> AsyncLROPoller[_models.Datastore]: """Implements datastore PUT method. Create Or Update datastore. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param datastore_name: Name of the datastore. + :param datastore_name: Name of the datastore. Required. :type datastore_name: str - :param body: Request payload. + :param body: Request payload. Default value is None. :type body: ~azure.mgmt.connectedvmware.models.Datastore + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. - :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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Datastore"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create( + self, + resource_group_name: str, + datastore_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Datastore]: + """Implements datastore PUT method. + + Create Or Update datastore. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param datastore_name: Name of the datastore. Required. + :type datastore_name: str + :param body: Request payload. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.Datastore] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + datastore_name: str, + body: Optional[Union[_models.Datastore, IO]] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.Datastore]: + """Implements datastore PUT method. + + Create Or Update datastore. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param datastore_name: Name of the datastore. Required. + :type datastore_name: str + :param body: Request payload. Is either a model type or a IO type. Default value is None. + :type body: ~azure.mgmt.connectedvmware.models.Datastore or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.Datastore] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Datastore] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_initial( + raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, datastore_name=datastore_name, body=body, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Datastore', pipeline_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) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - 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 + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - async def get( - self, - resource_group_name: str, - datastore_name: str, - **kwargs: Any - ) -> "_models.Datastore": + 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, datastore_name: str, **kwargs: Any) -> _models.Datastore: """Gets a datastore. Implements datastore GET method. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param datastore_name: Name of the datastore. + :param datastore_name: Name of the datastore. Required. :type datastore_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Datastore, or the result of cls(response) + :return: Datastore or the result of cls(response) :rtype: ~azure.mgmt.connectedvmware.models.Datastore - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - 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" - 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 = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Datastore] + + request = build_get_request( + resource_group_name=resource_group_name, + datastore_name=datastore_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + deserialized = self._deserialize("Datastore", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores/{datastoreName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores/{datastoreName}"} # type: ignore + + @overload async def update( self, resource_group_name: str, datastore_name: str, - body: Optional["_models.ResourcePatch"] = None, + body: Optional[_models.ResourcePatch] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.Datastore": + ) -> _models.Datastore: """Updates a datastore. API to update certain properties of the datastore resource. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param datastore_name: Name of the datastore. + :param datastore_name: Name of the datastore. Required. :type datastore_name: str - :param body: Resource properties to update. + :param body: Resource properties to update. Default value is None. :type body: ~azure.mgmt.connectedvmware.models.ResourcePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Datastore, or the result of cls(response) + :return: Datastore or the result of cls(response) :rtype: ~azure.mgmt.connectedvmware.models.Datastore - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - 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.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') - - body_content_kwargs = {} # type: Dict[str, Any] - if body is not None: - body_content = self._serialize.body(body, 'ResourcePatch') + + @overload + async def update( + self, + resource_group_name: str, + datastore_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Datastore: + """Updates a datastore. + + API to update certain properties of the datastore resource. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param datastore_name: Name of the datastore. Required. + :type datastore_name: str + :param body: Resource properties to update. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Datastore or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.Datastore + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + datastore_name: str, + body: Optional[Union[_models.ResourcePatch, IO]] = None, + **kwargs: Any + ) -> _models.Datastore: + """Updates a datastore. + + API to update certain properties of the datastore resource. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param datastore_name: Name of the datastore. Required. + :type datastore_name: str + :param body: Resource properties to update. Is either a model type or a IO type. Default value + is None. + :type body: ~azure.mgmt.connectedvmware.models.ResourcePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Datastore or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.Datastore + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Datastore] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - body_content = None - 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) + if body is not None: + _json = self._serialize.body(body, "ResourcePatch") + else: + _json = None + + request = build_update_request( + resource_group_name=resource_group_name, + datastore_name=datastore_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + deserialized = self._deserialize("Datastore", pipeline_response) if cls: 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, - datastore_name: str, - force: Optional[bool] = None, - **kwargs: Any + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores/{datastoreName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, 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 = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + datastore_name=datastore_name, + subscription_id=self._config.subscription_id, + force=force, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores/{datastoreName}'} # type: ignore + _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, - datastore_name: str, - force: Optional[bool] = None, - **kwargs: Any + self, resource_group_name: str, datastore_name: str, force: Optional[bool] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes an datastore. Implements datastore DELETE method. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param datastore_name: Name of the datastore. + :param datastore_name: Name of the datastore. Required. :type datastore_name: str - :param force: Whether force delete was specified. + :param force: Whether force delete was specified. Default value is None. :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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, datastore_name=datastore_name, force=force, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements 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) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - 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 + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.DatastoresList"]: + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores/{datastoreName}"} # type: ignore + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.Datastore"]: """Implements GET datastores in a subscription. List of datastores 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 DatastoresList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.DatastoresList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Datastore or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.Datastore] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DatastoresList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DatastoresList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): 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, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -482,71 +645,71 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) 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 + return AsyncItemPaged(get_next, extract_data) - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.DatastoresList"]: + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/datastores"} # type: ignore + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Datastore"]: """Implements GET datastores in a resource group. List of datastores in a resource group. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :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] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Datastore or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.Datastore] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DatastoresList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DatastoresList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): 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( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -555,17 +718,18 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores"} # type: ignore 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..6bea85776d91 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,422 +6,519 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._guest_agents_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]] -class GuestAgentsOperations: - """GuestAgentsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class GuestAgentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.connectedvmware.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.connectedvmware.aio.AzureArcVMwareManagementServiceAPI`'s + :attr:`guest_agents` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _create_initial( self, resource_group_name: str, virtual_machine_name: str, name: str, - body: Optional["_models.GuestAgent"] = None, + body: Optional[Union[_models.GuestAgent, IO]] = 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') - - # 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') + ) -> _models.GuestAgent: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GuestAgent] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - body_content = None - 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) + if body is not None: + _json = self._serialize.body(body, "GuestAgent") + else: + _json = None + + request = build_create_request( + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('GuestAgent', pipeline_response) + deserialized = self._deserialize("GuestAgent", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GuestAgent', pipeline_response) + deserialized = self._deserialize("GuestAgent", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/guestAgents/{name}'} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/guestAgents/{name}"} # type: ignore + + @overload async def begin_create( self, resource_group_name: str, virtual_machine_name: str, name: str, - body: Optional["_models.GuestAgent"] = None, + body: Optional[_models.GuestAgent] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.GuestAgent"]: + ) -> AsyncLROPoller[_models.GuestAgent]: """Implements GuestAgent PUT method. Create Or Update GuestAgent. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param virtual_machine_name: Name of the vm. + :param virtual_machine_name: Name of the vm. Required. :type virtual_machine_name: str - :param name: Name of the guestAgents. + :param name: Name of the guestAgents. Required. :type name: str - :param body: Request payload. + :param body: Request payload. Default value is None. :type body: ~azure.mgmt.connectedvmware.models.GuestAgent + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. - :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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestAgent"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create( + self, + resource_group_name: str, + virtual_machine_name: str, + name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GuestAgent]: + """Implements GuestAgent PUT method. + + Create Or Update GuestAgent. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param virtual_machine_name: Name of the vm. Required. + :type virtual_machine_name: str + :param name: Name of the guestAgents. Required. + :type name: str + :param body: Request payload. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.GuestAgent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + virtual_machine_name: str, + name: str, + body: Optional[Union[_models.GuestAgent, IO]] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.GuestAgent]: + """Implements GuestAgent PUT method. + + Create Or Update GuestAgent. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param virtual_machine_name: Name of the vm. Required. + :type virtual_machine_name: str + :param name: Name of the guestAgents. Required. + :type name: str + :param body: Request payload. Is either a model type or a IO type. Default value is None. + :type body: ~azure.mgmt.connectedvmware.models.GuestAgent or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.GuestAgent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GuestAgent] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_initial( + raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, virtual_machine_name=virtual_machine_name, name=name, body=body, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('GuestAgent', pipeline_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) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - 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 + 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, - virtual_machine_name: str, - name: str, - **kwargs: Any - ) -> "_models.GuestAgent": + self, resource_group_name: str, virtual_machine_name: str, name: str, **kwargs: Any + ) -> _models.GuestAgent: """Gets GuestAgent. Implements GuestAgent GET method. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param virtual_machine_name: Name of the vm. + :param virtual_machine_name: Name of the vm. Required. :type virtual_machine_name: str - :param name: Name of the GuestAgent. + :param name: Name of the GuestAgent. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GuestAgent, or the result of cls(response) + :return: GuestAgent or the result of cls(response) :rtype: ~azure.mgmt.connectedvmware.models.GuestAgent - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - 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" - 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 = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GuestAgent] + + request = build_get_request( + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + deserialized = self._deserialize("GuestAgent", pipeline_response) if cls: 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, - virtual_machine_name: str, - name: str, - **kwargs: Any + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/guestAgents/{name}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, 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 = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/guestAgents/{name}'} # type: ignore + _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, - virtual_machine_name: str, - name: str, - **kwargs: Any + self, resource_group_name: str, virtual_machine_name: str, name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes an GuestAgent. Implements GuestAgent DELETE method. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param virtual_machine_name: Name of the vm. + :param virtual_machine_name: Name of the vm. Required. :type virtual_machine_name: str - :param name: Name of the GuestAgent. + :param name: Name of the GuestAgent. Required. :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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, virtual_machine_name=virtual_machine_name, name=name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements 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) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - 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 + 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, - virtual_machine_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.GuestAgentList"]: + self, resource_group_name: str, virtual_machine_name: str, **kwargs: Any + ) -> AsyncIterable["_models.GuestAgent"]: """Implements GET GuestAgent in a vm. Returns the list of GuestAgent of the given vm. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param virtual_machine_name: Name of the vm. + :param virtual_machine_name: Name of the vm. Required. :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] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either GuestAgent or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.GuestAgent] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestAgentList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GuestAgentList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): 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( + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_vm.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -429,17 +527,18 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_vm.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/guestAgents'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list_by_vm.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/guestAgents"} # type: ignore 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..a57123a866c0 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,475 +6,626 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._hosts_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class HostsOperations: - """HostsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class HostsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.connectedvmware.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.connectedvmware.aio.AzureArcVMwareManagementServiceAPI`'s + :attr:`hosts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _create_initial( - self, - 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') - - # 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') + self, resource_group_name: str, host_name: str, body: Optional[Union[_models.Host, IO]] = None, **kwargs: Any + ) -> _models.Host: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Host] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - body_content = None - 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) + if body is not None: + _json = self._serialize.body(body, "Host") + else: + _json = None + + request = build_create_request( + resource_group_name=resource_group_name, + host_name=host_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Host', pipeline_response) + deserialized = self._deserialize("Host", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Host', pipeline_response) + deserialized = self._deserialize("Host", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts/{hostName}'} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts/{hostName}"} # type: ignore + + @overload async def begin_create( self, resource_group_name: str, host_name: str, - body: Optional["_models.Host"] = None, + body: Optional[_models.Host] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.Host"]: + ) -> AsyncLROPoller[_models.Host]: """Implements host PUT method. Create Or Update host. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param host_name: Name of the host. + :param host_name: Name of the host. Required. :type host_name: str - :param body: Request payload. + :param body: Request payload. Default value is None. :type body: ~azure.mgmt.connectedvmware.models.Host + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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 Host or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.Host] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Host"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create( + self, + resource_group_name: str, + host_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Host]: + """Implements host PUT method. + + Create Or Update host. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param host_name: Name of the host. Required. + :type host_name: str + :param body: Request payload. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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 Host or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.Host] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, resource_group_name: str, host_name: str, body: Optional[Union[_models.Host, IO]] = None, **kwargs: Any + ) -> AsyncLROPoller[_models.Host]: + """Implements host PUT method. + + Create Or Update host. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param host_name: Name of the host. Required. + :type host_name: str + :param body: Request payload. Is either a model type or a IO type. Default value is None. + :type body: ~azure.mgmt.connectedvmware.models.Host or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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 Host or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.Host] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Host] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_initial( + raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, host_name=host_name, body=body, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Host', pipeline_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) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - 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 + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - async def get( - self, - resource_group_name: str, - host_name: str, - **kwargs: Any - ) -> "_models.Host": + 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, host_name: str, **kwargs: Any) -> _models.Host: """Gets a host. Implements host GET method. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param host_name: Name of the host. + :param host_name: Name of the host. Required. :type host_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Host, or the result of cls(response) + :return: Host or the result of cls(response) :rtype: ~azure.mgmt.connectedvmware.models.Host - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - 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" - 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 = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Host] + + request = build_get_request( + resource_group_name=resource_group_name, + host_name=host_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + deserialized = self._deserialize("Host", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts/{hostName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts/{hostName}"} # type: ignore + + @overload async def update( self, resource_group_name: str, host_name: str, - body: Optional["_models.ResourcePatch"] = None, + body: Optional[_models.ResourcePatch] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.Host": + ) -> _models.Host: """Updates a host. API to update certain properties of the host resource. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param host_name: Name of the host. + :param host_name: Name of the host. Required. :type host_name: str - :param body: Resource properties to update. + :param body: Resource properties to update. Default value is None. :type body: ~azure.mgmt.connectedvmware.models.ResourcePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Host, or the result of cls(response) + :return: Host or the result of cls(response) :rtype: ~azure.mgmt.connectedvmware.models.Host - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - 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.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') - - body_content_kwargs = {} # type: Dict[str, Any] - if body is not None: - body_content = self._serialize.body(body, 'ResourcePatch') + + @overload + async def update( + self, + resource_group_name: str, + host_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Host: + """Updates a host. + + API to update certain properties of the host resource. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param host_name: Name of the host. Required. + :type host_name: str + :param body: Resource properties to update. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Host or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.Host + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + host_name: str, + body: Optional[Union[_models.ResourcePatch, IO]] = None, + **kwargs: Any + ) -> _models.Host: + """Updates a host. + + API to update certain properties of the host resource. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param host_name: Name of the host. Required. + :type host_name: str + :param body: Resource properties to update. Is either a model type or a IO type. Default value + is None. + :type body: ~azure.mgmt.connectedvmware.models.ResourcePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Host or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.Host + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Host] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - body_content = None - 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) + if body is not None: + _json = self._serialize.body(body, "ResourcePatch") + else: + _json = None + + request = build_update_request( + resource_group_name=resource_group_name, + host_name=host_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + deserialized = self._deserialize("Host", pipeline_response) if cls: 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, - host_name: str, - force: Optional[bool] = None, - **kwargs: Any + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts/{hostName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, 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 = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + host_name=host_name, + subscription_id=self._config.subscription_id, + force=force, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts/{hostName}'} # type: ignore + _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, - host_name: str, - force: Optional[bool] = None, - **kwargs: Any + self, resource_group_name: str, host_name: str, force: Optional[bool] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes an host. Implements host DELETE method. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param host_name: Name of the host. + :param host_name: Name of the host. Required. :type host_name: str - :param force: Whether force delete was specified. + :param force: Whether force delete was specified. Default value is None. :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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, host_name=host_name, force=force, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements 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) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - 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 + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.HostsList"]: + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts/{hostName}"} # type: ignore + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.Host"]: """Implements GET hosts in a subscription. List of hosts 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 HostsList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.HostsList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Host or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.Host] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.HostsList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.HostsList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): 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, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -482,71 +634,71 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) 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 + return AsyncItemPaged(get_next, extract_data) - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.HostsList"]: + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/hosts"} # type: ignore + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Host"]: """Implements GET hosts in a resource group. List of hosts in a resource group. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :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 HostsList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.HostsList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Host or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.Host] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.HostsList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.HostsList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): 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( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -555,17 +707,18 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts"} # type: ignore 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..fc0ce093d91e 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,299 +6,381 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +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]] -class HybridIdentityMetadataOperations: - """HybridIdentityMetadataOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class HybridIdentityMetadataOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.connectedvmware.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.connectedvmware.aio.AzureArcVMwareManagementServiceAPI`'s + :attr:`hybrid_identity_metadata` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @overload async def create( self, resource_group_name: str, virtual_machine_name: str, metadata_name: str, - body: Optional["_models.HybridIdentityMetadata"] = None, + body: Optional[_models.HybridIdentityMetadata] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.HybridIdentityMetadata": + ) -> _models.HybridIdentityMetadata: """Implements HybridIdentityMetadata PUT method. Create Or Update HybridIdentityMetadata. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param virtual_machine_name: Name of the vm. + :param virtual_machine_name: Name of the vm. Required. :type virtual_machine_name: str - :param metadata_name: Name of the hybridIdentityMetadata. + :param metadata_name: Name of the hybridIdentityMetadata. Required. :type metadata_name: str - :param body: Request payload. + :param body: Request payload. Default value is None. :type body: ~azure.mgmt.connectedvmware.models.HybridIdentityMetadata + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: HybridIdentityMetadata, or the result of cls(response) + :return: HybridIdentityMetadata or the result of cls(response) :rtype: ~azure.mgmt.connectedvmware.models.HybridIdentityMetadata - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.HybridIdentityMetadata"] - 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.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') - - body_content_kwargs = {} # type: Dict[str, Any] - if body is not None: - body_content = self._serialize.body(body, 'HybridIdentityMetadata') + + @overload + async def create( + self, + resource_group_name: str, + virtual_machine_name: str, + metadata_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.HybridIdentityMetadata: + """Implements HybridIdentityMetadata PUT method. + + Create Or Update HybridIdentityMetadata. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param virtual_machine_name: Name of the vm. Required. + :type virtual_machine_name: str + :param metadata_name: Name of the hybridIdentityMetadata. Required. + :type metadata_name: str + :param body: Request payload. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: HybridIdentityMetadata or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.HybridIdentityMetadata + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + virtual_machine_name: str, + metadata_name: str, + body: Optional[Union[_models.HybridIdentityMetadata, IO]] = None, + **kwargs: Any + ) -> _models.HybridIdentityMetadata: + """Implements HybridIdentityMetadata PUT method. + + Create Or Update HybridIdentityMetadata. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param virtual_machine_name: Name of the vm. Required. + :type virtual_machine_name: str + :param metadata_name: Name of the hybridIdentityMetadata. Required. + :type metadata_name: str + :param body: Request payload. Is either a model type or a IO type. Default value is None. + :type body: ~azure.mgmt.connectedvmware.models.HybridIdentityMetadata or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: HybridIdentityMetadata or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.HybridIdentityMetadata + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.HybridIdentityMetadata] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - body_content = None - 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) + if body is not None: + _json = self._serialize.body(body, "HybridIdentityMetadata") + else: + _json = None + + request = build_create_request( + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + metadata_name=metadata_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + deserialized = self._deserialize("HybridIdentityMetadata", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/hybridIdentityMetadata/{metadataName}'} # type: ignore + 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, - virtual_machine_name: str, - metadata_name: str, - **kwargs: Any - ) -> "_models.HybridIdentityMetadata": + self, resource_group_name: str, virtual_machine_name: str, metadata_name: str, **kwargs: Any + ) -> _models.HybridIdentityMetadata: """Gets HybridIdentityMetadata. Implements HybridIdentityMetadata GET method. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param virtual_machine_name: Name of the vm. + :param virtual_machine_name: Name of the vm. Required. :type virtual_machine_name: str - :param metadata_name: Name of the HybridIdentityMetadata. + :param metadata_name: Name of the HybridIdentityMetadata. Required. :type metadata_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: HybridIdentityMetadata, or the result of cls(response) + :return: HybridIdentityMetadata or the result of cls(response) :rtype: ~azure.mgmt.connectedvmware.models.HybridIdentityMetadata - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.HybridIdentityMetadata"] - 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.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 = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.HybridIdentityMetadata] + + request = build_get_request( + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + metadata_name=metadata_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + deserialized = self._deserialize("HybridIdentityMetadata", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/hybridIdentityMetadata/{metadataName}'} # type: ignore - async def delete( - self, - resource_group_name: str, - virtual_machine_name: str, - metadata_name: str, - **kwargs: Any + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/hybridIdentityMetadata/{metadataName}"} # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, virtual_machine_name: str, metadata_name: str, **kwargs: Any ) -> None: """Deletes an HybridIdentityMetadata. Implements HybridIdentityMetadata DELETE method. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param virtual_machine_name: Name of the vm. + :param virtual_machine_name: Name of the vm. Required. :type virtual_machine_name: str - :param metadata_name: Name of the HybridIdentityMetadata. + :param metadata_name: Name of the HybridIdentityMetadata. Required. :type metadata_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - 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.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 = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + metadata_name=metadata_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/hybridIdentityMetadata/{metadataName}'} # type: ignore + 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, - virtual_machine_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.HybridIdentityMetadataList"]: + self, resource_group_name: str, virtual_machine_name: str, **kwargs: Any + ) -> AsyncIterable["_models.HybridIdentityMetadata"]: """Implements GET HybridIdentityMetadata in a vm. Returns the list of HybridIdentityMetadata of the given vm. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param virtual_machine_name: Name of the vm. + :param virtual_machine_name: Name of the vm. Required. :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] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either HybridIdentityMetadata or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.HybridIdentityMetadata] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.HybridIdentityMetadataList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.HybridIdentityMetadataList] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): 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( + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_vm.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -306,17 +389,18 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_vm.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/hybridIdentityMetadata'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list_by_vm.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/hybridIdentityMetadata"} # type: ignore 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..e30acb07efee 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,299 +6,380 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - -T = TypeVar('T') +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]] -class InventoryItemsOperations: - """InventoryItemsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class InventoryItemsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.connectedvmware.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.connectedvmware.aio.AzureArcVMwareManagementServiceAPI`'s + :attr:`inventory_items` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @overload async def create( self, resource_group_name: str, vcenter_name: str, inventory_item_name: str, - body: Optional["_models.InventoryItem"] = None, + body: Optional[_models.InventoryItem] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.InventoryItem": + ) -> _models.InventoryItem: """Implements InventoryItem PUT method. Create Or Update InventoryItem. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param vcenter_name: Name of the vCenter. + :param vcenter_name: Name of the vCenter. Required. :type vcenter_name: str - :param inventory_item_name: Name of the inventoryItem. + :param inventory_item_name: Name of the inventoryItem. Required. :type inventory_item_name: str - :param body: Request payload. + :param body: Request payload. Default value is None. :type body: ~azure.mgmt.connectedvmware.models.InventoryItem + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: InventoryItem, or the result of cls(response) + :return: InventoryItem or the result of cls(response) :rtype: ~azure.mgmt.connectedvmware.models.InventoryItem - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.InventoryItem"] - 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.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') - - body_content_kwargs = {} # type: Dict[str, Any] - if body is not None: - body_content = self._serialize.body(body, 'InventoryItem') + + @overload + async def create( + self, + resource_group_name: str, + vcenter_name: str, + inventory_item_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.InventoryItem: + """Implements InventoryItem PUT method. + + Create Or Update InventoryItem. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param vcenter_name: Name of the vCenter. Required. + :type vcenter_name: str + :param inventory_item_name: Name of the inventoryItem. Required. + :type inventory_item_name: str + :param body: Request payload. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: InventoryItem or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.InventoryItem + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + vcenter_name: str, + inventory_item_name: str, + body: Optional[Union[_models.InventoryItem, IO]] = None, + **kwargs: Any + ) -> _models.InventoryItem: + """Implements InventoryItem PUT method. + + Create Or Update InventoryItem. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param vcenter_name: Name of the vCenter. Required. + :type vcenter_name: str + :param inventory_item_name: Name of the inventoryItem. Required. + :type inventory_item_name: str + :param body: Request payload. Is either a model type or a IO type. Default value is None. + :type body: ~azure.mgmt.connectedvmware.models.InventoryItem or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: InventoryItem or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.InventoryItem + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.InventoryItem] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - body_content = None - 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) + if body is not None: + _json = self._serialize.body(body, "InventoryItem") + else: + _json = None + + request = build_create_request( + resource_group_name=resource_group_name, + vcenter_name=vcenter_name, + inventory_item_name=inventory_item_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + deserialized = self._deserialize("InventoryItem", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}/inventoryItems/{inventoryItemName}'} # type: ignore + 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, - vcenter_name: str, - inventory_item_name: str, - **kwargs: Any - ) -> "_models.InventoryItem": + self, resource_group_name: str, vcenter_name: str, inventory_item_name: str, **kwargs: Any + ) -> _models.InventoryItem: """Gets InventoryItem. Implements InventoryItem GET method. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param vcenter_name: Name of the vCenter. + :param vcenter_name: Name of the vCenter. Required. :type vcenter_name: str - :param inventory_item_name: Name of the inventoryItem. + :param inventory_item_name: Name of the inventoryItem. Required. :type inventory_item_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: InventoryItem, or the result of cls(response) + :return: InventoryItem or the result of cls(response) :rtype: ~azure.mgmt.connectedvmware.models.InventoryItem - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.InventoryItem"] - 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.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 = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.InventoryItem] + + request = build_get_request( + resource_group_name=resource_group_name, + vcenter_name=vcenter_name, + inventory_item_name=inventory_item_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + deserialized = self._deserialize("InventoryItem", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}/inventoryItems/{inventoryItemName}'} # type: ignore - async def delete( - self, - resource_group_name: str, - vcenter_name: str, - inventory_item_name: str, - **kwargs: Any + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}/inventoryItems/{inventoryItemName}"} # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, vcenter_name: str, inventory_item_name: str, **kwargs: Any ) -> None: """Deletes an inventoryItem. Implements inventoryItem DELETE method. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param vcenter_name: Name of the vCenter. + :param vcenter_name: Name of the vCenter. Required. :type vcenter_name: str - :param inventory_item_name: Name of the inventoryItem. + :param inventory_item_name: Name of the inventoryItem. Required. :type inventory_item_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - 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.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 = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + vcenter_name=vcenter_name, + inventory_item_name=inventory_item_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}/inventoryItems/{inventoryItemName}'} # type: ignore + 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, - vcenter_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.InventoryItemsList"]: + self, resource_group_name: str, vcenter_name: str, **kwargs: Any + ) -> AsyncIterable["_models.InventoryItem"]: """Implements GET inventoryItems in a vCenter. Returns the list of inventoryItems of the given vCenter. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param vcenter_name: Name of the vCenter. + :param vcenter_name: Name of the vCenter. Required. :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] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either InventoryItem or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.InventoryItem] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.InventoryItemsList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.InventoryItemsList] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): 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( + resource_group_name=resource_group_name, + vcenter_name=vcenter_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_v_center.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -306,17 +388,18 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_v_center.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}/inventoryItems'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list_by_v_center.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}/inventoryItems"} # type: ignore 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..c1153e50330e 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,552 +6,745 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._machine_extensions_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class MachineExtensionsOperations: - """MachineExtensionsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class MachineExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.connectedvmware.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.connectedvmware.aio.AzureArcVMwareManagementServiceAPI`'s + :attr:`machine_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _create_or_update_initial( self, resource_group_name: str, name: str, extension_name: str, - extension_parameters: "_models.MachineExtension", + extension_parameters: Union[_models.MachineExtension, IO], **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') - - # 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] - 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) + ) -> _models.MachineExtension: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MachineExtension] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(extension_parameters, (IO, bytes)): + _content = extension_parameters + else: + _json = self._serialize.body(extension_parameters, "MachineExtension") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + name=name, + extension_name=extension_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('MachineExtension', pipeline_response) + deserialized = self._deserialize("MachineExtension", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('MachineExtension', pipeline_response) + deserialized = self._deserialize("MachineExtension", pipeline_response) if cls: 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 + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}"} # type: ignore + + @overload async def begin_create_or_update( self, resource_group_name: str, name: str, extension_name: str, - extension_parameters: "_models.MachineExtension", + extension_parameters: _models.MachineExtension, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.MachineExtension"]: + ) -> AsyncLROPoller[_models.MachineExtension]: """The operation to create or update the extension. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str :param name: The name of the machine where the extension should be created or updated. + Required. :type name: str - :param extension_name: The name of the machine extension. + :param extension_name: The name of the machine extension. Required. :type extension_name: str :param extension_parameters: Parameters supplied to the Create Machine Extension operation. + Required. :type extension_parameters: ~azure.mgmt.connectedvmware.models.MachineExtension + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. - :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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.MachineExtension"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + name: str, + extension_name: str, + extension_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MachineExtension]: + """The operation to create or update the extension. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param name: The name of the machine where the extension should be created or updated. + Required. + :type name: str + :param extension_name: The name of the machine extension. Required. + :type extension_name: str + :param extension_parameters: Parameters supplied to the Create Machine Extension operation. + Required. + :type extension_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.MachineExtension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + name: str, + extension_name: str, + extension_parameters: Union[_models.MachineExtension, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.MachineExtension]: + """The operation to create or update the extension. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param name: The name of the machine where the extension should be created or updated. + Required. + :type name: str + :param extension_name: The name of the machine extension. Required. + :type extension_name: str + :param extension_parameters: Parameters supplied to the Create Machine Extension operation. Is + either a model type or a IO type. Required. + :type extension_parameters: ~azure.mgmt.connectedvmware.models.MachineExtension or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.MachineExtension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MachineExtension] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, name=name, extension_name=extension_name, extension_parameters=extension_parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('MachineExtension', pipeline_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) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - 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 + 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( self, resource_group_name: str, name: str, extension_name: str, - extension_parameters: "_models.MachineExtensionUpdate", + extension_parameters: Union[_models.MachineExtensionUpdate, IO], **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') - - # 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] - 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) + ) -> _models.MachineExtension: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MachineExtension] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(extension_parameters, (IO, bytes)): + _content = extension_parameters + else: + _json = self._serialize.body(extension_parameters, "MachineExtensionUpdate") + + request = build_update_request( + resource_group_name=resource_group_name, + name=name, + extension_name=extension_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('MachineExtension', pipeline_response) + deserialized = self._deserialize("MachineExtension", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('MachineExtension', pipeline_response) + deserialized = self._deserialize("MachineExtension", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}'} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}"} # type: ignore + + @overload async def begin_update( self, resource_group_name: str, name: str, extension_name: str, - extension_parameters: "_models.MachineExtensionUpdate", + extension_parameters: _models.MachineExtensionUpdate, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.MachineExtension"]: + ) -> AsyncLROPoller[_models.MachineExtension]: """The operation to update the extension. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str :param name: The name of the machine where the extension should be created or updated. + Required. :type name: str - :param extension_name: The name of the machine extension. + :param extension_name: The name of the machine extension. Required. :type extension_name: str :param extension_parameters: Parameters supplied to the Create Machine Extension operation. + Required. :type extension_parameters: ~azure.mgmt.connectedvmware.models.MachineExtensionUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. - :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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.MachineExtension"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_update( + self, + resource_group_name: str, + name: str, + extension_name: str, + extension_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.MachineExtension]: + """The operation to update the extension. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param name: The name of the machine where the extension should be created or updated. + Required. + :type name: str + :param extension_name: The name of the machine extension. Required. + :type extension_name: str + :param extension_parameters: Parameters supplied to the Create Machine Extension operation. + Required. + :type extension_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.MachineExtension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + name: str, + extension_name: str, + extension_parameters: Union[_models.MachineExtensionUpdate, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.MachineExtension]: + """The operation to update the extension. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param name: The name of the machine where the extension should be created or updated. + Required. + :type name: str + :param extension_name: The name of the machine extension. Required. + :type extension_name: str + :param extension_parameters: Parameters supplied to the Create Machine Extension operation. Is + either a model type or a IO type. Required. + :type extension_parameters: ~azure.mgmt.connectedvmware.models.MachineExtensionUpdate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.MachineExtension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MachineExtension] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, name=name, extension_name=extension_name, extension_parameters=extension_parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('MachineExtension', pipeline_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) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - 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 + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - async def _delete_initial( - self, - resource_group_name: str, - name: str, - extension_name: str, - **kwargs: Any + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, 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 = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + name=name, + extension_name=extension_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}'} # type: ignore + _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, - name: str, - extension_name: str, - **kwargs: Any + self, resource_group_name: str, name: str, extension_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """The operation to delete the extension. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param name: The name of the machine where the extension should be deleted. + :param name: The name of the machine where the extension should be deleted. Required. :type name: str - :param extension_name: The name of the machine extension. + :param extension_name: The name of the machine extension. Required. :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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, name=name, extension_name=extension_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements 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) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - 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 + 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, - name: str, - extension_name: str, - **kwargs: Any - ) -> "_models.MachineExtension": + self, 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. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param name: The name of the machine containing the extension. + :param name: The name of the machine containing the extension. Required. :type name: str - :param extension_name: The name of the machine extension. + :param extension_name: The name of the machine extension. Required. :type extension_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MachineExtension, or the result of cls(response) + :return: MachineExtension or the result of cls(response) :rtype: ~azure.mgmt.connectedvmware.models.MachineExtension - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - 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" - 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 = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MachineExtension] + + request = build_get_request( + resource_group_name=resource_group_name, + name=name, + extension_name=extension_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + deserialized = self._deserialize("MachineExtension", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}'} # type: ignore + 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, - name: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.MachineExtensionsListResult"]: + self, resource_group_name: str, name: str, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.MachineExtension"]: """The operation to get all extensions of a non-Azure machine. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param name: The name of the machine containing the extension. + :param name: The name of the machine containing the extension. Required. :type name: str - :param expand: The expand expression to apply on the operation. + :param expand: The expand expression to apply on the operation. Default value is None. :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] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either MachineExtension or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.MachineExtension] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MachineExtensionsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MachineExtensionsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): 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( + resource_group_name=resource_group_name, + name=name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -559,17 +753,18 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions"} # type: ignore 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..64742982791a 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,82 +6,94 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict 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') +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.connectedvmware.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.connectedvmware.aio.AzureArcVMwareManagementServiceAPI`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.OperationsList"]: + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Returns list of all operations. :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] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationsList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationsList] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): 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 = self._client.get(url, query_parameters, header_parameters) + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -89,17 +102,18 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) 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': '/providers/Microsoft.ConnectedVMwarevSphere/operations'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.ConnectedVMwarevSphere/operations"} # type: ignore diff --git a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_patch.py b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ 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..cabb39ab9a47 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,475 +6,638 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._resource_pools_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ResourcePoolsOperations: - """ResourcePoolsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ResourcePoolsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.connectedvmware.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.connectedvmware.aio.AzureArcVMwareManagementServiceAPI`'s + :attr:`resource_pools` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _create_initial( self, resource_group_name: str, resource_pool_name: str, - body: Optional["_models.ResourcePool"] = None, + body: Optional[Union[_models.ResourcePool, IO]] = 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') - - # 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') + ) -> _models.ResourcePool: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourcePool] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - body_content = None - 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) + if body is not None: + _json = self._serialize.body(body, "ResourcePool") + else: + _json = None + + request = build_create_request( + resource_group_name=resource_group_name, + resource_pool_name=resource_pool_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ResourcePool', pipeline_response) + deserialized = self._deserialize("ResourcePool", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ResourcePool', pipeline_response) + deserialized = self._deserialize("ResourcePool", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools/{resourcePoolName}'} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools/{resourcePoolName}"} # type: ignore + + @overload async def begin_create( self, resource_group_name: str, resource_pool_name: str, - body: Optional["_models.ResourcePool"] = None, + body: Optional[_models.ResourcePool] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.ResourcePool"]: + ) -> AsyncLROPoller[_models.ResourcePool]: """Implements resourcePool PUT method. Create Or Update resourcePool. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param resource_pool_name: Name of the resourcePool. + :param resource_pool_name: Name of the resourcePool. Required. :type resource_pool_name: str - :param body: Request payload. + :param body: Request payload. Default value is None. :type body: ~azure.mgmt.connectedvmware.models.ResourcePool + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. - :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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourcePool"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create( + self, + resource_group_name: str, + resource_pool_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ResourcePool]: + """Implements resourcePool PUT method. + + Create Or Update resourcePool. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param resource_pool_name: Name of the resourcePool. Required. + :type resource_pool_name: str + :param body: Request payload. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.ResourcePool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + resource_pool_name: str, + body: Optional[Union[_models.ResourcePool, IO]] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.ResourcePool]: + """Implements resourcePool PUT method. + + Create Or Update resourcePool. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param resource_pool_name: Name of the resourcePool. Required. + :type resource_pool_name: str + :param body: Request payload. Is either a model type or a IO type. Default value is None. + :type body: ~azure.mgmt.connectedvmware.models.ResourcePool or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.ResourcePool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourcePool] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_initial( + raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, resource_pool_name=resource_pool_name, body=body, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ResourcePool', pipeline_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) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - 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 + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - async def get( - self, - resource_group_name: str, - resource_pool_name: str, - **kwargs: Any - ) -> "_models.ResourcePool": + 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, resource_pool_name: str, **kwargs: Any) -> _models.ResourcePool: """Gets a resourcePool. Implements resourcePool GET method. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param resource_pool_name: Name of the resourcePool. + :param resource_pool_name: Name of the resourcePool. Required. :type resource_pool_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourcePool, or the result of cls(response) + :return: ResourcePool or the result of cls(response) :rtype: ~azure.mgmt.connectedvmware.models.ResourcePool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - 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" - 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 = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourcePool] + + request = build_get_request( + resource_group_name=resource_group_name, + resource_pool_name=resource_pool_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + deserialized = self._deserialize("ResourcePool", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools/{resourcePoolName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools/{resourcePoolName}"} # type: ignore + + @overload async def update( self, resource_group_name: str, resource_pool_name: str, - body: Optional["_models.ResourcePatch"] = None, + body: Optional[_models.ResourcePatch] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ResourcePool": + ) -> _models.ResourcePool: """Updates a resourcePool. API to update certain properties of the resourcePool resource. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param resource_pool_name: Name of the resourcePool. + :param resource_pool_name: Name of the resourcePool. Required. :type resource_pool_name: str - :param body: Resource properties to update. + :param body: Resource properties to update. Default value is None. :type body: ~azure.mgmt.connectedvmware.models.ResourcePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourcePool, or the result of cls(response) + :return: ResourcePool or the result of cls(response) :rtype: ~azure.mgmt.connectedvmware.models.ResourcePool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - 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.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') - - body_content_kwargs = {} # type: Dict[str, Any] - if body is not None: - body_content = self._serialize.body(body, 'ResourcePatch') + + @overload + async def update( + self, + resource_group_name: str, + resource_pool_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ResourcePool: + """Updates a resourcePool. + + API to update certain properties of the resourcePool resource. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param resource_pool_name: Name of the resourcePool. Required. + :type resource_pool_name: str + :param body: Resource properties to update. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourcePool or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.ResourcePool + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + resource_pool_name: str, + body: Optional[Union[_models.ResourcePatch, IO]] = None, + **kwargs: Any + ) -> _models.ResourcePool: + """Updates a resourcePool. + + API to update certain properties of the resourcePool resource. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param resource_pool_name: Name of the resourcePool. Required. + :type resource_pool_name: str + :param body: Resource properties to update. Is either a model type or a IO type. Default value + is None. + :type body: ~azure.mgmt.connectedvmware.models.ResourcePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourcePool or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.ResourcePool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourcePool] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - body_content = None - 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) + if body is not None: + _json = self._serialize.body(body, "ResourcePatch") + else: + _json = None + + request = build_update_request( + resource_group_name=resource_group_name, + resource_pool_name=resource_pool_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + deserialized = self._deserialize("ResourcePool", pipeline_response) if cls: 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, - resource_pool_name: str, - force: Optional[bool] = None, - **kwargs: Any + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools/{resourcePoolName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, 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 = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + resource_pool_name=resource_pool_name, + subscription_id=self._config.subscription_id, + force=force, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools/{resourcePoolName}'} # type: ignore + _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, - resource_pool_name: str, - force: Optional[bool] = None, - **kwargs: Any + self, resource_group_name: str, resource_pool_name: str, force: Optional[bool] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes an resourcePool. Implements resourcePool DELETE method. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param resource_pool_name: Name of the resourcePool. + :param resource_pool_name: Name of the resourcePool. Required. :type resource_pool_name: str - :param force: Whether force delete was specified. + :param force: Whether force delete was specified. Default value is None. :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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_pool_name=resource_pool_name, force=force, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements 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) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - 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 + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.ResourcePoolsList"]: + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools/{resourcePoolName}"} # type: ignore + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.ResourcePool"]: """Implements GET resourcePools in a subscription. List of resourcePools 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 ResourcePoolsList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.ResourcePoolsList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ResourcePool or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.ResourcePool] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourcePoolsList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourcePoolsList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): 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, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -482,71 +646,72 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) 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 + return AsyncItemPaged(get_next, extract_data) - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ResourcePoolsList"]: + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools"} # type: ignore + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.ResourcePool"]: """Implements GET resourcePools in a resource group. List of resourcePools in a resource group. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :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] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ResourcePool or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.ResourcePool] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourcePoolsList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourcePoolsList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): 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( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -555,17 +720,18 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools"} # type: ignore 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..3e6a047891f8 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,475 +6,637 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._vcenters_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class VCentersOperations: - """VCentersOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VCentersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.connectedvmware.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.connectedvmware.aio.AzureArcVMwareManagementServiceAPI`'s + :attr:`vcenters` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _create_initial( self, resource_group_name: str, vcenter_name: str, - body: Optional["_models.VCenter"] = None, + body: Optional[Union[_models.VCenter, IO]] = 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') - - # 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') + ) -> _models.VCenter: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.VCenter] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - body_content = None - 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) + if body is not None: + _json = self._serialize.body(body, "VCenter") + else: + _json = None + + request = build_create_request( + resource_group_name=resource_group_name, + vcenter_name=vcenter_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('VCenter', pipeline_response) + deserialized = self._deserialize("VCenter", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('VCenter', pipeline_response) + deserialized = self._deserialize("VCenter", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}'} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}"} # type: ignore + + @overload async def begin_create( self, resource_group_name: str, vcenter_name: str, - body: Optional["_models.VCenter"] = None, + body: Optional[_models.VCenter] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.VCenter"]: + ) -> AsyncLROPoller[_models.VCenter]: """Implements vCenter PUT method. Create Or Update vCenter. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param vcenter_name: Name of the vCenter. + :param vcenter_name: Name of the vCenter. Required. :type vcenter_name: str - :param body: Request payload. + :param body: Request payload. Default value is None. :type body: ~azure.mgmt.connectedvmware.models.VCenter + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. - :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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VCenter"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create( + self, + resource_group_name: str, + vcenter_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.VCenter]: + """Implements vCenter PUT method. + + Create Or Update vCenter. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param vcenter_name: Name of the vCenter. Required. + :type vcenter_name: str + :param body: Request payload. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.VCenter] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + vcenter_name: str, + body: Optional[Union[_models.VCenter, IO]] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.VCenter]: + """Implements vCenter PUT method. + + Create Or Update vCenter. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param vcenter_name: Name of the vCenter. Required. + :type vcenter_name: str + :param body: Request payload. Is either a model type or a IO type. Default value is None. + :type body: ~azure.mgmt.connectedvmware.models.VCenter or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.VCenter] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.VCenter] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_initial( + raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, vcenter_name=vcenter_name, body=body, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('VCenter', pipeline_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) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - 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 + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - async def get( - self, - resource_group_name: str, - vcenter_name: str, - **kwargs: Any - ) -> "_models.VCenter": + 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, vcenter_name: str, **kwargs: Any) -> _models.VCenter: """Gets a vCenter. Implements vCenter GET method. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param vcenter_name: Name of the vCenter. + :param vcenter_name: Name of the vCenter. Required. :type vcenter_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: VCenter, or the result of cls(response) + :return: VCenter or the result of cls(response) :rtype: ~azure.mgmt.connectedvmware.models.VCenter - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - 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" - 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 = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.VCenter] + + request = build_get_request( + resource_group_name=resource_group_name, + vcenter_name=vcenter_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + deserialized = self._deserialize("VCenter", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}"} # type: ignore + + @overload async def update( self, resource_group_name: str, vcenter_name: str, - body: Optional["_models.ResourcePatch"] = None, + body: Optional[_models.ResourcePatch] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.VCenter": + ) -> _models.VCenter: """Updates a vCenter. API to update certain properties of the vCenter resource. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param vcenter_name: Name of the vCenter. + :param vcenter_name: Name of the vCenter. Required. :type vcenter_name: str - :param body: Resource properties to update. + :param body: Resource properties to update. Default value is None. :type body: ~azure.mgmt.connectedvmware.models.ResourcePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: VCenter, or the result of cls(response) + :return: VCenter or the result of cls(response) :rtype: ~azure.mgmt.connectedvmware.models.VCenter - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - 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.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') - - body_content_kwargs = {} # type: Dict[str, Any] - if body is not None: - body_content = self._serialize.body(body, 'ResourcePatch') + + @overload + async def update( + self, + resource_group_name: str, + vcenter_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.VCenter: + """Updates a vCenter. + + API to update certain properties of the vCenter resource. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param vcenter_name: Name of the vCenter. Required. + :type vcenter_name: str + :param body: Resource properties to update. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: VCenter or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.VCenter + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + vcenter_name: str, + body: Optional[Union[_models.ResourcePatch, IO]] = None, + **kwargs: Any + ) -> _models.VCenter: + """Updates a vCenter. + + API to update certain properties of the vCenter resource. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param vcenter_name: Name of the vCenter. Required. + :type vcenter_name: str + :param body: Resource properties to update. Is either a model type or a IO type. Default value + is None. + :type body: ~azure.mgmt.connectedvmware.models.ResourcePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: VCenter or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.VCenter + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.VCenter] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - body_content = None - 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) + if body is not None: + _json = self._serialize.body(body, "ResourcePatch") + else: + _json = None + + request = build_update_request( + resource_group_name=resource_group_name, + vcenter_name=vcenter_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + deserialized = self._deserialize("VCenter", pipeline_response) if cls: 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, - vcenter_name: str, - force: Optional[bool] = None, - **kwargs: Any + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, 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 = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + vcenter_name=vcenter_name, + subscription_id=self._config.subscription_id, + force=force, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}'} # type: ignore + _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, - vcenter_name: str, - force: Optional[bool] = None, - **kwargs: Any + self, resource_group_name: str, vcenter_name: str, force: Optional[bool] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes an vCenter. Implements vCenter DELETE method. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param vcenter_name: Name of the vCenter. + :param vcenter_name: Name of the vCenter. Required. :type vcenter_name: str - :param force: Whether force delete was specified. + :param force: Whether force delete was specified. Default value is None. :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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, vcenter_name=vcenter_name, force=force, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements 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) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - 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 + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.VCentersList"]: + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}"} # type: ignore + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.VCenter"]: """Implements GET vCenters in a subscription. List of vCenters 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 VCentersList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.VCentersList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either VCenter or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.VCenter] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VCentersList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.VCentersList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): 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, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -482,71 +645,71 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) 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 + return AsyncItemPaged(get_next, extract_data) - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.VCentersList"]: + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/vcenters"} # type: ignore + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.VCenter"]: """Implements GET vCenters in a resource group. List of vCenters in a resource group. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :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] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either VCenter or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.VCenter] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VCentersList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.VCentersList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): 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( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -555,17 +718,18 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters"} # type: ignore 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..57cb278781c5 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,475 +6,644 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._virtual_machine_templates_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class VirtualMachineTemplatesOperations: - """VirtualMachineTemplatesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachineTemplatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.connectedvmware.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.connectedvmware.aio.AzureArcVMwareManagementServiceAPI`'s + :attr:`virtual_machine_templates` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _create_initial( self, resource_group_name: str, virtual_machine_template_name: str, - body: Optional["_models.VirtualMachineTemplate"] = None, + body: Optional[Union[_models.VirtualMachineTemplate, IO]] = 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') - - # 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') + ) -> _models.VirtualMachineTemplate: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.VirtualMachineTemplate] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - body_content = None - 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) + if body is not None: + _json = self._serialize.body(body, "VirtualMachineTemplate") + else: + _json = None + + request = build_create_request( + resource_group_name=resource_group_name, + virtual_machine_template_name=virtual_machine_template_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('VirtualMachineTemplate', pipeline_response) + deserialized = self._deserialize("VirtualMachineTemplate", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('VirtualMachineTemplate', pipeline_response) + deserialized = self._deserialize("VirtualMachineTemplate", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates/{virtualMachineTemplateName}'} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates/{virtualMachineTemplateName}"} # type: ignore + + @overload async def begin_create( self, resource_group_name: str, virtual_machine_template_name: str, - body: Optional["_models.VirtualMachineTemplate"] = None, + body: Optional[_models.VirtualMachineTemplate] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachineTemplate"]: + ) -> AsyncLROPoller[_models.VirtualMachineTemplate]: """Implements virtual machine template PUT method. Create Or Update virtual machine template. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param virtual_machine_template_name: Name of the virtual machine template resource. + :param virtual_machine_template_name: Name of the virtual machine template resource. Required. :type virtual_machine_template_name: str - :param body: Request payload. + :param body: Request payload. Default value is None. :type body: ~azure.mgmt.connectedvmware.models.VirtualMachineTemplate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. - :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] + :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] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineTemplate"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create( + self, + resource_group_name: str, + virtual_machine_template_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachineTemplate]: + """Implements virtual machine template PUT method. + + Create Or Update virtual machine template. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param virtual_machine_template_name: Name of the virtual machine template resource. Required. + :type virtual_machine_template_name: str + :param body: Request payload. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + virtual_machine_template_name: str, + body: Optional[Union[_models.VirtualMachineTemplate, IO]] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachineTemplate]: + """Implements virtual machine template PUT method. + + Create Or Update virtual machine template. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param virtual_machine_template_name: Name of the virtual machine template resource. Required. + :type virtual_machine_template_name: str + :param body: Request payload. Is either a model type or a IO type. Default value is None. + :type body: ~azure.mgmt.connectedvmware.models.VirtualMachineTemplate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.VirtualMachineTemplate] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_initial( + raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, virtual_machine_template_name=virtual_machine_template_name, body=body, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('VirtualMachineTemplate', pipeline_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) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - 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 + 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, - virtual_machine_template_name: str, - **kwargs: Any - ) -> "_models.VirtualMachineTemplate": + self, resource_group_name: str, virtual_machine_template_name: str, **kwargs: Any + ) -> _models.VirtualMachineTemplate: """Gets a virtual machine template. Implements virtual machine template GET method. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param virtual_machine_template_name: Name of the virtual machine template resource. + :param virtual_machine_template_name: Name of the virtual machine template resource. Required. :type virtual_machine_template_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: VirtualMachineTemplate, or the result of cls(response) + :return: VirtualMachineTemplate or the result of cls(response) :rtype: ~azure.mgmt.connectedvmware.models.VirtualMachineTemplate - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - 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" - 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 = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.VirtualMachineTemplate] + + request = build_get_request( + resource_group_name=resource_group_name, + virtual_machine_template_name=virtual_machine_template_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + deserialized = self._deserialize("VirtualMachineTemplate", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates/{virtualMachineTemplateName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates/{virtualMachineTemplateName}"} # type: ignore + + @overload async def update( self, resource_group_name: str, virtual_machine_template_name: str, - body: Optional["_models.ResourcePatch"] = None, + body: Optional[_models.ResourcePatch] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.VirtualMachineTemplate": + ) -> _models.VirtualMachineTemplate: """Updates a virtual machine template. API to update certain properties of the virtual machine template resource. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param virtual_machine_template_name: Name of the virtual machine template resource. + :param virtual_machine_template_name: Name of the virtual machine template resource. Required. :type virtual_machine_template_name: str - :param body: Resource properties to update. + :param body: Resource properties to update. Default value is None. :type body: ~azure.mgmt.connectedvmware.models.ResourcePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: VirtualMachineTemplate, or the result of cls(response) + :return: VirtualMachineTemplate or the result of cls(response) :rtype: ~azure.mgmt.connectedvmware.models.VirtualMachineTemplate - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - 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.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') - - body_content_kwargs = {} # type: Dict[str, Any] - if body is not None: - body_content = self._serialize.body(body, 'ResourcePatch') + + @overload + async def update( + self, + resource_group_name: str, + virtual_machine_template_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.VirtualMachineTemplate: + """Updates a virtual machine template. + + API to update certain properties of the virtual machine template resource. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param virtual_machine_template_name: Name of the virtual machine template resource. Required. + :type virtual_machine_template_name: str + :param body: Resource properties to update. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: VirtualMachineTemplate or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.VirtualMachineTemplate + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + virtual_machine_template_name: str, + body: Optional[Union[_models.ResourcePatch, IO]] = None, + **kwargs: Any + ) -> _models.VirtualMachineTemplate: + """Updates a virtual machine template. + + API to update certain properties of the virtual machine template resource. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param virtual_machine_template_name: Name of the virtual machine template resource. Required. + :type virtual_machine_template_name: str + :param body: Resource properties to update. Is either a model type or a IO type. Default value + is None. + :type body: ~azure.mgmt.connectedvmware.models.ResourcePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: VirtualMachineTemplate or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.VirtualMachineTemplate + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.VirtualMachineTemplate] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - body_content = None - 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) + if body is not None: + _json = self._serialize.body(body, "ResourcePatch") + else: + _json = None + + request = build_update_request( + resource_group_name=resource_group_name, + virtual_machine_template_name=virtual_machine_template_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + deserialized = self._deserialize("VirtualMachineTemplate", pipeline_response) if cls: 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, - virtual_machine_template_name: str, - force: Optional[bool] = None, - **kwargs: Any + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates/{virtualMachineTemplateName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, 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 = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + virtual_machine_template_name=virtual_machine_template_name, + subscription_id=self._config.subscription_id, + force=force, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates/{virtualMachineTemplateName}'} # type: ignore + _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, - virtual_machine_template_name: str, - force: Optional[bool] = None, - **kwargs: Any + self, resource_group_name: str, virtual_machine_template_name: str, force: Optional[bool] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes an virtual machine template. Implements virtual machine template DELETE method. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param virtual_machine_template_name: Name of the virtual machine template resource. + :param virtual_machine_template_name: Name of the virtual machine template resource. Required. :type virtual_machine_template_name: str - :param force: Whether force delete was specified. + :param force: Whether force delete was specified. Default value is None. :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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, virtual_machine_template_name=virtual_machine_template_name, force=force, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements 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) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - 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 + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineTemplatesList"]: + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates/{virtualMachineTemplateName}"} # type: ignore + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.VirtualMachineTemplate"]: """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.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.VirtualMachineTemplatesList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either VirtualMachineTemplate or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.VirtualMachineTemplate] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineTemplatesList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.VirtualMachineTemplatesList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): 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, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -482,71 +652,75 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) 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 + 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, - **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachineTemplatesList"]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.VirtualMachineTemplate"]: """Implements GET virtualMachineTemplates in a resource group. List of virtualMachineTemplates in a resource group. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :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] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either VirtualMachineTemplate or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.VirtualMachineTemplate] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineTemplatesList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.VirtualMachineTemplatesList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): 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( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -555,17 +729,18 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates"} # type: ignore 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..a3bab4379024 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,883 +6,1494 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._virtual_machines_operations import ( + build_assess_patches_request, + build_create_request, + build_delete_request, + build_get_request, + build_install_patches_request, + build_list_by_resource_group_request, + build_list_request, + build_restart_request, + build_start_request, + build_stop_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class VirtualMachinesOperations: - """VirtualMachinesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualMachinesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.connectedvmware.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.connectedvmware.aio.AzureArcVMwareManagementServiceAPI`'s + :attr:`virtual_machines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + async def _assess_patches_initial( + self, resource_group_name: str, name: str, **kwargs: Any + ) -> Optional[_models.VirtualMachineAssessPatchesResult]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.VirtualMachineAssessPatchesResult]] + + request = build_assess_patches_request( + resource_group_name=resource_group_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._assess_patches_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("VirtualMachineAssessPatchesResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _assess_patches_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/assessPatches"} # type: ignore + + @distributed_trace_async + async def begin_assess_patches( + self, resource_group_name: str, name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachineAssessPatchesResult]: + """The operation to assess patches on a vSphere VMware machine identity in Azure. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param name: The name of the vSphere VMware machine. Required. + :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. + :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 VirtualMachineAssessPatchesResult or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.VirtualMachineAssessPatchesResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.VirtualMachineAssessPatchesResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._assess_patches_initial( # type: ignore + resource_group_name=resource_group_name, + name=name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("VirtualMachineAssessPatchesResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_assess_patches.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/assessPatches"} # type: ignore + + async def _install_patches_initial( + self, + resource_group_name: str, + name: str, + install_patches_input: Union[_models.VirtualMachineInstallPatchesParameters, IO], + **kwargs: Any + ) -> Optional[_models.VirtualMachineInstallPatchesResult]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.VirtualMachineInstallPatchesResult]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(install_patches_input, (IO, bytes)): + _content = install_patches_input + else: + _json = self._serialize.body(install_patches_input, "VirtualMachineInstallPatchesParameters") + + request = build_install_patches_request( + resource_group_name=resource_group_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._install_patches_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("VirtualMachineInstallPatchesResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _install_patches_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/installPatches"} # type: ignore + + @overload + async def begin_install_patches( + self, + resource_group_name: str, + name: str, + install_patches_input: _models.VirtualMachineInstallPatchesParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachineInstallPatchesResult]: + """The operation to install patches on a vSphere VMware machine identity in Azure. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param name: The name of the vSphere VMware machine. Required. + :type name: str + :param install_patches_input: Input for InstallPatches as directly received by the API. + Required. + :type install_patches_input: + ~azure.mgmt.connectedvmware.models.VirtualMachineInstallPatchesParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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 VirtualMachineInstallPatchesResult + or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.VirtualMachineInstallPatchesResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_install_patches( + self, + resource_group_name: str, + name: str, + install_patches_input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachineInstallPatchesResult]: + """The operation to install patches on a vSphere VMware machine identity in Azure. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param name: The name of the vSphere VMware machine. Required. + :type name: str + :param install_patches_input: Input for InstallPatches as directly received by the API. + Required. + :type install_patches_input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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 VirtualMachineInstallPatchesResult + or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.VirtualMachineInstallPatchesResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_install_patches( + self, + resource_group_name: str, + name: str, + install_patches_input: Union[_models.VirtualMachineInstallPatchesParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachineInstallPatchesResult]: + """The operation to install patches on a vSphere VMware machine identity in Azure. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param name: The name of the vSphere VMware machine. Required. + :type name: str + :param install_patches_input: Input for InstallPatches as directly received by the API. Is + either a model type or a IO type. Required. + :type install_patches_input: + ~azure.mgmt.connectedvmware.models.VirtualMachineInstallPatchesParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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 VirtualMachineInstallPatchesResult + or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.VirtualMachineInstallPatchesResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.VirtualMachineInstallPatchesResult] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._install_patches_initial( # type: ignore + resource_group_name=resource_group_name, + name=name, + install_patches_input=install_patches_input, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("VirtualMachineInstallPatchesResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_install_patches.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/installPatches"} # type: ignore async def _create_initial( self, resource_group_name: str, virtual_machine_name: str, - body: Optional["_models.VirtualMachine"] = None, + body: Optional[Union[_models.VirtualMachine, IO]] = 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') - - # 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') + ) -> _models.VirtualMachine: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.VirtualMachine] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - body_content = None - 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) + if body is not None: + _json = self._serialize.body(body, "VirtualMachine") + else: + _json = None + + request = build_create_request( + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('VirtualMachine', pipeline_response) + deserialized = self._deserialize("VirtualMachine", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('VirtualMachine', pipeline_response) + deserialized = self._deserialize("VirtualMachine", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}'} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}"} # type: ignore + + @overload async def begin_create( self, resource_group_name: str, virtual_machine_name: str, - body: Optional["_models.VirtualMachine"] = None, + body: Optional[_models.VirtualMachine] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachine"]: + ) -> AsyncLROPoller[_models.VirtualMachine]: """Implements virtual machine PUT method. Create Or Update virtual machine. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param virtual_machine_name: Name of the virtual machine resource. + :param virtual_machine_name: Name of the virtual machine resource. Required. :type virtual_machine_name: str - :param body: Request payload. + :param body: Request payload. Default value is None. :type body: ~azure.mgmt.connectedvmware.models.VirtualMachine + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. - :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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create( + self, + resource_group_name: str, + virtual_machine_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachine]: + """Implements virtual machine PUT method. + + Create Or Update virtual machine. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param virtual_machine_name: Name of the virtual machine resource. Required. + :type virtual_machine_name: str + :param body: Request payload. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.VirtualMachine] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + virtual_machine_name: str, + body: Optional[Union[_models.VirtualMachine, IO]] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachine]: + """Implements virtual machine PUT method. + + Create Or Update virtual machine. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param virtual_machine_name: Name of the virtual machine resource. Required. + :type virtual_machine_name: str + :param body: Request payload. Is either a model type or a IO type. Default value is None. + :type body: ~azure.mgmt.connectedvmware.models.VirtualMachine or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.VirtualMachine] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.VirtualMachine] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_initial( + raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, virtual_machine_name=virtual_machine_name, body=body, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('VirtualMachine', pipeline_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) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - 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 + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - async def get( - self, - resource_group_name: str, - virtual_machine_name: str, - **kwargs: Any - ) -> "_models.VirtualMachine": + 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, virtual_machine_name: str, **kwargs: Any) -> _models.VirtualMachine: """Gets a virtual machine. Implements virtual machine GET method. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param virtual_machine_name: Name of the virtual machine resource. + :param virtual_machine_name: Name of the virtual machine resource. Required. :type virtual_machine_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: VirtualMachine, or the result of cls(response) + :return: VirtualMachine or the result of cls(response) :rtype: ~azure.mgmt.connectedvmware.models.VirtualMachine - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - 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" - 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 = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.VirtualMachine] + + request = build_get_request( + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + deserialized = self._deserialize("VirtualMachine", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}'} # type: ignore + + 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, + body: Optional[Union[_models.VirtualMachineUpdate, IO]] = 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._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') - - body_content_kwargs = {} # type: Dict[str, Any] - if body is not None: - body_content = self._serialize.body(body, 'VirtualMachineUpdate') + ) -> Optional[_models.VirtualMachine]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.VirtualMachine]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - body_content = None - 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) + if body is not None: + _json = self._serialize.body(body, "VirtualMachineUpdate") + else: + _json = None + + request = build_update_request( + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = None if response.status_code == 200: - deserialized = self._deserialize('VirtualMachine', pipeline_response) + deserialized = self._deserialize("VirtualMachine", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('VirtualMachine', pipeline_response) + deserialized = self._deserialize("VirtualMachine", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}'} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}"} # type: ignore + + @overload async def begin_update( self, resource_group_name: str, virtual_machine_name: str, - body: Optional["_models.VirtualMachineUpdate"] = None, + body: Optional[_models.VirtualMachineUpdate] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualMachine"]: + ) -> AsyncLROPoller[_models.VirtualMachine]: """Updates a virtual machine. API to update certain properties of the virtual machine resource. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param virtual_machine_name: Name of the virtual machine resource. + :param virtual_machine_name: Name of the virtual machine resource. Required. :type virtual_machine_name: str - :param body: Resource properties to update. + :param body: Resource properties to update. Default value is None. :type body: ~azure.mgmt.connectedvmware.models.VirtualMachineUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. - :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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_update( + self, + resource_group_name: str, + virtual_machine_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachine]: + """Updates a virtual machine. + + API to update certain properties of the virtual machine resource. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param virtual_machine_name: Name of the virtual machine resource. Required. + :type virtual_machine_name: str + :param body: Resource properties to update. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.VirtualMachine] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + virtual_machine_name: str, + body: Optional[Union[_models.VirtualMachineUpdate, IO]] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachine]: + """Updates a virtual machine. + + API to update certain properties of the virtual machine resource. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param virtual_machine_name: Name of the virtual machine resource. Required. + :type virtual_machine_name: str + :param body: Resource properties to update. Is either a model type or a IO type. Default value + is None. + :type body: ~azure.mgmt.connectedvmware.models.VirtualMachineUpdate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.VirtualMachine] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.VirtualMachine] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, virtual_machine_name=virtual_machine_name, body=body, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('VirtualMachine', pipeline_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) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - 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 + 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( + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, virtual_machine_name: str, force: Optional[bool] = None, + retain: 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 = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + subscription_id=self._config.subscription_id, + force=force, + retain=retain, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}'} # type: ignore + _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, virtual_machine_name: str, force: Optional[bool] = None, + retain: Optional[bool] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes an virtual machine. Implements virtual machine DELETE method. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param virtual_machine_name: Name of the virtual machine resource. + :param virtual_machine_name: Name of the virtual machine resource. Required. :type virtual_machine_name: str - :param force: Whether force delete was specified. + :param force: Whether force delete was specified. Default value is None. :type force: bool + :param retain: Whether to just disable the VM from azure and retain the VM in the VMM. Default + value is None. + :type retain: 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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, virtual_machine_name=virtual_machine_name, force=force, - cls=lambda x,y,z: x, + retain=retain, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements 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) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - 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 + 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( + async def _stop_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, virtual_machine_name: str, - body: Optional["_models.StopVirtualMachineOptions"] = None, + body: Optional[Union[_models.StopVirtualMachineOptions, IO]] = 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') - - # 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') + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + if body is not None: + _json = self._serialize.body(body, "StopVirtualMachineOptions") + else: + _json = None + + request = build_stop_request( + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._stop_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _stop_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/stop'} # type: ignore + _stop_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/stop"} # type: ignore + @overload async def begin_stop( self, resource_group_name: str, virtual_machine_name: str, - body: Optional["_models.StopVirtualMachineOptions"] = None, + body: Optional[_models.StopVirtualMachineOptions] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: """Implements the operation to stop a virtual machine. Stop virtual machine. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param virtual_machine_name: Name of the virtual machine resource. + :param virtual_machine_name: Name of the virtual machine resource. Required. :type virtual_machine_name: str - :param body: Virtualmachine stop action payload. + :param body: Virtualmachine stop action payload. Default value is None. :type body: ~azure.mgmt.connectedvmware.models.StopVirtualMachineOptions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_stop( + self, + resource_group_name: str, + virtual_machine_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Implements the operation to stop a virtual machine. + + Stop virtual machine. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param virtual_machine_name: Name of the virtual machine resource. Required. + :type virtual_machine_name: str + :param body: Virtualmachine stop action payload. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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 None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_stop( + self, + resource_group_name: str, + virtual_machine_name: str, + body: Optional[Union[_models.StopVirtualMachineOptions, IO]] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Implements the operation to stop a virtual machine. + + Stop virtual machine. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param virtual_machine_name: Name of the virtual machine resource. Required. + :type virtual_machine_name: str + :param body: Virtualmachine stop action payload. Is either a model type or a IO type. Default + value is None. + :type body: ~azure.mgmt.connectedvmware.models.StopVirtualMachineOptions or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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 None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._stop_initial( + raw_result = await self._stop_initial( # type: ignore resource_group_name=resource_group_name, virtual_machine_name=virtual_machine_name, body=body, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements 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) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - 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 + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - async def _start_initial( - self, - resource_group_name: str, - virtual_machine_name: str, - **kwargs: Any + begin_stop.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/stop"} # type: ignore + + async def _start_initial( # pylint: disable=inconsistent-return-statements + self, 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 = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_start_request( + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._start_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _start_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/start'} # type: ignore + _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, - virtual_machine_name: str, - **kwargs: Any + self, resource_group_name: str, virtual_machine_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Implements the operation to start a virtual machine. Start virtual machine. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param virtual_machine_name: Name of the virtual machine resource. + :param virtual_machine_name: Name of the virtual machine resource. Required. :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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._start_initial( + raw_result = await self._start_initial( # type: ignore resource_group_name=resource_group_name, virtual_machine_name=virtual_machine_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements 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) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - 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 + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - async def _restart_initial( - self, - resource_group_name: str, - virtual_machine_name: str, - **kwargs: Any + begin_start.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/start"} # type: ignore + + async def _restart_initial( # pylint: disable=inconsistent-return-statements + self, 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 = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_restart_request( + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._restart_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _restart_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/restart'} # type: ignore + _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, - virtual_machine_name: str, - **kwargs: Any + self, resource_group_name: str, virtual_machine_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Implements the operation to restart a virtual machine. Restart virtual machine. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param virtual_machine_name: Name of the virtual machine resource. + :param virtual_machine_name: Name of the virtual machine resource. Required. :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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, virtual_machine_name=virtual_machine_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements 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) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - 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 + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachinesList"]: + begin_restart.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/restart"} # type: ignore + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.VirtualMachine"]: """Implements GET virtualMachines in a subscription. List of virtualMachines 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 VirtualMachinesList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.VirtualMachinesList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either VirtualMachine or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.VirtualMachine] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachinesList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.VirtualMachinesList] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): 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, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -890,71 +1502,74 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) 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 + 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, - **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachinesList"]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.VirtualMachine"]: """Implements GET virtualMachines in a resource group. List of virtualMachines in a resource group. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :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] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either VirtualMachine or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.VirtualMachine] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachinesList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.VirtualMachinesList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): 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( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -963,17 +1578,18 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines"} # type: ignore 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..c9f879539a22 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,475 +6,638 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._virtual_networks_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class VirtualNetworksOperations: - """VirtualNetworksOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VirtualNetworksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.connectedvmware.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.connectedvmware.aio.AzureArcVMwareManagementServiceAPI`'s + :attr:`virtual_networks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _create_initial( self, resource_group_name: str, virtual_network_name: str, - body: Optional["_models.VirtualNetwork"] = None, + body: Optional[Union[_models.VirtualNetwork, IO]] = 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') - - # 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') + ) -> _models.VirtualNetwork: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.VirtualNetwork] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - body_content = None - 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) + if body is not None: + _json = self._serialize.body(body, "VirtualNetwork") + else: + _json = None + + request = build_create_request( + resource_group_name=resource_group_name, + virtual_network_name=virtual_network_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('VirtualNetwork', pipeline_response) + deserialized = self._deserialize("VirtualNetwork", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('VirtualNetwork', pipeline_response) + deserialized = self._deserialize("VirtualNetwork", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks/{virtualNetworkName}'} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks/{virtualNetworkName}"} # type: ignore + + @overload async def begin_create( self, resource_group_name: str, virtual_network_name: str, - body: Optional["_models.VirtualNetwork"] = None, + body: Optional[_models.VirtualNetwork] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.VirtualNetwork"]: + ) -> AsyncLROPoller[_models.VirtualNetwork]: """Implements virtual network PUT method. Create Or Update virtual network. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param virtual_network_name: Name of the virtual network resource. + :param virtual_network_name: Name of the virtual network resource. Required. :type virtual_network_name: str - :param body: Request payload. + :param body: Request payload. Default value is None. :type body: ~azure.mgmt.connectedvmware.models.VirtualNetwork + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. - :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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetwork"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create( + self, + resource_group_name: str, + virtual_network_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualNetwork]: + """Implements virtual network PUT method. + + Create Or Update virtual network. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param virtual_network_name: Name of the virtual network resource. Required. + :type virtual_network_name: str + :param body: Request payload. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.VirtualNetwork] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + virtual_network_name: str, + body: Optional[Union[_models.VirtualNetwork, IO]] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualNetwork]: + """Implements virtual network PUT method. + + Create Or Update virtual network. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param virtual_network_name: Name of the virtual network resource. Required. + :type virtual_network_name: str + :param body: Request payload. Is either a model type or a IO type. Default value is None. + :type body: ~azure.mgmt.connectedvmware.models.VirtualNetwork or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.VirtualNetwork] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.VirtualNetwork] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_initial( + raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, virtual_network_name=virtual_network_name, body=body, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('VirtualNetwork', pipeline_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) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - 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 + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - async def get( - self, - resource_group_name: str, - virtual_network_name: str, - **kwargs: Any - ) -> "_models.VirtualNetwork": + 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, virtual_network_name: str, **kwargs: Any) -> _models.VirtualNetwork: """Gets a virtual network. Implements virtual network GET method. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param virtual_network_name: Name of the virtual network resource. + :param virtual_network_name: Name of the virtual network resource. Required. :type virtual_network_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: VirtualNetwork, or the result of cls(response) + :return: VirtualNetwork or the result of cls(response) :rtype: ~azure.mgmt.connectedvmware.models.VirtualNetwork - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - 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" - 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 = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.VirtualNetwork] + + request = build_get_request( + resource_group_name=resource_group_name, + virtual_network_name=virtual_network_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + deserialized = self._deserialize("VirtualNetwork", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks/{virtualNetworkName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks/{virtualNetworkName}"} # type: ignore + + @overload async def update( self, resource_group_name: str, virtual_network_name: str, - body: Optional["_models.ResourcePatch"] = None, + body: Optional[_models.ResourcePatch] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.VirtualNetwork": + ) -> _models.VirtualNetwork: """Updates a virtual network. API to update certain properties of the virtual network resource. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param virtual_network_name: Name of the virtual network resource. + :param virtual_network_name: Name of the virtual network resource. Required. :type virtual_network_name: str - :param body: Resource properties to update. + :param body: Resource properties to update. Default value is None. :type body: ~azure.mgmt.connectedvmware.models.ResourcePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: VirtualNetwork, or the result of cls(response) + :return: VirtualNetwork or the result of cls(response) :rtype: ~azure.mgmt.connectedvmware.models.VirtualNetwork - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - 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.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') - - body_content_kwargs = {} # type: Dict[str, Any] - if body is not None: - body_content = self._serialize.body(body, 'ResourcePatch') + + @overload + async def update( + self, + resource_group_name: str, + virtual_network_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.VirtualNetwork: + """Updates a virtual network. + + API to update certain properties of the virtual network resource. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param virtual_network_name: Name of the virtual network resource. Required. + :type virtual_network_name: str + :param body: Resource properties to update. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: VirtualNetwork or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.VirtualNetwork + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + virtual_network_name: str, + body: Optional[Union[_models.ResourcePatch, IO]] = None, + **kwargs: Any + ) -> _models.VirtualNetwork: + """Updates a virtual network. + + API to update certain properties of the virtual network resource. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param virtual_network_name: Name of the virtual network resource. Required. + :type virtual_network_name: str + :param body: Resource properties to update. Is either a model type or a IO type. Default value + is None. + :type body: ~azure.mgmt.connectedvmware.models.ResourcePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: VirtualNetwork or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.VirtualNetwork + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.VirtualNetwork] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - body_content = None - 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) + if body is not None: + _json = self._serialize.body(body, "ResourcePatch") + else: + _json = None + + request = build_update_request( + resource_group_name=resource_group_name, + virtual_network_name=virtual_network_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + deserialized = self._deserialize("VirtualNetwork", pipeline_response) if cls: 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, - virtual_network_name: str, - force: Optional[bool] = None, - **kwargs: Any + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks/{virtualNetworkName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, 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 = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + virtual_network_name=virtual_network_name, + subscription_id=self._config.subscription_id, + force=force, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks/{virtualNetworkName}'} # type: ignore + _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, - virtual_network_name: str, - force: Optional[bool] = None, - **kwargs: Any + self, resource_group_name: str, virtual_network_name: str, force: Optional[bool] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes an virtual network. Implements virtual network DELETE method. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param virtual_network_name: Name of the virtual network resource. + :param virtual_network_name: Name of the virtual network resource. Required. :type virtual_network_name: str - :param force: Whether force delete was specified. + :param force: Whether force delete was specified. Default value is None. :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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, virtual_network_name=virtual_network_name, force=force, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements 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) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - 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 + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.VirtualNetworksList"]: + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks/{virtualNetworkName}"} # type: ignore + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.VirtualNetwork"]: """Implements GET virtualNetworks in a subscription. List of virtualNetworks 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 VirtualNetworksList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.VirtualNetworksList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either VirtualNetwork or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.VirtualNetwork] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetworksList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.VirtualNetworksList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): 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, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -482,71 +646,74 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) 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 + 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, - **kwargs: Any - ) -> AsyncIterable["_models.VirtualNetworksList"]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.VirtualNetwork"]: """Implements GET virtualNetworks in a resource group. List of virtualNetworks in a resource group. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :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] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either VirtualNetwork or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.VirtualNetwork] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetworksList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.VirtualNetworksList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): 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( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -555,17 +722,18 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks"} # type: ignore 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..e69f4e7c1b53 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,256 +6,228 @@ # 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 AvailablePatchCountByClassification +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 LinuxParameters +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 OsProfileLinuxConfiguration +from ._models_py3 import OsProfileUpdate +from ._models_py3 import OsProfileUpdateLinuxConfiguration +from ._models_py3 import OsProfileUpdateWindowsConfiguration +from ._models_py3 import OsProfileWindowsConfiguration +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 SecurityProfile +from ._models_py3 import StopVirtualMachineOptions +from ._models_py3 import StorageProfile +from ._models_py3 import StorageProfileUpdate +from ._models_py3 import SystemData +from ._models_py3 import UefiSettings +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 VirtualMachineAssessPatchesResult +from ._models_py3 import VirtualMachineInstallPatchesParameters +from ._models_py3 import VirtualMachineInstallPatchesResult +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 ._models_py3 import WindowsParameters -from ._azure_arc_vmware_management_service_api_enums import ( - CreatedByType, - DiskMode, - DiskType, - FirmwareType, - IPAddressAllocationMethod, - IdentityType, - InventoryType, - NICType, - OsType, - PowerOnBootOption, - ProvisioningAction, - ProvisioningState, - SCSIControllerType, - StatusLevelTypes, - StatusTypes, - VirtualSCSISharing, -) +from ._azure_arc_vmware_management_service_api_enums import CreatedByType +from ._azure_arc_vmware_management_service_api_enums import DiskMode +from ._azure_arc_vmware_management_service_api_enums import DiskType +from ._azure_arc_vmware_management_service_api_enums import FirmwareType +from ._azure_arc_vmware_management_service_api_enums import IPAddressAllocationMethod +from ._azure_arc_vmware_management_service_api_enums import IdentityType +from ._azure_arc_vmware_management_service_api_enums import InventoryType +from ._azure_arc_vmware_management_service_api_enums import NICType +from ._azure_arc_vmware_management_service_api_enums import OsType +from ._azure_arc_vmware_management_service_api_enums import OsTypeUM +from ._azure_arc_vmware_management_service_api_enums import PatchOperationStartedBy +from ._azure_arc_vmware_management_service_api_enums import PatchOperationStatus +from ._azure_arc_vmware_management_service_api_enums import PatchServiceUsed +from ._azure_arc_vmware_management_service_api_enums import PowerOnBootOption +from ._azure_arc_vmware_management_service_api_enums import ProvisioningAction +from ._azure_arc_vmware_management_service_api_enums import ProvisioningState +from ._azure_arc_vmware_management_service_api_enums import SCSIControllerType +from ._azure_arc_vmware_management_service_api_enums import StatusLevelTypes +from ._azure_arc_vmware_management_service_api_enums import StatusTypes +from ._azure_arc_vmware_management_service_api_enums import VMGuestPatchClassificationLinux +from ._azure_arc_vmware_management_service_api_enums import VMGuestPatchClassificationWindows +from ._azure_arc_vmware_management_service_api_enums import VMGuestPatchRebootSetting +from ._azure_arc_vmware_management_service_api_enums import VMGuestPatchRebootStatus +from ._azure_arc_vmware_management_service_api_enums import VirtualSCSISharing +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'Cluster', - 'ClusterInventoryItem', - 'ClustersList', - 'Condition', - 'Datastore', - 'DatastoreInventoryItem', - 'DatastoresList', - 'ErrorDefinition', - 'ErrorDetail', - 'ErrorResponse', - 'ExtendedLocation', - 'GuestAgent', - 'GuestAgentList', - 'GuestAgentProfile', - 'GuestCredential', - 'HardwareProfile', - 'Host', - 'HostInventoryItem', - 'HostsList', - 'HttpProxyConfiguration', - 'HybridIdentityMetadata', - 'HybridIdentityMetadataList', - 'Identity', - 'InventoryItem', - 'InventoryItemDetails', - 'InventoryItemProperties', - 'InventoryItemsList', - 'MachineExtension', - 'MachineExtensionInstanceView', - 'MachineExtensionInstanceViewStatus', - 'MachineExtensionPropertiesInstanceView', - 'MachineExtensionUpdate', - 'MachineExtensionsListResult', - 'NetworkInterface', - 'NetworkInterfaceUpdate', - 'NetworkProfile', - 'NetworkProfileUpdate', - 'NicIPAddressSettings', - 'NicIPSettings', - 'Operation', - 'OperationDisplay', - 'OperationsList', - 'OsProfile', - 'PlacementProfile', - 'ProxyResource', - 'Resource', - 'ResourcePatch', - 'ResourcePool', - 'ResourcePoolInventoryItem', - 'ResourcePoolsList', - 'ResourceStatus', - 'StopVirtualMachineOptions', - 'StorageProfile', - 'StorageProfileUpdate', - 'SystemData', - 'VCenter', - 'VCentersList', - 'VICredential', - 'VirtualDisk', - 'VirtualDiskUpdate', - 'VirtualMachine', - 'VirtualMachineInventoryItem', - 'VirtualMachineTemplate', - 'VirtualMachineTemplateInventoryItem', - 'VirtualMachineTemplatesList', - 'VirtualMachineUpdate', - 'VirtualMachinesList', - 'VirtualNetwork', - 'VirtualNetworkInventoryItem', - 'VirtualNetworksList', - 'VirtualSCSIController', - 'CreatedByType', - 'DiskMode', - 'DiskType', - 'FirmwareType', - 'IPAddressAllocationMethod', - 'IdentityType', - 'InventoryType', - 'NICType', - 'OsType', - 'PowerOnBootOption', - 'ProvisioningAction', - 'ProvisioningState', - 'SCSIControllerType', - 'StatusLevelTypes', - 'StatusTypes', - 'VirtualSCSISharing', + "AvailablePatchCountByClassification", + "Cluster", + "ClusterInventoryItem", + "ClustersList", + "Condition", + "Datastore", + "DatastoreInventoryItem", + "DatastoresList", + "ErrorDefinition", + "ErrorDetail", + "ErrorResponse", + "ExtendedLocation", + "GuestAgent", + "GuestAgentList", + "GuestAgentProfile", + "GuestCredential", + "HardwareProfile", + "Host", + "HostInventoryItem", + "HostsList", + "HttpProxyConfiguration", + "HybridIdentityMetadata", + "HybridIdentityMetadataList", + "Identity", + "InventoryItem", + "InventoryItemDetails", + "InventoryItemProperties", + "InventoryItemsList", + "LinuxParameters", + "MachineExtension", + "MachineExtensionInstanceView", + "MachineExtensionInstanceViewStatus", + "MachineExtensionPropertiesInstanceView", + "MachineExtensionUpdate", + "MachineExtensionsListResult", + "NetworkInterface", + "NetworkInterfaceUpdate", + "NetworkProfile", + "NetworkProfileUpdate", + "NicIPAddressSettings", + "NicIPSettings", + "Operation", + "OperationDisplay", + "OperationsList", + "OsProfile", + "OsProfileLinuxConfiguration", + "OsProfileUpdate", + "OsProfileUpdateLinuxConfiguration", + "OsProfileUpdateWindowsConfiguration", + "OsProfileWindowsConfiguration", + "PlacementProfile", + "ProxyResource", + "Resource", + "ResourcePatch", + "ResourcePool", + "ResourcePoolInventoryItem", + "ResourcePoolsList", + "ResourceStatus", + "SecurityProfile", + "StopVirtualMachineOptions", + "StorageProfile", + "StorageProfileUpdate", + "SystemData", + "UefiSettings", + "VCenter", + "VCentersList", + "VICredential", + "VirtualDisk", + "VirtualDiskUpdate", + "VirtualMachine", + "VirtualMachineAssessPatchesResult", + "VirtualMachineInstallPatchesParameters", + "VirtualMachineInstallPatchesResult", + "VirtualMachineInventoryItem", + "VirtualMachineTemplate", + "VirtualMachineTemplateInventoryItem", + "VirtualMachineTemplatesList", + "VirtualMachineUpdate", + "VirtualMachinesList", + "VirtualNetwork", + "VirtualNetworkInventoryItem", + "VirtualNetworksList", + "VirtualSCSIController", + "WindowsParameters", + "CreatedByType", + "DiskMode", + "DiskType", + "FirmwareType", + "IPAddressAllocationMethod", + "IdentityType", + "InventoryType", + "NICType", + "OsType", + "OsTypeUM", + "PatchOperationStartedBy", + "PatchOperationStatus", + "PatchServiceUsed", + "PowerOnBootOption", + "ProvisioningAction", + "ProvisioningState", + "SCSIControllerType", + "StatusLevelTypes", + "StatusTypes", + "VMGuestPatchClassificationLinux", + "VMGuestPatchClassificationWindows", + "VMGuestPatchRebootSetting", + "VMGuestPatchRebootStatus", + "VirtualSCSISharing", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() 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..21cebcdc47d1 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,46 +6,29 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta -from six import with_metaclass - -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)): - """The type of identity that created the resource. - """ +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class DiskMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Defines the different types of disk modes. - """ + +class DiskMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines the different types of disk modes.""" PERSISTENT = "persistent" INDEPENDENT_PERSISTENT = "independent_persistent" INDEPENDENT_NONPERSISTENT = "independent_nonpersistent" -class DiskType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Defines the different types of disks. - """ + +class DiskType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines the different types of disks.""" FLAT = "flat" PMEM = "pmem" @@ -55,23 +38,23 @@ class DiskType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SESPARSE = "sesparse" UNKNOWN = "unknown" -class FirmwareType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Firmware type - """ + +class FirmwareType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Firmware type.""" BIOS = "bios" EFI = "efi" -class IdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The type of managed service identity. - """ + +class IdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of managed service identity.""" NONE = "None" SYSTEM_ASSIGNED = "SystemAssigned" -class InventoryType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The inventory type. - """ + +class InventoryType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The inventory type.""" RESOURCE_POOL = "ResourcePool" VIRTUAL_MACHINE = "VirtualMachine" @@ -81,9 +64,9 @@ class InventoryType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): DATASTORE = "Datastore" HOST = "Host" -class IPAddressAllocationMethod(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """IP address allocation method. - """ + +class IPAddressAllocationMethod(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """IP address allocation method.""" UNSET = "unset" DYNAMIC = "dynamic" @@ -92,9 +75,9 @@ class IPAddressAllocationMethod(with_metaclass(_CaseInsensitiveEnumMeta, str, En RANDOM = "random" OTHER = "other" -class NICType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """NIC type - """ + +class NICType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """NIC type.""" VMXNET3 = "vmxnet3" VMXNET2 = "vmxnet2" @@ -103,32 +86,70 @@ class NICType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): E1000_E = "e1000e" PCNET32 = "pcnet32" -class OsType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Defines the different types of VM guest operating systems. - """ + +class OsType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines the different types of VM guest operating systems.""" WINDOWS = "Windows" LINUX = "Linux" OTHER = "Other" -class PowerOnBootOption(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Defines the options for power on boot. + +class OsTypeUM(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The operating system type of the machine.""" + + WINDOWS = "Windows" + LINUX = "Linux" + + +class PatchOperationStartedBy(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates if operation was triggered by user or by platform.""" + + USER = "User" + PLATFORM = "Platform" + + +class PatchOperationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The overall success or failure status of the operation. It remains "InProgress" until the + operation completes. At that point it will become "Unknown", "Failed", "Succeeded", or + "CompletedWithWarnings.". """ + UNKNOWN = "Unknown" + IN_PROGRESS = "InProgress" + FAILED = "Failed" + SUCCEEDED = "Succeeded" + COMPLETED_WITH_WARNINGS = "CompletedWithWarnings" + + +class PatchServiceUsed(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies the patch service used for the operation.""" + + UNKNOWN = "Unknown" + WU = "WU" + WU_WSUS = "WU_WSUS" + YUM = "YUM" + APT = "APT" + ZYPPER = "Zypper" + + +class PowerOnBootOption(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines the options for power on boot.""" + ENABLED = "enabled" DISABLED = "disabled" -class ProvisioningAction(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Defines the different types of operations for guest agent. - """ + +class ProvisioningAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines the different types of operations for guest agent.""" INSTALL = "install" UNINSTALL = "uninstall" REPAIR = "repair" -class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The current deployment state of resource. - """ + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current deployment state of resource.""" SUCCEEDED = "Succeeded" FAILED = "Failed" @@ -139,35 +160,75 @@ class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): ACCEPTED = "Accepted" CREATED = "Created" -class SCSIControllerType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Defines the different types of SCSI controllers. - """ + +class SCSIControllerType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines the different types of SCSI controllers.""" LSILOGIC = "lsilogic" BUSLOGIC = "buslogic" PVSCSI = "pvscsi" LSILOGICSAS = "lsilogicsas" -class StatusLevelTypes(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The level code. - """ + +class StatusLevelTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The level code.""" INFO = "Info" WARNING = "Warning" ERROR = "Error" -class StatusTypes(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The status of the hybrid machine agent. - """ + +class StatusTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the hybrid machine agent.""" CONNECTED = "Connected" DISCONNECTED = "Disconnected" ERROR = "Error" -class VirtualSCSISharing(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Defines the sharing mode for sharing the SCSI bus. - """ + +class VirtualSCSISharing(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines the sharing mode for sharing the SCSI bus.""" NO_SHARING = "noSharing" PHYSICAL_SHARING = "physicalSharing" VIRTUAL_SHARING = "virtualSharing" + + +class VMGuestPatchClassificationLinux(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """VMGuestPatchClassificationLinux.""" + + CRITICAL = "Critical" + SECURITY = "Security" + OTHER = "Other" + + +class VMGuestPatchClassificationWindows(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """VMGuestPatchClassificationWindows.""" + + CRITICAL = "Critical" + SECURITY = "Security" + UPDATE_ROLL_UP = "UpdateRollUp" + FEATURE_PACK = "FeaturePack" + SERVICE_PACK = "ServicePack" + DEFINITION = "Definition" + TOOLS = "Tools" + UPDATES = "Updates" + + +class VMGuestPatchRebootSetting(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines when it is acceptable to reboot a VM during a software update operation.""" + + IF_REQUIRED = "IfRequired" + NEVER = "Never" + ALWAYS = "Always" + + +class VMGuestPatchRebootStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The reboot state of the VM following completion of the operation.""" + + UNKNOWN = "Unknown" + NOT_NEEDED = "NotNeeded" + REQUIRED = "Required" + STARTED = "Started" + FAILED = "Failed" + COMPLETED = "Completed" 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 index b932b37bd4d6..9ea1e4b2e45a 100644 --- a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/models/_models.py +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/models/_models.py @@ -59,58 +59,55 @@ class Cluster(msrest.serialization.Model): """ _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 - ): + "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.location = kwargs["location"] + self.extended_location = kwargs.get("extended_location", None) self.system_data = None - self.tags = kwargs.get('tags', None) + self.tags = kwargs.get("tags", None) self.name = None self.id = None self.type = None - self.kind = kwargs.get('kind', 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.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 @@ -145,31 +142,36 @@ class InventoryItemProperties(msrest.serialization.Model): """ _validation = { - 'inventory_type': {'required': True}, - 'provisioning_state': {'readonly': True}, + "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'}, + "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 - ): + "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.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 @@ -196,24 +198,21 @@ class ClusterInventoryItem(InventoryItemProperties): """ _validation = { - 'inventory_type': {'required': True}, - 'provisioning_state': {'readonly': True}, + "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'}, + "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 - ): + def __init__(self, **kwargs): super(ClusterInventoryItem, self).__init__(**kwargs) - self.inventory_type = 'Cluster' # type: str + self.inventory_type = "Cluster" # type: str class ClustersList(msrest.serialization.Model): @@ -228,21 +227,18 @@ class ClustersList(msrest.serialization.Model): """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[Cluster]'}, + "next_link": {"key": "nextLink", "type": "str"}, + "value": {"key": "value", "type": "[Cluster]"}, } - def __init__( - self, - **kwargs - ): + def __init__(self, **kwargs): super(ClustersList, self).__init__(**kwargs) - self.next_link = kwargs.get('next_link', None) - self.value = kwargs['value'] + self.next_link = kwargs.get("next_link", None) + self.value = kwargs["value"] class Condition(msrest.serialization.Model): @@ -261,23 +257,20 @@ class Condition(msrest.serialization.Model): """ _validation = { - 'status': {'readonly': True}, - 'reason': {'readonly': True}, - 'message': {'readonly': True}, - 'severity': {'readonly': True}, + "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'}, + "status": {"key": "status", "type": "str"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "severity": {"key": "severity", "type": "str"}, } - def __init__( - self, - **kwargs - ): + def __init__(self, **kwargs): super(Condition, self).__init__(**kwargs) self.status = None self.reason = None @@ -333,54 +326,51 @@ class Datastore(msrest.serialization.Model): """ _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 - ): + "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.location = kwargs["location"] + self.extended_location = kwargs.get("extended_location", None) self.system_data = None - self.tags = kwargs.get('tags', None) + self.tags = kwargs.get("tags", None) self.name = None self.id = None self.type = None - self.kind = kwargs.get('kind', 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.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 @@ -414,28 +404,25 @@ class DatastoreInventoryItem(InventoryItemProperties): """ _validation = { - 'inventory_type': {'required': True}, - 'provisioning_state': {'readonly': True}, + "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'}, + "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 - ): + 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) + 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): @@ -450,21 +437,18 @@ class DatastoresList(msrest.serialization.Model): """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[Datastore]'}, + "next_link": {"key": "nextLink", "type": "str"}, + "value": {"key": "value", "type": "[Datastore]"}, } - def __init__( - self, - **kwargs - ): + def __init__(self, **kwargs): super(DatastoresList, self).__init__(**kwargs) - self.next_link = kwargs.get('next_link', None) - self.value = kwargs['value'] + self.next_link = kwargs.get("next_link", None) + self.value = kwargs["value"] class ErrorDefinition(msrest.serialization.Model): @@ -481,21 +465,18 @@ class ErrorDefinition(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'details': {'readonly': True}, + "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]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "details": {"key": "details", "type": "[ErrorDefinition]"}, } - def __init__( - self, - **kwargs - ): + def __init__(self, **kwargs): super(ErrorDefinition, self).__init__(**kwargs) self.code = None self.message = None @@ -518,26 +499,23 @@ class ErrorDetail(msrest.serialization.Model): """ _validation = { - 'code': {'required': True}, - 'message': {'required': True}, + "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]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorDetail]"}, } - def __init__( - self, - **kwargs - ): + 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) + 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): @@ -548,15 +526,12 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDefinition'}, + "error": {"key": "error", "type": "ErrorDefinition"}, } - def __init__( - self, - **kwargs - ): + def __init__(self, **kwargs): super(ErrorResponse, self).__init__(**kwargs) - self.error = kwargs.get('error', None) + self.error = kwargs.get("error", None) class ExtendedLocation(msrest.serialization.Model): @@ -569,17 +544,14 @@ class ExtendedLocation(msrest.serialization.Model): """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - **kwargs - ): + def __init__(self, **kwargs): super(ExtendedLocation, self).__init__(**kwargs) - self.type = kwargs.get('type', None) - self.name = kwargs.get('name', None) + self.type = kwargs.get("type", None) + self.name = kwargs.get("name", None) class Resource(msrest.serialization.Model): @@ -598,21 +570,18 @@ class Resource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): + def __init__(self, **kwargs): super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -635,21 +604,18 @@ class ProxyResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): + def __init__(self, **kwargs): super(ProxyResource, self).__init__(**kwargs) @@ -688,42 +654,39 @@ class GuestAgent(ProxyResource): """ _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 - ): + "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.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 @@ -742,21 +705,18 @@ class GuestAgentList(msrest.serialization.Model): """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[GuestAgent]'}, + "next_link": {"key": "nextLink", "type": "str"}, + "value": {"key": "value", "type": "[GuestAgent]"}, } - def __init__( - self, - **kwargs - ): + def __init__(self, **kwargs): super(GuestAgentList, self).__init__(**kwargs) - self.next_link = kwargs.get('next_link', None) - self.value = kwargs['value'] + self.next_link = kwargs.get("next_link", None) + self.value = kwargs["value"] class GuestAgentProfile(msrest.serialization.Model): @@ -778,25 +738,22 @@ class GuestAgentProfile(msrest.serialization.Model): """ _validation = { - 'vm_uuid': {'readonly': True}, - 'status': {'readonly': True}, - 'last_status_change': {'readonly': True}, - 'agent_version': {'readonly': True}, - 'error_details': {'readonly': True}, + "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]'}, + "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 - ): + def __init__(self, **kwargs): super(GuestAgentProfile, self).__init__(**kwargs) self.vm_uuid = None self.status = None @@ -815,17 +772,14 @@ class GuestCredential(msrest.serialization.Model): """ _attribute_map = { - 'username': {'key': 'username', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, } - def __init__( - self, - **kwargs - ): + def __init__(self, **kwargs): super(GuestCredential, self).__init__(**kwargs) - self.username = kwargs.get('username', None) - self.password = kwargs.get('password', None) + self.username = kwargs.get("username", None) + self.password = kwargs.get("password", None) class HardwareProfile(msrest.serialization.Model): @@ -852,28 +806,25 @@ class HardwareProfile(msrest.serialization.Model): """ _validation = { - 'cpu_hot_add_enabled': {'readonly': True}, - 'cpu_hot_remove_enabled': {'readonly': True}, - 'memory_hot_add_enabled': {'readonly': True}, + "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'}, + "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 - ): + 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.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 @@ -923,54 +874,51 @@ class Host(msrest.serialization.Model): """ _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 - ): + "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.location = kwargs["location"] + self.extended_location = kwargs.get("extended_location", None) self.system_data = None - self.tags = kwargs.get('tags', None) + self.tags = kwargs.get("tags", None) self.name = None self.id = None self.type = None - self.kind = kwargs.get('kind', 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.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 @@ -1002,26 +950,23 @@ class HostInventoryItem(InventoryItemProperties): """ _validation = { - 'inventory_type': {'required': True}, - 'provisioning_state': {'readonly': True}, + "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'}, + "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 - ): + def __init__(self, **kwargs): super(HostInventoryItem, self).__init__(**kwargs) - self.inventory_type = 'Host' # type: str - self.parent = kwargs.get('parent', None) + self.inventory_type = "Host" # type: str + self.parent = kwargs.get("parent", None) class HostsList(msrest.serialization.Model): @@ -1036,21 +981,18 @@ class HostsList(msrest.serialization.Model): """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[Host]'}, + "next_link": {"key": "nextLink", "type": "str"}, + "value": {"key": "value", "type": "[Host]"}, } - def __init__( - self, - **kwargs - ): + def __init__(self, **kwargs): super(HostsList, self).__init__(**kwargs) - self.next_link = kwargs.get('next_link', None) - self.value = kwargs['value'] + self.next_link = kwargs.get("next_link", None) + self.value = kwargs["value"] class HttpProxyConfiguration(msrest.serialization.Model): @@ -1061,15 +1003,12 @@ class HttpProxyConfiguration(msrest.serialization.Model): """ _attribute_map = { - 'https_proxy': {'key': 'httpsProxy', 'type': 'str'}, + "https_proxy": {"key": "httpsProxy", "type": "str"}, } - def __init__( - self, - **kwargs - ): + def __init__(self, **kwargs): super(HttpProxyConfiguration, self).__init__(**kwargs) - self.https_proxy = kwargs.get('https_proxy', None) + self.https_proxy = kwargs.get("https_proxy", None) class HybridIdentityMetadata(ProxyResource): @@ -1098,33 +1037,30 @@ class HybridIdentityMetadata(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'identity': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "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'}, + "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 - ): + 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.vm_id = kwargs.get("vm_id", None) + self.public_key = kwargs.get("public_key", None) self.identity = None self.provisioning_state = None @@ -1141,21 +1077,18 @@ class HybridIdentityMetadataList(msrest.serialization.Model): """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[HybridIdentityMetadata]'}, + "next_link": {"key": "nextLink", "type": "str"}, + "value": {"key": "value", "type": "[HybridIdentityMetadata]"}, } - def __init__( - self, - **kwargs - ): + def __init__(self, **kwargs): super(HybridIdentityMetadataList, self).__init__(**kwargs) - self.next_link = kwargs.get('next_link', None) - self.value = kwargs['value'] + self.next_link = kwargs.get("next_link", None) + self.value = kwargs["value"] class Identity(msrest.serialization.Model): @@ -1175,25 +1108,22 @@ class Identity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'type': {'required': True}, + "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'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): + def __init__(self, **kwargs): super(Identity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None - self.type = kwargs['type'] + self.type = kwargs["type"] class InventoryItem(ProxyResource): @@ -1233,38 +1163,35 @@ class InventoryItem(ProxyResource): """ _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 - ): + "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.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.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 @@ -1278,17 +1205,14 @@ class InventoryItemDetails(msrest.serialization.Model): """ _attribute_map = { - 'inventory_item_id': {'key': 'inventoryItemId', 'type': 'str'}, - 'mo_name': {'key': 'moName', 'type': 'str'}, + "inventory_item_id": {"key": "inventoryItemId", "type": "str"}, + "mo_name": {"key": "moName", "type": "str"}, } - def __init__( - self, - **kwargs - ): + 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) + self.inventory_item_id = kwargs.get("inventory_item_id", None) + self.mo_name = kwargs.get("mo_name", None) class InventoryItemsList(msrest.serialization.Model): @@ -1303,21 +1227,18 @@ class InventoryItemsList(msrest.serialization.Model): """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[InventoryItem]'}, + "next_link": {"key": "nextLink", "type": "str"}, + "value": {"key": "value", "type": "[InventoryItem]"}, } - def __init__( - self, - **kwargs - ): + def __init__(self, **kwargs): super(InventoryItemsList, self).__init__(**kwargs) - self.next_link = kwargs.get('next_link', None) - self.value = kwargs['value'] + self.next_link = kwargs.get("next_link", None) + self.value = kwargs["value"] class MachineExtension(msrest.serialization.Model): @@ -1363,51 +1284,48 @@ class MachineExtension(msrest.serialization.Model): """ _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 - ): + "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.location = kwargs.get("location", None) self.system_data = None - self.tags = kwargs.get('tags', 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.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) + self.instance_view = kwargs.get("instance_view", None) class MachineExtensionInstanceView(msrest.serialization.Model): @@ -1426,27 +1344,24 @@ class MachineExtensionInstanceView(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'type_handler_version': {'readonly': True}, + "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'}, + "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 - ): + 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) + self.status = kwargs.get("status", None) class MachineExtensionInstanceViewStatus(msrest.serialization.Model): @@ -1467,25 +1382,22 @@ class MachineExtensionInstanceViewStatus(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'level': {'readonly': True}, - 'display_status': {'readonly': True}, - 'message': {'readonly': True}, - 'time': {'readonly': True}, + "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'}, + "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 - ): + def __init__(self, **kwargs): super(MachineExtensionInstanceViewStatus, self).__init__(**kwargs) self.code = None self.level = None @@ -1510,22 +1422,19 @@ class MachineExtensionPropertiesInstanceView(MachineExtensionInstanceView): """ _validation = { - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'type_handler_version': {'readonly': True}, + "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'}, + "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 - ): + def __init__(self, **kwargs): super(MachineExtensionPropertiesInstanceView, self).__init__(**kwargs) @@ -1540,17 +1449,14 @@ class MachineExtensionsListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[MachineExtension]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[MachineExtension]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): + def __init__(self, **kwargs): super(MachineExtensionsListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) + self.value = kwargs.get("value", None) + self.next_link = kwargs.get("next_link", None) class ResourcePatch(msrest.serialization.Model): @@ -1561,15 +1467,12 @@ class ResourcePatch(msrest.serialization.Model): """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - **kwargs - ): + def __init__(self, **kwargs): super(ResourcePatch, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) + self.tags = kwargs.get("tags", None) class MachineExtensionUpdate(ResourcePatch): @@ -1598,28 +1501,25 @@ class MachineExtensionUpdate(ResourcePatch): """ _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'}, + "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 - ): + 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) + 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): @@ -1659,43 +1559,40 @@ class NetworkInterface(msrest.serialization.Model): """ _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 - ): + "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.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_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) + self.device_key = kwargs.get("device_key", None) + self.ip_settings = kwargs.get("ip_settings", None) class NetworkInterfaceUpdate(msrest.serialization.Model): @@ -1717,23 +1614,20 @@ class NetworkInterfaceUpdate(msrest.serialization.Model): """ _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'}, + "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 - ): + 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) + 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): @@ -1745,15 +1639,12 @@ class NetworkProfile(msrest.serialization.Model): """ _attribute_map = { - 'network_interfaces': {'key': 'networkInterfaces', 'type': '[NetworkInterface]'}, + "network_interfaces": {"key": "networkInterfaces", "type": "[NetworkInterface]"}, } - def __init__( - self, - **kwargs - ): + def __init__(self, **kwargs): super(NetworkProfile, self).__init__(**kwargs) - self.network_interfaces = kwargs.get('network_interfaces', None) + self.network_interfaces = kwargs.get("network_interfaces", None) class NetworkProfileUpdate(msrest.serialization.Model): @@ -1765,15 +1656,12 @@ class NetworkProfileUpdate(msrest.serialization.Model): """ _attribute_map = { - 'network_interfaces': {'key': 'networkInterfaces', 'type': '[NetworkInterfaceUpdate]'}, + "network_interfaces": {"key": "networkInterfaces", "type": "[NetworkInterfaceUpdate]"}, } - def __init__( - self, - **kwargs - ): + def __init__(self, **kwargs): super(NetworkProfileUpdate, self).__init__(**kwargs) - self.network_interfaces = kwargs.get('network_interfaces', None) + self.network_interfaces = kwargs.get("network_interfaces", None) class NicIPAddressSettings(msrest.serialization.Model): @@ -1790,21 +1678,18 @@ class NicIPAddressSettings(msrest.serialization.Model): """ _validation = { - 'allocation_method': {'readonly': True}, - 'ip_address': {'readonly': True}, - 'subnet_mask': {'readonly': True}, + "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'}, + "allocation_method": {"key": "allocationMethod", "type": "str"}, + "ip_address": {"key": "ipAddress", "type": "str"}, + "subnet_mask": {"key": "subnetMask", "type": "str"}, } - def __init__( - self, - **kwargs - ): + def __init__(self, **kwargs): super(NicIPAddressSettings, self).__init__(**kwargs) self.allocation_method = None self.ip_address = None @@ -1837,32 +1722,29 @@ class NicIPSettings(msrest.serialization.Model): """ _validation = { - 'primary_wins_server': {'readonly': True}, - 'secondary_wins_server': {'readonly': True}, - 'ip_address_info': {'readonly': True}, + "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]'}, + "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 - ): + 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.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 @@ -1880,19 +1762,16 @@ class Operation(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, + "name": {"key": "name", "type": "str"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "display": {"key": "display", "type": "OperationDisplay"}, } - def __init__( - self, - **kwargs - ): + def __init__(self, **kwargs): super(Operation, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.is_data_action = kwargs.get('is_data_action', None) - self.display = kwargs.get('display', None) + self.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): @@ -1909,21 +1788,18 @@ class OperationDisplay(msrest.serialization.Model): """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } - def __init__( - self, - **kwargs - ): + 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) + 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): @@ -1938,21 +1814,18 @@ class OperationsList(msrest.serialization.Model): """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[Operation]'}, + "next_link": {"key": "nextLink", "type": "str"}, + "value": {"key": "value", "type": "[Operation]"}, } - def __init__( - self, - **kwargs - ): + def __init__(self, **kwargs): super(OperationsList, self).__init__(**kwargs) - self.next_link = kwargs.get('next_link', None) - self.value = kwargs['value'] + self.next_link = kwargs.get("next_link", None) + self.value = kwargs["value"] class OsProfile(msrest.serialization.Model): @@ -1982,32 +1855,29 @@ class OsProfile(msrest.serialization.Model): """ _validation = { - 'os_name': {'readonly': True}, - 'tools_running_status': {'readonly': True}, - 'tools_version_status': {'readonly': True}, - 'tools_version': {'readonly': True}, + "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'}, + "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 - ): + 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.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 @@ -2032,21 +1902,18 @@ class PlacementProfile(msrest.serialization.Model): """ _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'}, + "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 - ): + 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) + 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): @@ -2117,66 +1984,63 @@ class ResourcePool(msrest.serialization.Model): """ _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 - ): + "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.location = kwargs["location"] + self.extended_location = kwargs.get("extended_location", None) self.system_data = None - self.tags = kwargs.get('tags', None) + self.tags = kwargs.get("tags", None) self.name = None self.id = None self.type = None - self.kind = kwargs.get('kind', 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.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 @@ -2214,26 +2078,23 @@ class ResourcePoolInventoryItem(InventoryItemProperties): """ _validation = { - 'inventory_type': {'required': True}, - 'provisioning_state': {'readonly': True}, + "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'}, + "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 - ): + def __init__(self, **kwargs): super(ResourcePoolInventoryItem, self).__init__(**kwargs) - self.inventory_type = 'ResourcePool' # type: str - self.parent = kwargs.get('parent', None) + self.inventory_type = "ResourcePool" # type: str + self.parent = kwargs.get("parent", None) class ResourcePoolsList(msrest.serialization.Model): @@ -2248,21 +2109,18 @@ class ResourcePoolsList(msrest.serialization.Model): """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[ResourcePool]'}, + "next_link": {"key": "nextLink", "type": "str"}, + "value": {"key": "value", "type": "[ResourcePool]"}, } - def __init__( - self, - **kwargs - ): + def __init__(self, **kwargs): super(ResourcePoolsList, self).__init__(**kwargs) - self.next_link = kwargs.get('next_link', None) - self.value = kwargs['value'] + self.next_link = kwargs.get("next_link", None) + self.value = kwargs["value"] class ResourceStatus(msrest.serialization.Model): @@ -2285,27 +2143,24 @@ class ResourceStatus(msrest.serialization.Model): """ _validation = { - 'type': {'readonly': True}, - 'status': {'readonly': True}, - 'reason': {'readonly': True}, - 'message': {'readonly': True}, - 'severity': {'readonly': True}, - 'last_updated_at': {'readonly': True}, + "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'}, + "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 - ): + def __init__(self, **kwargs): super(ResourceStatus, self).__init__(**kwargs) self.type = None self.status = None @@ -2325,15 +2180,12 @@ class StopVirtualMachineOptions(msrest.serialization.Model): """ _attribute_map = { - 'skip_shutdown': {'key': 'skipShutdown', 'type': 'bool'}, + "skip_shutdown": {"key": "skipShutdown", "type": "bool"}, } - def __init__( - self, - **kwargs - ): + def __init__(self, **kwargs): super(StopVirtualMachineOptions, self).__init__(**kwargs) - self.skip_shutdown = kwargs.get('skip_shutdown', False) + self.skip_shutdown = kwargs.get("skip_shutdown", False) class StorageProfile(msrest.serialization.Model): @@ -2349,20 +2201,17 @@ class StorageProfile(msrest.serialization.Model): """ _validation = { - 'scsi_controllers': {'readonly': True}, + "scsi_controllers": {"readonly": True}, } _attribute_map = { - 'disks': {'key': 'disks', 'type': '[VirtualDisk]'}, - 'scsi_controllers': {'key': 'scsiControllers', 'type': '[VirtualSCSIController]'}, + "disks": {"key": "disks", "type": "[VirtualDisk]"}, + "scsi_controllers": {"key": "scsiControllers", "type": "[VirtualSCSIController]"}, } - def __init__( - self, - **kwargs - ): + def __init__(self, **kwargs): super(StorageProfile, self).__init__(**kwargs) - self.disks = kwargs.get('disks', None) + self.disks = kwargs.get("disks", None) self.scsi_controllers = None @@ -2374,15 +2223,12 @@ class StorageProfileUpdate(msrest.serialization.Model): """ _attribute_map = { - 'disks': {'key': 'disks', 'type': '[VirtualDiskUpdate]'}, + "disks": {"key": "disks", "type": "[VirtualDiskUpdate]"}, } - def __init__( - self, - **kwargs - ): + def __init__(self, **kwargs): super(StorageProfileUpdate, self).__init__(**kwargs) - self.disks = kwargs.get('disks', None) + self.disks = kwargs.get("disks", None) class SystemData(msrest.serialization.Model): @@ -2405,25 +2251,22 @@ class SystemData(msrest.serialization.Model): """ _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'}, + "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 - ): + 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) + 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): @@ -2474,64 +2317,61 @@ class VCenter(msrest.serialization.Model): """ _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 - ): + "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.location = kwargs["location"] + self.extended_location = kwargs.get("extended_location", None) self.system_data = None - self.tags = kwargs.get('tags', None) + self.tags = kwargs.get("tags", None) self.name = None self.id = None self.type = None - self.kind = kwargs.get('kind', None) + self.kind = kwargs.get("kind", None) self.uuid = None - self.fqdn = kwargs['fqdn'] - self.port = kwargs.get('port', 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.credentials = kwargs.get("credentials", None) self.statuses = None self.provisioning_state = None @@ -2548,21 +2388,18 @@ class VCentersList(msrest.serialization.Model): """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[VCenter]'}, + "next_link": {"key": "nextLink", "type": "str"}, + "value": {"key": "value", "type": "[VCenter]"}, } - def __init__( - self, - **kwargs - ): + def __init__(self, **kwargs): super(VCentersList, self).__init__(**kwargs) - self.next_link = kwargs.get('next_link', None) - self.value = kwargs['value'] + self.next_link = kwargs.get("next_link", None) + self.value = kwargs["value"] class VICredential(msrest.serialization.Model): @@ -2575,17 +2412,14 @@ class VICredential(msrest.serialization.Model): """ _attribute_map = { - 'username': {'key': 'username', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, } - def __init__( - self, - **kwargs - ): + def __init__(self, **kwargs): super(VICredential, self).__init__(**kwargs) - self.username = kwargs.get('username', None) - self.password = kwargs.get('password', None) + self.username = kwargs.get("username", None) + self.password = kwargs.get("password", None) class VirtualDisk(msrest.serialization.Model): @@ -2618,38 +2452,35 @@ class VirtualDisk(msrest.serialization.Model): """ _validation = { - 'label': {'readonly': True}, - 'disk_object_id': {'readonly': True}, + "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'}, + "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 - ): + def __init__(self, **kwargs): super(VirtualDisk, self).__init__(**kwargs) - self.name = kwargs.get('name', None) + 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) + 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): @@ -2676,29 +2507,26 @@ class VirtualDiskUpdate(msrest.serialization.Model): """ _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'}, + "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 - ): + 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) + 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): @@ -2780,86 +2608,83 @@ class VirtualMachine(msrest.serialization.Model): """ _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 - ): + "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.location = kwargs["location"] + self.extended_location = kwargs.get("extended_location", None) self.system_data = None - self.tags = kwargs.get('tags', 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.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.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 @@ -2918,48 +2743,45 @@ class VirtualMachineInventoryItem(InventoryItemProperties): """ _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 - ): + "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.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 @@ -2978,21 +2800,18 @@ class VirtualMachinesList(msrest.serialization.Model): """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[VirtualMachine]'}, + "next_link": {"key": "nextLink", "type": "str"}, + "value": {"key": "value", "type": "[VirtualMachine]"}, } - def __init__( - self, - **kwargs - ): + def __init__(self, **kwargs): super(VirtualMachinesList, self).__init__(**kwargs) - self.next_link = kwargs.get('next_link', None) - self.value = kwargs['value'] + self.next_link = kwargs.get("next_link", None) + self.value = kwargs["value"] class VirtualMachineTemplate(msrest.serialization.Model): @@ -3067,76 +2886,73 @@ class VirtualMachineTemplate(msrest.serialization.Model): """ _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 - ): + "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.location = kwargs["location"] + self.extended_location = kwargs.get("extended_location", None) self.system_data = None - self.tags = kwargs.get('tags', None) + self.tags = kwargs.get("tags", None) self.name = None self.id = None self.type = None - self.kind = kwargs.get('kind', 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.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 @@ -3191,36 +3007,33 @@ class VirtualMachineTemplateInventoryItem(InventoryItemProperties): """ _validation = { - 'inventory_type': {'required': True}, - 'provisioning_state': {'readonly': True}, + "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'}, + "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 - ): + 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) + 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): @@ -3235,21 +3048,18 @@ class VirtualMachineTemplatesList(msrest.serialization.Model): """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[VirtualMachineTemplate]'}, + "next_link": {"key": "nextLink", "type": "str"}, + "value": {"key": "value", "type": "[VirtualMachineTemplate]"}, } - def __init__( - self, - **kwargs - ): + def __init__(self, **kwargs): super(VirtualMachineTemplatesList, self).__init__(**kwargs) - self.next_link = kwargs.get('next_link', None) - self.value = kwargs['value'] + self.next_link = kwargs.get("next_link", None) + self.value = kwargs["value"] class VirtualMachineUpdate(msrest.serialization.Model): @@ -3268,23 +3078,20 @@ class VirtualMachineUpdate(msrest.serialization.Model): """ _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'}, + "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 - ): + 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) + 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): @@ -3333,54 +3140,51 @@ class VirtualNetwork(msrest.serialization.Model): """ _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 - ): + "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.location = kwargs["location"] + self.extended_location = kwargs.get("extended_location", None) self.system_data = None - self.tags = kwargs.get('tags', None) + self.tags = kwargs.get("tags", None) self.name = None self.id = None self.type = None - self.kind = kwargs.get('kind', 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.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 @@ -3410,24 +3214,21 @@ class VirtualNetworkInventoryItem(InventoryItemProperties): """ _validation = { - 'inventory_type': {'required': True}, - 'provisioning_state': {'readonly': True}, + "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'}, + "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 - ): + def __init__(self, **kwargs): super(VirtualNetworkInventoryItem, self).__init__(**kwargs) - self.inventory_type = 'VirtualNetwork' # type: str + self.inventory_type = "VirtualNetwork" # type: str class VirtualNetworksList(msrest.serialization.Model): @@ -3442,21 +3243,18 @@ class VirtualNetworksList(msrest.serialization.Model): """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[VirtualNetwork]'}, + "next_link": {"key": "nextLink", "type": "str"}, + "value": {"key": "value", "type": "[VirtualNetwork]"}, } - def __init__( - self, - **kwargs - ): + def __init__(self, **kwargs): super(VirtualNetworksList, self).__init__(**kwargs) - self.next_link = kwargs.get('next_link', None) - self.value = kwargs['value'] + self.next_link = kwargs.get("next_link", None) + self.value = kwargs["value"] class VirtualSCSIController(msrest.serialization.Model): @@ -3477,20 +3275,17 @@ class VirtualSCSIController(msrest.serialization.Model): """ _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'}, + "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 - ): + 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) + 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..17cb9e0fbb4c 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 @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,48 +8,118 @@ # -------------------------------------------------------------------------- import datetime -from typing import Any, Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from .. import _serialization -from ._azure_arc_vmware_management_service_api_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class Cluster(msrest.serialization.Model): +class AvailablePatchCountByClassification(_serialization.Model): + """Summarization of patches available for installation on the machine by classification. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar security: Number of security patches available for installation. + :vartype security: int + :ivar critical: Number of critical patches available for installation. + :vartype critical: int + :ivar definition: Number of definition patches available for installation. + :vartype definition: int + :ivar update_rollup: Number of update Rollup patches available for installation. + :vartype update_rollup: int + :ivar feature_pack: Number of feature pack patches available for installation. + :vartype feature_pack: int + :ivar service_pack: Number of service pack patches available for installation. + :vartype service_pack: int + :ivar tools: Number of tools patches available for installation. + :vartype tools: int + :ivar updates: Number of updates category patches available for installation. + :vartype updates: int + :ivar other: Number of other patches available for installation. + :vartype other: int + """ + + _validation = { + "security": {"readonly": True}, + "critical": {"readonly": True}, + "definition": {"readonly": True}, + "update_rollup": {"readonly": True}, + "feature_pack": {"readonly": True}, + "service_pack": {"readonly": True}, + "tools": {"readonly": True}, + "updates": {"readonly": True}, + "other": {"readonly": True}, + } + + _attribute_map = { + "security": {"key": "security", "type": "int"}, + "critical": {"key": "critical", "type": "int"}, + "definition": {"key": "definition", "type": "int"}, + "update_rollup": {"key": "updateRollup", "type": "int"}, + "feature_pack": {"key": "featurePack", "type": "int"}, + "service_pack": {"key": "servicePack", "type": "int"}, + "tools": {"key": "tools", "type": "int"}, + "updates": {"key": "updates", "type": "int"}, + "other": {"key": "other", "type": "int"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.security = None + self.critical = None + self.definition = None + self.update_rollup = None + self.feature_pack = None + self.service_pack = None + self.tools = None + self.updates = None + self.other = None + + +class Cluster(_serialization.Model): # pylint: disable=too-many-instance-attributes """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 location: Gets or sets the location. Required. + :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: 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. @@ -64,46 +135,46 @@ class Cluster(msrest.serialization.Model): """ _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'}, + "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, *, location: str, - extended_location: Optional["ExtendedLocation"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, tags: Optional[Dict[str, str]] = None, kind: Optional[str] = None, v_center_id: Optional[str] = None, @@ -111,7 +182,27 @@ def __init__( inventory_item_id: Optional[str] = None, **kwargs ): - super(Cluster, self).__init__(**kwargs) + """ + :keyword location: Gets or sets the location. Required. + :paramtype location: str + :keyword extended_location: Gets or sets the extended location. + :paramtype extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation + :keyword 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().__init__(**kwargs) self.location = location self.extended_location = extended_location self.system_data = None @@ -132,46 +223,55 @@ def __init__( self.provisioning_state = None -class InventoryItemProperties(msrest.serialization.Model): +class InventoryItemProperties(_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. + 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 + :ivar inventory_type: They inventory type. Required. Known values are: "ResourcePool", + "VirtualMachine", "VirtualMachineTemplate", "VirtualNetwork", "Cluster", "Datastore", and + "Host". + :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 """ _validation = { - 'inventory_type': {'required': True}, - 'provisioning_state': {'readonly': True}, + "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'}, + "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'} + "inventory_type": { + "Cluster": "ClusterInventoryItem", + "Datastore": "DatastoreInventoryItem", + "Host": "HostInventoryItem", + "ResourcePool": "ResourcePoolInventoryItem", + "VirtualMachine": "VirtualMachineInventoryItem", + "VirtualMachineTemplate": "VirtualMachineTemplateInventoryItem", + "VirtualNetwork": "VirtualNetworkInventoryItem", + } } def __init__( @@ -182,7 +282,17 @@ def __init__( mo_name: Optional[str] = None, **kwargs ): - super(InventoryItemProperties, self).__init__(**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().__init__(**kwargs) self.inventory_type = None # type: Optional[str] self.managed_resource_id = managed_resource_id self.mo_ref_id = mo_ref_id @@ -197,32 +307,32 @@ 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", - "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 + :ivar inventory_type: They inventory type. Required. Known values are: "ResourcePool", + "VirtualMachine", "VirtualMachineTemplate", "VirtualNetwork", "Cluster", "Datastore", and + "Host". + :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 """ _validation = { - 'inventory_type': {'required': True}, - 'provisioning_state': {'readonly': True}, + "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'}, + "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__( @@ -233,43 +343,53 @@ def __init__( mo_name: Optional[str] = None, **kwargs ): - 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 - - -class ClustersList(msrest.serialization.Model): + """ + :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().__init__(managed_resource_id=managed_resource_id, mo_ref_id=mo_ref_id, mo_name=mo_name, **kwargs) + self.inventory_type = "Cluster" # type: str + + +class ClustersList(_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] + :ivar next_link: Url to follow for getting next page of Clusters. + :vartype next_link: str + :ivar value: Array of Clusters. Required. + :vartype value: list[~azure.mgmt.connectedvmware.models.Cluster] """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[Cluster]'}, + "next_link": {"key": "nextLink", "type": "str"}, + "value": {"key": "value", "type": "[Cluster]"}, } - def __init__( - self, - *, - value: List["Cluster"], - next_link: Optional[str] = None, - **kwargs - ): - super(ClustersList, self).__init__(**kwargs) + def __init__(self, *, value: List["_models.Cluster"], next_link: Optional[str] = None, **kwargs): + """ + :keyword next_link: Url to follow for getting next page of Clusters. + :paramtype next_link: str + :keyword value: Array of Clusters. Required. + :paramtype value: list[~azure.mgmt.connectedvmware.models.Cluster] + """ + super().__init__(**kwargs) self.next_link = next_link self.value = value -class Condition(msrest.serialization.Model): +class Condition(_serialization.Model): """Condition defines an extension to status. Variables are only populated by the server, and will be ignored when sending a request. @@ -285,114 +405,111 @@ class Condition(msrest.serialization.Model): """ _validation = { - 'status': {'readonly': True}, - 'reason': {'readonly': True}, - 'message': {'readonly': True}, - 'severity': {'readonly': True}, + "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'}, + "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) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.status = None self.reason = None self.message = None self.severity = None -class Datastore(msrest.serialization.Model): +class Datastore(_serialization.Model): # pylint: disable=too-many-instance-attributes """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 location: Gets or sets the location. Required. + :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: 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. :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". + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Succeeded", + "Failed", "Canceled", "Provisioning", "Updating", "Deleting", "Accepted", and "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'}, + "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, *, location: str, - extended_location: Optional["ExtendedLocation"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, tags: Optional[Dict[str, str]] = None, kind: Optional[str] = None, v_center_id: Optional[str] = None, @@ -400,7 +517,27 @@ def __init__( inventory_item_id: Optional[str] = None, **kwargs ): - super(Datastore, self).__init__(**kwargs) + """ + :keyword location: Gets or sets the location. Required. + :paramtype location: str + :keyword extended_location: Gets or sets the extended location. + :paramtype extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation + :keyword 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().__init__(**kwargs) self.location = location self.extended_location = extended_location self.system_data = None @@ -426,38 +563,38 @@ 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", - "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 + :ivar inventory_type: They inventory type. Required. Known values are: "ResourcePool", + "VirtualMachine", "VirtualMachineTemplate", "VirtualNetwork", "Cluster", "Datastore", and + "Host". + :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: int + :ivar free_space_gb: Gets or sets Available space of this datastore, in GBs. + :vartype free_space_gb: int """ _validation = { - 'inventory_type': {'required': True}, - 'provisioning_state': {'readonly': True}, + "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'}, + "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": "int"}, + "free_space_gb": {"key": "freeSpaceGB", "type": "int"}, } def __init__( @@ -470,45 +607,59 @@ def __init__( free_space_gb: Optional[int] = None, **kwargs ): - 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 + """ + :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: int + :keyword free_space_gb: Gets or sets Available space of this datastore, in GBs. + :paramtype free_space_gb: int + """ + super().__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 self.free_space_gb = free_space_gb -class DatastoresList(msrest.serialization.Model): +class DatastoresList(_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] + :ivar next_link: Url to follow for getting next page of Datastores. + :vartype next_link: str + :ivar value: Array of Datastores. Required. + :vartype value: list[~azure.mgmt.connectedvmware.models.Datastore] """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[Datastore]'}, + "next_link": {"key": "nextLink", "type": "str"}, + "value": {"key": "value", "type": "[Datastore]"}, } - def __init__( - self, - *, - value: List["Datastore"], - next_link: Optional[str] = None, - **kwargs - ): - super(DatastoresList, self).__init__(**kwargs) + def __init__(self, *, value: List["_models.Datastore"], next_link: Optional[str] = None, **kwargs): + """ + :keyword next_link: Url to follow for getting next page of Datastores. + :paramtype next_link: str + :keyword value: Array of Datastores. Required. + :paramtype value: list[~azure.mgmt.connectedvmware.models.Datastore] + """ + super().__init__(**kwargs) self.next_link = next_link self.value = value -class ErrorDefinition(msrest.serialization.Model): +class ErrorDefinition(_serialization.Model): """Error definition. Variables are only populated by the server, and will be ignored when sending a request. @@ -522,52 +673,50 @@ class ErrorDefinition(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'details': {'readonly': True}, + "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]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "details": {"key": "details", "type": "[ErrorDefinition]"}, } - def __init__( - self, - **kwargs - ): - super(ErrorDefinition, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.details = None -class ErrorDetail(msrest.serialization.Model): +class ErrorDetail(_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] + :ivar code: The error's code. Required. + :vartype code: str + :ivar message: A human readable error message. Required. + :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 = { - 'code': {'required': True}, - 'message': {'required': True}, + "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]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorDetail]"}, } def __init__( @@ -576,64 +725,73 @@ def __init__( code: str, message: str, target: Optional[str] = None, - details: Optional[List["ErrorDetail"]] = None, + details: Optional[List["_models.ErrorDetail"]] = None, **kwargs ): - super(ErrorDetail, self).__init__(**kwargs) + """ + :keyword code: The error's code. Required. + :paramtype code: str + :keyword message: A human readable error message. Required. + :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().__init__(**kwargs) self.code = code self.message = message self.target = target self.details = details -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_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 = { - 'error': {'key': 'error', 'type': 'ErrorDefinition'}, + "error": {"key": "error", "type": "ErrorDefinition"}, } - def __init__( - self, - *, - error: Optional["ErrorDefinition"] = None, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) + def __init__(self, *, error: Optional["_models.ErrorDefinition"] = None, **kwargs): + """ + :keyword error: The error details. + :paramtype error: ~azure.mgmt.connectedvmware.models.ErrorDefinition + """ + super().__init__(**kwargs) self.error = error -class ExtendedLocation(msrest.serialization.Model): +class ExtendedLocation(_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 = { - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - type: Optional[str] = None, - name: Optional[str] = None, - **kwargs - ): - super(ExtendedLocation, self).__init__(**kwargs) + def __init__(self, *, type: Optional[str] = None, name: Optional[str] = None, **kwargs): + """ + :keyword type: The extended location type. + :paramtype type: str + :keyword name: The extended location name. + :paramtype name: str + """ + super().__init__(**kwargs) self.type = type self.name = name -class Resource(msrest.serialization.Model): +class Resource(_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. @@ -649,22 +807,20 @@ class Resource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -686,25 +842,23 @@ class ProxyResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "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'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(ProxyResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) -class GuestAgent(ProxyResource): +class GuestAgent(ProxyResource): # pylint: disable=too-many-instance-attributes """Defines the GuestAgent. Variables are only populated by the server, and will be ignored when sending a request. @@ -721,13 +875,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 - include: "install", "uninstall", "repair". - :type provisioning_action: str or ~azure.mgmt.connectedvmware.models.ProvisioningAction + :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. Known values are: + "install", "uninstall", and "repair". + :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. @@ -739,41 +893,50 @@ class GuestAgent(ProxyResource): """ _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'}, + "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, *, - credentials: Optional["GuestCredential"] = None, - http_proxy_config: Optional["HttpProxyConfiguration"] = None, - provisioning_action: Optional[Union[str, "ProvisioningAction"]] = None, + credentials: Optional["_models.GuestCredential"] = None, + http_proxy_config: Optional["_models.HttpProxyConfiguration"] = None, + provisioning_action: Optional[Union[str, "_models.ProvisioningAction"]] = None, **kwargs ): - super(GuestAgent, self).__init__(**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. Known values + are: "install", "uninstall", and "repair". + :paramtype provisioning_action: str or ~azure.mgmt.connectedvmware.models.ProvisioningAction + """ + super().__init__(**kwargs) self.system_data = None self.uuid = None self.credentials = credentials @@ -785,47 +948,47 @@ def __init__( self.provisioning_state = None -class GuestAgentList(msrest.serialization.Model): +class GuestAgentList(_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] + :ivar next_link: Url to follow for getting next page of GuestAgent. + :vartype next_link: str + :ivar value: Array of GuestAgent. Required. + :vartype value: list[~azure.mgmt.connectedvmware.models.GuestAgent] """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[GuestAgent]'}, + "next_link": {"key": "nextLink", "type": "str"}, + "value": {"key": "value", "type": "[GuestAgent]"}, } - def __init__( - self, - *, - value: List["GuestAgent"], - next_link: Optional[str] = None, - **kwargs - ): - super(GuestAgentList, self).__init__(**kwargs) + def __init__(self, *, value: List["_models.GuestAgent"], next_link: Optional[str] = None, **kwargs): + """ + :keyword next_link: Url to follow for getting next page of GuestAgent. + :paramtype next_link: str + :keyword value: Array of GuestAgent. Required. + :paramtype value: list[~azure.mgmt.connectedvmware.models.GuestAgent] + """ + super().__init__(**kwargs) self.next_link = next_link self.value = value -class GuestAgentProfile(msrest.serialization.Model): +class GuestAgentProfile(_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". + :ivar status: The status of the hybrid machine agent. Known values are: "Connected", + "Disconnected", and "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 @@ -836,26 +999,24 @@ class GuestAgentProfile(msrest.serialization.Model): """ _validation = { - 'vm_uuid': {'readonly': True}, - 'status': {'readonly': True}, - 'last_status_change': {'readonly': True}, - 'agent_version': {'readonly': True}, - 'error_details': {'readonly': True}, + "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]'}, + "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) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.vm_uuid = None self.status = None self.last_status_change = None @@ -863,44 +1024,44 @@ def __init__( self.error_details = None -class GuestCredential(msrest.serialization.Model): +class GuestCredential(_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 = { - 'username': {'key': 'username', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, } - def __init__( - self, - *, - username: Optional[str] = None, - password: Optional[str] = None, - **kwargs - ): - super(GuestCredential, self).__init__(**kwargs) + def __init__(self, *, username: Optional[str] = None, 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().__init__(**kwargs) self.username = username self.password = password -class HardwareProfile(msrest.serialization.Model): +class HardwareProfile(_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 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 @@ -913,18 +1074,18 @@ class HardwareProfile(msrest.serialization.Model): """ _validation = { - 'cpu_hot_add_enabled': {'readonly': True}, - 'cpu_hot_remove_enabled': {'readonly': True}, - 'memory_hot_add_enabled': {'readonly': True}, + "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'}, + "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__( @@ -935,7 +1096,16 @@ def __init__( num_cores_per_socket: Optional[int] = None, **kwargs ): - super(HardwareProfile, self).__init__(**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().__init__(**kwargs) self.memory_size_mb = memory_size_mb self.num_cp_us = num_cp_us self.num_cores_per_socket = num_cores_per_socket @@ -944,39 +1114,39 @@ def __init__( self.memory_hot_add_enabled = None -class Host(msrest.serialization.Model): +class Host(_serialization.Model): # pylint: disable=too-many-instance-attributes """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 location: Gets or sets the location. Required. + :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: 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. @@ -988,42 +1158,42 @@ class Host(msrest.serialization.Model): """ _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'}, + "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, *, location: str, - extended_location: Optional["ExtendedLocation"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, tags: Optional[Dict[str, str]] = None, kind: Optional[str] = None, v_center_id: Optional[str] = None, @@ -1031,7 +1201,26 @@ def __init__( inventory_item_id: Optional[str] = None, **kwargs ): - super(Host, self).__init__(**kwargs) + """ + :keyword location: Gets or sets the location. Required. + :paramtype location: str + :keyword extended_location: Gets or sets the extended location. + :paramtype extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation + :keyword 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().__init__(**kwargs) self.location = location self.extended_location = extended_location self.system_data = None @@ -1057,35 +1246,35 @@ 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", - "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 + :ivar inventory_type: They inventory type. Required. Known values are: "ResourcePool", + "VirtualMachine", "VirtualMachineTemplate", "VirtualNetwork", "Cluster", "Datastore", and + "Host". + :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 = { - 'inventory_type': {'required': True}, - 'provisioning_state': {'readonly': True}, + "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'}, + "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__( @@ -1094,64 +1283,75 @@ def __init__( managed_resource_id: Optional[str] = None, mo_ref_id: Optional[str] = None, mo_name: Optional[str] = None, - parent: Optional["InventoryItemDetails"] = None, + parent: Optional["_models.InventoryItemDetails"] = None, **kwargs ): - 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 + """ + :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().__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 -class HostsList(msrest.serialization.Model): +class HostsList(_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] + :ivar next_link: Url to follow for getting next page of Hosts. + :vartype next_link: str + :ivar value: Array of Hosts. Required. + :vartype value: list[~azure.mgmt.connectedvmware.models.Host] """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[Host]'}, + "next_link": {"key": "nextLink", "type": "str"}, + "value": {"key": "value", "type": "[Host]"}, } - def __init__( - self, - *, - value: List["Host"], - next_link: Optional[str] = None, - **kwargs - ): - super(HostsList, self).__init__(**kwargs) + def __init__(self, *, value: List["_models.Host"], next_link: Optional[str] = None, **kwargs): + """ + :keyword next_link: Url to follow for getting next page of Hosts. + :paramtype next_link: str + :keyword value: Array of Hosts. Required. + :paramtype value: list[~azure.mgmt.connectedvmware.models.Host] + """ + super().__init__(**kwargs) self.next_link = next_link self.value = value -class HttpProxyConfiguration(msrest.serialization.Model): +class HttpProxyConfiguration(_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 = { - 'https_proxy': {'key': 'httpsProxy', 'type': 'str'}, + "https_proxy": {"key": "httpsProxy", "type": "str"}, } - def __init__( - self, - *, - https_proxy: Optional[str] = None, - **kwargs - ): - super(HttpProxyConfiguration, self).__init__(**kwargs) + def __init__(self, *, https_proxy: Optional[str] = None, **kwargs): + """ + :keyword https_proxy: Gets or sets httpsProxy url. + :paramtype https_proxy: str + """ + super().__init__(**kwargs) self.https_proxy = https_proxy @@ -1170,10 +1370,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. @@ -1181,33 +1381,33 @@ class HybridIdentityMetadata(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'identity': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "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'}, + "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, - *, - vm_id: Optional[str] = None, - public_key: Optional[str] = None, - **kwargs - ): - super(HybridIdentityMetadata, self).__init__(**kwargs) + def __init__(self, *, vm_id: Optional[str] = None, 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().__init__(**kwargs) self.system_data = None self.vm_id = vm_id self.public_key = public_key @@ -1215,39 +1415,39 @@ def __init__( self.provisioning_state = None -class HybridIdentityMetadataList(msrest.serialization.Model): +class HybridIdentityMetadataList(_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] + :ivar next_link: Url to follow for getting next page of HybridIdentityMetadata. + :vartype next_link: str + :ivar value: Array of HybridIdentityMetadata. Required. + :vartype value: list[~azure.mgmt.connectedvmware.models.HybridIdentityMetadata] """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[HybridIdentityMetadata]'}, + "next_link": {"key": "nextLink", "type": "str"}, + "value": {"key": "value", "type": "[HybridIdentityMetadata]"}, } - def __init__( - self, - *, - value: List["HybridIdentityMetadata"], - next_link: Optional[str] = None, - **kwargs - ): - super(HybridIdentityMetadataList, self).__init__(**kwargs) + def __init__(self, *, value: List["_models.HybridIdentityMetadata"], next_link: Optional[str] = None, **kwargs): + """ + :keyword next_link: Url to follow for getting next page of HybridIdentityMetadata. + :paramtype next_link: str + :keyword value: Array of HybridIdentityMetadata. Required. + :paramtype value: list[~azure.mgmt.connectedvmware.models.HybridIdentityMetadata] + """ + super().__init__(**kwargs) self.next_link = next_link self.value = value -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Managed service identity. Variables are only populated by the server, and will be ignored when sending a request. @@ -1258,30 +1458,30 @@ 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: The type of managed service identity. Required. Known values are: "None" and "SystemAssigned". - :type type: str or ~azure.mgmt.connectedvmware.models.IdentityType + :vartype type: str or ~azure.mgmt.connectedvmware.models.IdentityType """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'type': {'required': True}, + "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'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - type: Union[str, "IdentityType"], - **kwargs - ): - super(Identity, self).__init__(**kwargs) + def __init__(self, *, type: Union[str, "_models.IdentityType"], **kwargs): + """ + :keyword type: The type of managed service identity. Required. Known values are: "None" and + "SystemAssigned". + :paramtype type: str or ~azure.mgmt.connectedvmware.models.IdentityType + """ + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type @@ -1304,45 +1504,45 @@ 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", - "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 kind: str + :ivar inventory_type: They inventory type. Required. Known values are: "ResourcePool", + "VirtualMachine", "VirtualMachineTemplate", "VirtualNetwork", "Cluster", "Datastore", and + "Host". + :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 """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'inventory_type': {'required': True}, - 'provisioning_state': {'readonly': True}, + "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'}, + "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__( @@ -1354,7 +1554,21 @@ def __init__( mo_name: Optional[str] = None, **kwargs ): - super(InventoryItem, self).__init__(**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().__init__(**kwargs) self.system_data = None self.kind = kind self.inventory_type = None # type: Optional[str] @@ -1364,130 +1578,182 @@ def __init__( self.provisioning_state = None -class InventoryItemDetails(msrest.serialization.Model): +class InventoryItemDetails(_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 = { - 'inventory_item_id': {'key': 'inventoryItemId', 'type': 'str'}, - 'mo_name': {'key': 'moName', 'type': 'str'}, + "inventory_item_id": {"key": "inventoryItemId", "type": "str"}, + "mo_name": {"key": "moName", "type": "str"}, } - def __init__( - self, - *, - inventory_item_id: Optional[str] = None, - mo_name: Optional[str] = None, - **kwargs - ): - super(InventoryItemDetails, self).__init__(**kwargs) + def __init__(self, *, inventory_item_id: Optional[str] = None, 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().__init__(**kwargs) self.inventory_item_id = inventory_item_id self.mo_name = mo_name -class InventoryItemsList(msrest.serialization.Model): +class InventoryItemsList(_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] + :ivar next_link: Url to follow for getting next page of InventoryItems. + :vartype next_link: str + :ivar value: Array of InventoryItems. Required. + :vartype value: list[~azure.mgmt.connectedvmware.models.InventoryItem] """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[InventoryItem]'}, + "next_link": {"key": "nextLink", "type": "str"}, + "value": {"key": "value", "type": "[InventoryItem]"}, + } + + def __init__(self, *, value: List["_models.InventoryItem"], next_link: Optional[str] = None, **kwargs): + """ + :keyword next_link: Url to follow for getting next page of InventoryItems. + :paramtype next_link: str + :keyword value: Array of InventoryItems. Required. + :paramtype value: list[~azure.mgmt.connectedvmware.models.InventoryItem] + """ + super().__init__(**kwargs) + self.next_link = next_link + self.value = value + + +class LinuxParameters(_serialization.Model): + """Input for InstallPatches on a Linux VM, as directly received by the API. + + :ivar classifications_to_include: The update classifications to select when installing patches + for Linux. + :vartype classifications_to_include: list[str or + ~azure.mgmt.connectedvmware.models.VMGuestPatchClassificationLinux] + :ivar package_name_masks_to_include: packages to include in the patch operation. Format: + packageName_packageVersion. + :vartype package_name_masks_to_include: list[str] + :ivar package_name_masks_to_exclude: packages to exclude in the patch operation. Format: + packageName_packageVersion. + :vartype package_name_masks_to_exclude: list[str] + """ + + _attribute_map = { + "classifications_to_include": {"key": "classificationsToInclude", "type": "[str]"}, + "package_name_masks_to_include": {"key": "packageNameMasksToInclude", "type": "[str]"}, + "package_name_masks_to_exclude": {"key": "packageNameMasksToExclude", "type": "[str]"}, } def __init__( self, *, - value: List["InventoryItem"], - next_link: Optional[str] = None, + classifications_to_include: Optional[List[Union[str, "_models.VMGuestPatchClassificationLinux"]]] = None, + package_name_masks_to_include: Optional[List[str]] = None, + package_name_masks_to_exclude: Optional[List[str]] = None, **kwargs ): - super(InventoryItemsList, self).__init__(**kwargs) - self.next_link = next_link - self.value = value - - -class MachineExtension(msrest.serialization.Model): + """ + :keyword classifications_to_include: The update classifications to select when installing + patches for Linux. + :paramtype classifications_to_include: list[str or + ~azure.mgmt.connectedvmware.models.VMGuestPatchClassificationLinux] + :keyword package_name_masks_to_include: packages to include in the patch operation. Format: + packageName_packageVersion. + :paramtype package_name_masks_to_include: list[str] + :keyword package_name_masks_to_exclude: packages to exclude in the patch operation. Format: + packageName_packageVersion. + :paramtype package_name_masks_to_exclude: list[str] + """ + super().__init__(**kwargs) + self.classifications_to_include = classifications_to_include + self.package_name_masks_to_include = package_name_masks_to_include + self.package_name_masks_to_exclude = package_name_masks_to_exclude + + +class MachineExtension(_serialization.Model): # pylint: disable=too-many-instance-attributes """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 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: 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 enable_automatic_upgrade: Indicates whether the extension should be automatically + upgraded by the platform if there is a newer version available. + :vartype enable_automatic_upgrade: bool + :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: JSON + :ivar protected_settings: The extension can contain either protectedSettings or protectedSettingsFromKeyVault or no protected settings at all. - :type protected_settings: any + :vartype protected_settings: JSON :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 = { - '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'}, + "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"}, + "enable_automatic_upgrade": {"key": "properties.enableAutomaticUpgrade", "type": "bool"}, + "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__( @@ -1499,13 +1765,45 @@ def __init__( publisher: Optional[str] = None, type_properties_type: Optional[str] = None, type_handler_version: Optional[str] = None, + enable_automatic_upgrade: Optional[bool] = None, auto_upgrade_minor_version: Optional[bool] = None, - settings: Optional[Any] = None, - protected_settings: Optional[Any] = None, - instance_view: Optional["MachineExtensionPropertiesInstanceView"] = None, + settings: Optional[JSON] = None, + protected_settings: Optional[JSON] = None, + instance_view: Optional["_models.MachineExtensionPropertiesInstanceView"] = None, **kwargs ): - super(MachineExtension, self).__init__(**kwargs) + """ + :keyword location: Gets or sets the location. + :paramtype location: str + :keyword 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 enable_automatic_upgrade: Indicates whether the extension should be automatically + upgraded by the platform if there is a newer version available. + :paramtype enable_automatic_upgrade: bool + :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: JSON + :keyword protected_settings: The extension can contain either protectedSettings or + protectedSettingsFromKeyVault or no protected settings at all. + :paramtype protected_settings: JSON + :keyword instance_view: The machine extension instance view. + :paramtype instance_view: + ~azure.mgmt.connectedvmware.models.MachineExtensionPropertiesInstanceView + """ + super().__init__(**kwargs) self.location = location self.system_data = None self.tags = tags @@ -1516,6 +1814,7 @@ def __init__( self.publisher = publisher self.type_properties_type = type_properties_type self.type_handler_version = type_handler_version + self.enable_automatic_upgrade = enable_automatic_upgrade self.auto_upgrade_minor_version = auto_upgrade_minor_version self.settings = settings self.protected_settings = protected_settings @@ -1523,7 +1822,7 @@ def __init__( self.instance_view = instance_view -class MachineExtensionInstanceView(msrest.serialization.Model): +class MachineExtensionInstanceView(_serialization.Model): """Describes the Machine Extension Instance View. Variables are only populated by the server, and will be ignored when sending a request. @@ -1534,44 +1833,43 @@ 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 = { - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'type_handler_version': {'readonly': True}, + "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'}, + "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, - *, - status: Optional["MachineExtensionInstanceViewStatus"] = None, - **kwargs - ): - super(MachineExtensionInstanceView, self).__init__(**kwargs) + def __init__(self, *, status: Optional["_models.MachineExtensionInstanceViewStatus"] = None, **kwargs): + """ + :keyword status: Instance view status. + :paramtype status: ~azure.mgmt.connectedvmware.models.MachineExtensionInstanceViewStatus + """ + super().__init__(**kwargs) self.name = None self.type = None self.type_handler_version = None self.status = status -class MachineExtensionInstanceViewStatus(msrest.serialization.Model): +class MachineExtensionInstanceViewStatus(_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". + :ivar level: The level code. Known values are: "Info", "Warning", and "Error". :vartype level: str or ~azure.mgmt.connectedvmware.models.StatusLevelTypes :ivar display_status: The short localizable label for the status. :vartype display_status: str @@ -1582,26 +1880,24 @@ class MachineExtensionInstanceViewStatus(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'level': {'readonly': True}, - 'display_status': {'readonly': True}, - 'message': {'readonly': True}, - 'time': {'readonly': True}, + "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'}, + "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) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.level = None self.display_status = None @@ -1620,114 +1916,119 @@ 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 = { - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'type_handler_version': {'readonly': True}, + "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'}, + "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, - *, - status: Optional["MachineExtensionInstanceViewStatus"] = None, - **kwargs - ): - super(MachineExtensionPropertiesInstanceView, self).__init__(status=status, **kwargs) + def __init__(self, *, status: Optional["_models.MachineExtensionInstanceViewStatus"] = None, **kwargs): + """ + :keyword status: Instance view status. + :paramtype status: ~azure.mgmt.connectedvmware.models.MachineExtensionInstanceViewStatus + """ + super().__init__(status=status, **kwargs) -class MachineExtensionsListResult(msrest.serialization.Model): +class MachineExtensionsListResult(_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 = { - 'value': {'key': 'value', 'type': '[MachineExtension]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[MachineExtension]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["MachineExtension"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.MachineExtension"]] = None, next_link: Optional[str] = None, **kwargs ): - super(MachineExtensionsListResult, self).__init__(**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().__init__(**kwargs) self.value = value self.next_link = next_link -class ResourcePatch(msrest.serialization.Model): +class ResourcePatch(_serialization.Model): """Object containing updates for patch operations. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar tags: Resource tags. + :vartype tags: dict[str, str] """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): - super(ResourcePatch, self).__init__(**kwargs) + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) self.tags = tags 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: 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 enable_automatic_upgrade: Indicates whether the extension should be automatically + upgraded by the platform if there is a newer version available. + :vartype enable_automatic_upgrade: bool + :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: JSON + :ivar protected_settings: The extension can contain either protectedSettings or protectedSettingsFromKeyVault or no protected settings at all. - :type protected_settings: any + :vartype protected_settings: JSON """ _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'}, + "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"}, + "enable_automatic_upgrade": {"key": "properties.enableAutomaticUpgrade", "type": "bool"}, + "auto_upgrade_minor_version": {"key": "properties.autoUpgradeMinorVersion", "type": "bool"}, + "settings": {"key": "properties.settings", "type": "object"}, + "protected_settings": {"key": "properties.protectedSettings", "type": "object"}, } def __init__( @@ -1738,28 +2039,55 @@ def __init__( publisher: Optional[str] = None, type: Optional[str] = None, type_handler_version: Optional[str] = None, + enable_automatic_upgrade: Optional[bool] = None, auto_upgrade_minor_version: Optional[bool] = None, - settings: Optional[Any] = None, - protected_settings: Optional[Any] = None, + settings: Optional[JSON] = None, + protected_settings: Optional[JSON] = None, **kwargs ): - super(MachineExtensionUpdate, self).__init__(tags=tags, **kwargs) + """ + :keyword 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 enable_automatic_upgrade: Indicates whether the extension should be automatically + upgraded by the platform if there is a newer version available. + :paramtype enable_automatic_upgrade: bool + :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: JSON + :keyword protected_settings: The extension can contain either protectedSettings or + protectedSettingsFromKeyVault or no protected settings at all. + :paramtype protected_settings: JSON + """ + super().__init__(tags=tags, **kwargs) self.force_update_tag = force_update_tag self.publisher = publisher self.type = type self.type_handler_version = type_handler_version + self.enable_automatic_upgrade = enable_automatic_upgrade self.auto_upgrade_minor_version = auto_upgrade_minor_version self.settings = settings self.protected_settings = protected_settings -class NetworkInterface(msrest.serialization.Model): +class NetworkInterface(_serialization.Model): # pylint: disable=too-many-instance-attributes """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 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 +2095,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", - "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 network_id: str + :ivar nic_type: NIC type. Known values are: "vmxnet3", "vmxnet2", "vmxnet", "e1000", "e1000e", + and "pcnet32". + :vartype nic_type: str or ~azure.mgmt.connectedvmware.models.NICType + :ivar power_on_boot: Gets or sets the power on boot. Known values are: "enabled" and "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,32 +2111,32 @@ 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 = { - 'label': {'readonly': True}, - 'ip_addresses': {'readonly': True}, - 'mac_address': {'readonly': True}, - 'network_mo_ref_id': {'readonly': True}, - 'network_mo_name': {'readonly': True}, + "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'}, + "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__( @@ -1816,13 +2144,30 @@ def __init__( *, name: Optional[str] = None, network_id: Optional[str] = None, - nic_type: Optional[Union[str, "NICType"]] = None, - power_on_boot: Optional[Union[str, "PowerOnBootOption"]] = None, + nic_type: Optional[Union[str, "_models.NICType"]] = None, + power_on_boot: Optional[Union[str, "_models.PowerOnBootOption"]] = None, device_key: Optional[int] = None, - ip_settings: Optional["NicIPSettings"] = None, + ip_settings: Optional["_models.NicIPSettings"] = None, **kwargs ): - super(NetworkInterface, self).__init__(**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. Known values are: "vmxnet3", "vmxnet2", "vmxnet", "e1000", + "e1000e", and "pcnet32". + :paramtype nic_type: str or ~azure.mgmt.connectedvmware.models.NICType + :keyword power_on_boot: Gets or sets the power on boot. Known values are: "enabled" and + "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().__init__(**kwargs) self.name = name self.label = None self.ip_addresses = None @@ -1836,30 +2181,30 @@ def __init__( self.ip_settings = ip_settings -class NetworkInterfaceUpdate(msrest.serialization.Model): +class NetworkInterfaceUpdate(_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", - "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 network_id: str + :ivar nic_type: NIC type. Known values are: "vmxnet3", "vmxnet2", "vmxnet", "e1000", "e1000e", + and "pcnet32". + :vartype nic_type: str or ~azure.mgmt.connectedvmware.models.NICType + :ivar power_on_boot: Gets or sets the power on boot. Known values are: "enabled" and "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 = { - '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'}, + "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__( @@ -1867,12 +2212,27 @@ def __init__( *, name: Optional[str] = None, network_id: Optional[str] = None, - nic_type: Optional[Union[str, "NICType"]] = None, - power_on_boot: Optional[Union[str, "PowerOnBootOption"]] = None, + nic_type: Optional[Union[str, "_models.NICType"]] = None, + power_on_boot: Optional[Union[str, "_models.PowerOnBootOption"]] = None, device_key: Optional[int] = None, **kwargs ): - super(NetworkInterfaceUpdate, self).__init__(**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. Known values are: "vmxnet3", "vmxnet2", "vmxnet", "e1000", + "e1000e", and "pcnet32". + :paramtype nic_type: str or ~azure.mgmt.connectedvmware.models.NICType + :keyword power_on_boot: Gets or sets the power on boot. Known values are: "enabled" and + "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().__init__(**kwargs) self.name = name self.network_id = network_id self.nic_type = nic_type @@ -1880,51 +2240,51 @@ def __init__( self.device_key = device_key -class NetworkProfile(msrest.serialization.Model): +class NetworkProfile(_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 = { - 'network_interfaces': {'key': 'networkInterfaces', 'type': '[NetworkInterface]'}, + "network_interfaces": {"key": "networkInterfaces", "type": "[NetworkInterface]"}, } - def __init__( - self, - *, - network_interfaces: Optional[List["NetworkInterface"]] = None, - **kwargs - ): - super(NetworkProfile, self).__init__(**kwargs) + def __init__(self, *, network_interfaces: Optional[List["_models.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().__init__(**kwargs) self.network_interfaces = network_interfaces -class NetworkProfileUpdate(msrest.serialization.Model): +class NetworkProfileUpdate(_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 = { - 'network_interfaces': {'key': 'networkInterfaces', 'type': '[NetworkInterfaceUpdate]'}, + "network_interfaces": {"key": "networkInterfaces", "type": "[NetworkInterfaceUpdate]"}, } - def __init__( - self, - *, - network_interfaces: Optional[List["NetworkInterfaceUpdate"]] = None, - **kwargs - ): - super(NetworkProfileUpdate, self).__init__(**kwargs) + def __init__(self, *, network_interfaces: Optional[List["_models.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().__init__(**kwargs) self.network_interfaces = network_interfaces -class NicIPAddressSettings(msrest.serialization.Model): +class NicIPAddressSettings(_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. @@ -1938,43 +2298,41 @@ class NicIPAddressSettings(msrest.serialization.Model): """ _validation = { - 'allocation_method': {'readonly': True}, - 'ip_address': {'readonly': True}, - 'subnet_mask': {'readonly': True}, + "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'}, + "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) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.allocation_method = None self.ip_address = None self.subnet_mask = None -class NicIPSettings(msrest.serialization.Model): +class NicIPSettings(_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 allocation_method: Gets or sets the nic allocation method. Known values are: "unset", + "dynamic", "static", "linklayer", "random", and "other". + :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. @@ -1985,33 +2343,47 @@ class NicIPSettings(msrest.serialization.Model): """ _validation = { - 'primary_wins_server': {'readonly': True}, - 'secondary_wins_server': {'readonly': True}, - 'ip_address_info': {'readonly': True}, + "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]'}, + "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, *, - allocation_method: Optional[Union[str, "IPAddressAllocationMethod"]] = None, + allocation_method: Optional[Union[str, "_models.IPAddressAllocationMethod"]] = None, dns_servers: Optional[List[str]] = None, gateway: Optional[List[str]] = None, ip_address: Optional[str] = None, subnet_mask: Optional[str] = None, **kwargs ): - super(NicIPSettings, self).__init__(**kwargs) + """ + :keyword allocation_method: Gets or sets the nic allocation method. Known values are: "unset", + "dynamic", "static", "linklayer", "random", and "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().__init__(**kwargs) self.allocation_method = allocation_method self.dns_servers = dns_servers self.gateway = gateway @@ -2022,21 +2394,21 @@ def __init__( self.ip_address_info = None -class Operation(msrest.serialization.Model): +class Operation(_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 = { - 'name': {'key': 'name', 'type': 'str'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, + "name": {"key": "name", "type": "str"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "display": {"key": "display", "type": "OperationDisplay"}, } def __init__( @@ -2044,33 +2416,41 @@ def __init__( *, name: Optional[str] = None, is_data_action: Optional[bool] = None, - display: Optional["OperationDisplay"] = None, + display: Optional["_models.OperationDisplay"] = None, **kwargs ): - super(Operation, self).__init__(**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().__init__(**kwargs) self.name = name self.is_data_action = is_data_action self.display = display -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_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 = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -2082,59 +2462,74 @@ def __init__( description: Optional[str] = None, **kwargs ): - super(OperationDisplay, self).__init__(**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().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationsList(msrest.serialization.Model): +class OperationsList(_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] + :ivar next_link: Url to follow for getting next page of operations. + :vartype next_link: str + :ivar value: Array of operations. Required. + :vartype value: list[~azure.mgmt.connectedvmware.models.Operation] """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[Operation]'}, + "next_link": {"key": "nextLink", "type": "str"}, + "value": {"key": "value", "type": "[Operation]"}, } - def __init__( - self, - *, - value: List["Operation"], - next_link: Optional[str] = None, - **kwargs - ): - super(OperationsList, self).__init__(**kwargs) + def __init__(self, *, value: List["_models.Operation"], next_link: Optional[str] = None, **kwargs): + """ + :keyword next_link: Url to follow for getting next page of operations. + :paramtype next_link: str + :keyword value: Array of operations. Required. + :paramtype value: list[~azure.mgmt.connectedvmware.models.Operation] + """ + super().__init__(**kwargs) self.next_link = next_link self.value = value -class OsProfile(msrest.serialization.Model): +class OsProfile(_serialization.Model): # pylint: disable=too-many-instance-attributes """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", + :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 guest_id: Gets or sets the guestId. + :vartype guest_id: str + :ivar allow_extension_operations: Gets or sets a value indicating whether the VM is ready for + extension operations. + :vartype allow_extension_operations: bool + :ivar os_type: Gets or sets the type of the os. Known values are: "Windows", "Linux", and "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 @@ -2145,24 +2540,34 @@ class OsProfile(msrest.serialization.Model): :vartype tools_version_status: str :ivar tools_version: Gets or sets the current version of VMware Tools. :vartype tools_version: str + :ivar windows_configuration: Specifies the windows configuration for update management. + :vartype windows_configuration: + ~azure.mgmt.connectedvmware.models.OsProfileWindowsConfiguration + :ivar linux_configuration: Specifies the linux configuration for update management. + :vartype linux_configuration: ~azure.mgmt.connectedvmware.models.OsProfileLinuxConfiguration """ _validation = { - 'os_name': {'readonly': True}, - 'tools_running_status': {'readonly': True}, - 'tools_version_status': {'readonly': True}, - 'tools_version': {'readonly': True}, + "allow_extension_operations": {"readonly": True}, + "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'}, + "computer_name": {"key": "computerName", "type": "str"}, + "admin_username": {"key": "adminUsername", "type": "str"}, + "admin_password": {"key": "adminPassword", "type": "str"}, + "guest_id": {"key": "guestId", "type": "str"}, + "allow_extension_operations": {"key": "allowExtensionOperations", "type": "bool"}, + "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"}, + "windows_configuration": {"key": "windowsConfiguration", "type": "OsProfileWindowsConfiguration"}, + "linux_configuration": {"key": "linuxConfiguration", "type": "OsProfileLinuxConfiguration"}, } def __init__( @@ -2171,42 +2576,207 @@ def __init__( computer_name: Optional[str] = None, admin_username: Optional[str] = None, admin_password: Optional[str] = None, - os_type: Optional[Union[str, "OsType"]] = None, + guest_id: Optional[str] = None, + os_type: Optional[Union[str, "_models.OsType"]] = None, + windows_configuration: Optional["_models.OsProfileWindowsConfiguration"] = None, + linux_configuration: Optional["_models.OsProfileLinuxConfiguration"] = None, **kwargs ): - super(OsProfile, self).__init__(**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 guest_id: Gets or sets the guestId. + :paramtype guest_id: str + :keyword os_type: Gets or sets the type of the os. Known values are: "Windows", "Linux", and + "Other". + :paramtype os_type: str or ~azure.mgmt.connectedvmware.models.OsType + :keyword windows_configuration: Specifies the windows configuration for update management. + :paramtype windows_configuration: + ~azure.mgmt.connectedvmware.models.OsProfileWindowsConfiguration + :keyword linux_configuration: Specifies the linux configuration for update management. + :paramtype linux_configuration: ~azure.mgmt.connectedvmware.models.OsProfileLinuxConfiguration + """ + super().__init__(**kwargs) self.computer_name = computer_name self.admin_username = admin_username self.admin_password = admin_password + self.guest_id = guest_id + self.allow_extension_operations = None self.os_type = os_type self.os_name = None self.tools_running_status = None self.tools_version_status = None self.tools_version = None + self.windows_configuration = windows_configuration + self.linux_configuration = linux_configuration + + +class OsProfileLinuxConfiguration(_serialization.Model): + """Specifies the linux configuration for update management. + + :ivar assessment_mode: Specifies the assessment mode. + :vartype assessment_mode: str + :ivar patch_mode: Specifies the patch mode. + :vartype patch_mode: str + """ + + _attribute_map = { + "assessment_mode": {"key": "patchSettings.assessmentMode", "type": "str"}, + "patch_mode": {"key": "patchSettings.patchMode", "type": "str"}, + } + + def __init__(self, *, assessment_mode: Optional[str] = None, patch_mode: Optional[str] = None, **kwargs): + """ + :keyword assessment_mode: Specifies the assessment mode. + :paramtype assessment_mode: str + :keyword patch_mode: Specifies the patch mode. + :paramtype patch_mode: str + """ + super().__init__(**kwargs) + self.assessment_mode = assessment_mode + self.patch_mode = patch_mode + + +class OsProfileUpdate(_serialization.Model): + """Defines the os update properties. + + :ivar windows_configuration: Specifies the windows configuration for update management. + :vartype windows_configuration: + ~azure.mgmt.connectedvmware.models.OsProfileUpdateWindowsConfiguration + :ivar linux_configuration: Specifies the linux configuration for update management. + :vartype linux_configuration: + ~azure.mgmt.connectedvmware.models.OsProfileUpdateLinuxConfiguration + """ + + _attribute_map = { + "windows_configuration": {"key": "windowsConfiguration", "type": "OsProfileUpdateWindowsConfiguration"}, + "linux_configuration": {"key": "linuxConfiguration", "type": "OsProfileUpdateLinuxConfiguration"}, + } + + def __init__( + self, + *, + windows_configuration: Optional["_models.OsProfileUpdateWindowsConfiguration"] = None, + linux_configuration: Optional["_models.OsProfileUpdateLinuxConfiguration"] = None, + **kwargs + ): + """ + :keyword windows_configuration: Specifies the windows configuration for update management. + :paramtype windows_configuration: + ~azure.mgmt.connectedvmware.models.OsProfileUpdateWindowsConfiguration + :keyword linux_configuration: Specifies the linux configuration for update management. + :paramtype linux_configuration: + ~azure.mgmt.connectedvmware.models.OsProfileUpdateLinuxConfiguration + """ + super().__init__(**kwargs) + self.windows_configuration = windows_configuration + self.linux_configuration = linux_configuration + + +class OsProfileUpdateLinuxConfiguration(_serialization.Model): + """Specifies the linux configuration for update management. + + :ivar assessment_mode: Specifies the assessment mode. + :vartype assessment_mode: str + :ivar patch_mode: Specifies the patch mode. + :vartype patch_mode: str + """ + + _attribute_map = { + "assessment_mode": {"key": "patchSettings.assessmentMode", "type": "str"}, + "patch_mode": {"key": "patchSettings.patchMode", "type": "str"}, + } + + def __init__(self, *, assessment_mode: Optional[str] = None, patch_mode: Optional[str] = None, **kwargs): + """ + :keyword assessment_mode: Specifies the assessment mode. + :paramtype assessment_mode: str + :keyword patch_mode: Specifies the patch mode. + :paramtype patch_mode: str + """ + super().__init__(**kwargs) + self.assessment_mode = assessment_mode + self.patch_mode = patch_mode + + +class OsProfileUpdateWindowsConfiguration(_serialization.Model): + """Specifies the windows configuration for update management. + + :ivar assessment_mode: Specifies the assessment mode. + :vartype assessment_mode: str + :ivar patch_mode: Specifies the patch mode. + :vartype patch_mode: str + """ + _attribute_map = { + "assessment_mode": {"key": "patchSettings.assessmentMode", "type": "str"}, + "patch_mode": {"key": "patchSettings.patchMode", "type": "str"}, + } + + def __init__(self, *, assessment_mode: Optional[str] = None, patch_mode: Optional[str] = None, **kwargs): + """ + :keyword assessment_mode: Specifies the assessment mode. + :paramtype assessment_mode: str + :keyword patch_mode: Specifies the patch mode. + :paramtype patch_mode: str + """ + super().__init__(**kwargs) + self.assessment_mode = assessment_mode + self.patch_mode = patch_mode + + +class OsProfileWindowsConfiguration(_serialization.Model): + """Specifies the windows configuration for update management. + + :ivar assessment_mode: Specifies the assessment mode. + :vartype assessment_mode: str + :ivar patch_mode: Specifies the patch mode. + :vartype patch_mode: str + """ -class PlacementProfile(msrest.serialization.Model): + _attribute_map = { + "assessment_mode": {"key": "patchSettings.assessmentMode", "type": "str"}, + "patch_mode": {"key": "patchSettings.patchMode", "type": "str"}, + } + + def __init__(self, *, assessment_mode: Optional[str] = None, patch_mode: Optional[str] = None, **kwargs): + """ + :keyword assessment_mode: Specifies the assessment mode. + :paramtype assessment_mode: str + :keyword patch_mode: Specifies the patch mode. + :paramtype patch_mode: str + """ + super().__init__(**kwargs) + self.assessment_mode = assessment_mode + self.patch_mode = patch_mode + + +class PlacementProfile(_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 = { - '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'}, + "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__( @@ -2218,48 +2788,62 @@ def __init__( datastore_id: Optional[str] = None, **kwargs ): - super(PlacementProfile, self).__init__(**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().__init__(**kwargs) self.resource_pool_id = resource_pool_id self.cluster_id = cluster_id self.host_id = host_id self.datastore_id = datastore_id -class ResourcePool(msrest.serialization.Model): +class ResourcePool(_serialization.Model): # pylint: disable=too-many-instance-attributes """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 location: Gets or sets the location. Required. + :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: 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 @@ -2269,10 +2853,10 @@ class ResourcePool(msrest.serialization.Model): :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 + :vartype cpu_reservation_m_hz: int :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 + :vartype cpu_limit_m_hz: int :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. @@ -2280,10 +2864,10 @@ class ResourcePool(msrest.serialization.Model): :ivar mem_reservation_mb: Gets or sets MemReservationMB which specifies the guaranteed available memory in megabytes. - :vartype mem_reservation_mb: long + :vartype mem_reservation_mb: int :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 + :vartype mem_limit_mb: int :ivar custom_resource_name: Gets the name of the corresponding resource in Kubernetes. :vartype custom_resource_name: str :ivar statuses: The resource status information. @@ -2293,54 +2877,54 @@ class ResourcePool(msrest.serialization.Model): """ _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'}, + "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": "int"}, + "cpu_limit_m_hz": {"key": "properties.cpuLimitMHz", "type": "int"}, + "mem_shares_level": {"key": "properties.memSharesLevel", "type": "str"}, + "mem_reservation_mb": {"key": "properties.memReservationMB", "type": "int"}, + "mem_limit_mb": {"key": "properties.memLimitMB", "type": "int"}, + "custom_resource_name": {"key": "properties.customResourceName", "type": "str"}, + "statuses": {"key": "properties.statuses", "type": "[ResourceStatus]"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( self, *, location: str, - extended_location: Optional["ExtendedLocation"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, tags: Optional[Dict[str, str]] = None, kind: Optional[str] = None, v_center_id: Optional[str] = None, @@ -2348,7 +2932,27 @@ def __init__( inventory_item_id: Optional[str] = None, **kwargs ): - super(ResourcePool, self).__init__(**kwargs) + """ + :keyword location: Gets or sets the location. Required. + :paramtype location: str + :keyword extended_location: Gets or sets the extended location. + :paramtype extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation + :keyword 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().__init__(**kwargs) self.location = location self.extended_location = extended_location self.system_data = None @@ -2380,35 +2984,35 @@ 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", - "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 + :ivar inventory_type: They inventory type. Required. Known values are: "ResourcePool", + "VirtualMachine", "VirtualMachineTemplate", "VirtualNetwork", "Cluster", "Datastore", and + "Host". + :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 = { - 'inventory_type': {'required': True}, - 'provisioning_state': {'readonly': True}, + "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'}, + "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__( @@ -2417,47 +3021,59 @@ def __init__( managed_resource_id: Optional[str] = None, mo_ref_id: Optional[str] = None, mo_name: Optional[str] = None, - parent: Optional["InventoryItemDetails"] = None, + parent: Optional["_models.InventoryItemDetails"] = None, **kwargs ): - 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 + """ + :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().__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 -class ResourcePoolsList(msrest.serialization.Model): +class ResourcePoolsList(_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] + :ivar next_link: Url to follow for getting next page of ResourcePools. + :vartype next_link: str + :ivar value: Array of ResourcePools. Required. + :vartype value: list[~azure.mgmt.connectedvmware.models.ResourcePool] """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[ResourcePool]'}, + "next_link": {"key": "nextLink", "type": "str"}, + "value": {"key": "value", "type": "[ResourcePool]"}, } - def __init__( - self, - *, - value: List["ResourcePool"], - next_link: Optional[str] = None, - **kwargs - ): - super(ResourcePoolsList, self).__init__(**kwargs) + def __init__(self, *, value: List["_models.ResourcePool"], next_link: Optional[str] = None, **kwargs): + """ + :keyword next_link: Url to follow for getting next page of ResourcePools. + :paramtype next_link: str + :keyword value: Array of ResourcePools. Required. + :paramtype value: list[~azure.mgmt.connectedvmware.models.ResourcePool] + """ + super().__init__(**kwargs) self.next_link = next_link self.value = value -class ResourceStatus(msrest.serialization.Model): +class ResourceStatus(_serialization.Model): """The resource status information. Variables are only populated by the server, and will be ignored when sending a request. @@ -2477,28 +3093,26 @@ class ResourceStatus(msrest.serialization.Model): """ _validation = { - 'type': {'readonly': True}, - 'status': {'readonly': True}, - 'reason': {'readonly': True}, - 'message': {'readonly': True}, - 'severity': {'readonly': True}, - 'last_updated_at': {'readonly': True}, + "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'}, + "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) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.status = None self.reason = None @@ -2507,122 +3121,159 @@ def __init__( self.last_updated_at = None -class StopVirtualMachineOptions(msrest.serialization.Model): +class SecurityProfile(_serialization.Model): + """Specifies the Security profile settings for the virtual machine. + + :ivar uefi_settings: Specifies the security settings like secure boot used while creating the + virtual machine. + :vartype uefi_settings: ~azure.mgmt.connectedvmware.models.UefiSettings + """ + + _attribute_map = { + "uefi_settings": {"key": "uefiSettings", "type": "UefiSettings"}, + } + + def __init__(self, *, uefi_settings: Optional["_models.UefiSettings"] = None, **kwargs): + """ + :keyword uefi_settings: Specifies the security settings like secure boot used while creating + the virtual machine. + :paramtype uefi_settings: ~azure.mgmt.connectedvmware.models.UefiSettings + """ + super().__init__(**kwargs) + self.uefi_settings = uefi_settings + + +class StopVirtualMachineOptions(_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 = { - 'skip_shutdown': {'key': 'skipShutdown', 'type': 'bool'}, + "skip_shutdown": {"key": "skipShutdown", "type": "bool"}, } - def __init__( - self, - *, - skip_shutdown: Optional[bool] = False, - **kwargs - ): - super(StopVirtualMachineOptions, self).__init__(**kwargs) + def __init__(self, *, skip_shutdown: 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().__init__(**kwargs) self.skip_shutdown = skip_shutdown -class StorageProfile(msrest.serialization.Model): +class StorageProfile(_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 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] """ _validation = { - 'scsi_controllers': {'readonly': True}, + "scsi_controllers": {"readonly": True}, } _attribute_map = { - 'disks': {'key': 'disks', 'type': '[VirtualDisk]'}, - 'scsi_controllers': {'key': 'scsiControllers', 'type': '[VirtualSCSIController]'}, + "disks": {"key": "disks", "type": "[VirtualDisk]"}, + "scsi_controllers": {"key": "scsiControllers", "type": "[VirtualSCSIController]"}, } - def __init__( - self, - *, - disks: Optional[List["VirtualDisk"]] = None, - **kwargs - ): - super(StorageProfile, self).__init__(**kwargs) + def __init__(self, *, disks: Optional[List["_models.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().__init__(**kwargs) self.disks = disks self.scsi_controllers = None -class StorageProfileUpdate(msrest.serialization.Model): +class StorageProfileUpdate(_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 = { - 'disks': {'key': 'disks', 'type': '[VirtualDiskUpdate]'}, + "disks": {"key": "disks", "type": "[VirtualDiskUpdate]"}, } - def __init__( - self, - *, - disks: Optional[List["VirtualDiskUpdate"]] = None, - **kwargs - ): - super(StorageProfileUpdate, self).__init__(**kwargs) + def __init__(self, *, disks: Optional[List["_models.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().__init__(**kwargs) self.disks = disks -class SystemData(msrest.serialization.Model): +class SystemData(_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 + :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. Known values are: + "User", "Application", "ManagedIdentity", and "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. Known values + are: "User", "Application", "ManagedIdentity", and "Key". + :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 = { - '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'}, + "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, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): - super(SystemData, self).__init__(**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. Known values are: + "User", "Application", "ManagedIdentity", and "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. Known + values are: "User", "Application", "ManagedIdentity", and "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().__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type self.created_at = created_at @@ -2631,37 +3282,59 @@ def __init__( self.last_modified_at = last_modified_at -class VCenter(msrest.serialization.Model): +class UefiSettings(_serialization.Model): + """Specifies the security settings like secure boot used while creating the virtual machine. + + :ivar secure_boot_enabled: Specifies whether secure boot should be enabled on the virtual + machine. + :vartype secure_boot_enabled: bool + """ + + _attribute_map = { + "secure_boot_enabled": {"key": "secureBootEnabled", "type": "bool"}, + } + + def __init__(self, *, secure_boot_enabled: Optional[bool] = None, **kwargs): + """ + :keyword secure_boot_enabled: Specifies whether secure boot should be enabled on the virtual + machine. + :paramtype secure_boot_enabled: bool + """ + super().__init__(**kwargs) + self.secure_boot_enabled = secure_boot_enabled + + +class VCenter(_serialization.Model): # pylint: disable=too-many-instance-attributes """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 location: Gets or sets the location. Required. + :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: 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: Gets or sets the FQDN/IPAddress of the vCenter. Required. + :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 +3343,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. @@ -2679,41 +3352,41 @@ class VCenter(msrest.serialization.Model): """ _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'}, + "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__( @@ -2721,14 +3394,32 @@ def __init__( *, location: str, fqdn: str, - extended_location: Optional["ExtendedLocation"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, tags: Optional[Dict[str, str]] = None, kind: Optional[str] = None, port: Optional[int] = None, - credentials: Optional["VICredential"] = None, + credentials: Optional["_models.VICredential"] = None, **kwargs ): - super(VCenter, self).__init__(**kwargs) + """ + :keyword location: Gets or sets the location. Required. + :paramtype location: str + :keyword extended_location: Gets or sets the extended location. + :paramtype extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation + :keyword 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: Gets or sets the FQDN/IPAddress of the vCenter. Required. + :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().__init__(**kwargs) self.location = location self.extended_location = extended_location self.system_data = None @@ -2749,109 +3440,109 @@ def __init__( self.provisioning_state = None -class VCentersList(msrest.serialization.Model): +class VCentersList(_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] + :ivar next_link: Url to follow for getting next page of VCenters. + :vartype next_link: str + :ivar value: Array of VCenters. Required. + :vartype value: list[~azure.mgmt.connectedvmware.models.VCenter] """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[VCenter]'}, + "next_link": {"key": "nextLink", "type": "str"}, + "value": {"key": "value", "type": "[VCenter]"}, } - def __init__( - self, - *, - value: List["VCenter"], - next_link: Optional[str] = None, - **kwargs - ): - super(VCentersList, self).__init__(**kwargs) + def __init__(self, *, value: List["_models.VCenter"], next_link: Optional[str] = None, **kwargs): + """ + :keyword next_link: Url to follow for getting next page of VCenters. + :paramtype next_link: str + :keyword value: Array of VCenters. Required. + :paramtype value: list[~azure.mgmt.connectedvmware.models.VCenter] + """ + super().__init__(**kwargs) self.next_link = next_link self.value = value -class VICredential(msrest.serialization.Model): +class VICredential(_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 = { - 'username': {'key': 'username', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, } - def __init__( - self, - *, - username: Optional[str] = None, - password: Optional[str] = None, - **kwargs - ): - super(VICredential, self).__init__(**kwargs) + def __init__(self, *, username: Optional[str] = None, 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().__init__(**kwargs) self.username = username self.password = password -class VirtualDisk(msrest.serialization.Model): +class VirtualDisk(_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 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", - "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 + :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. Known values are: "persistent", + "independent_persistent", and "independent_nonpersistent". + :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. Known values are: "flat", "pmem", + "rawphysical", "rawvirtual", "sparse", "sesparse", and "unknown". + :vartype disk_type: str or ~azure.mgmt.connectedvmware.models.DiskType """ _validation = { - 'label': {'readonly': True}, - 'disk_object_id': {'readonly': True}, + "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'}, + "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__( @@ -2860,14 +3551,34 @@ def __init__( name: Optional[str] = None, disk_size_gb: Optional[int] = None, device_key: Optional[int] = None, - disk_mode: Optional[Union[str, "DiskMode"]] = None, + disk_mode: Optional[Union[str, "_models.DiskMode"]] = None, controller_key: Optional[int] = None, unit_number: Optional[int] = None, device_name: Optional[str] = None, - disk_type: Optional[Union[str, "DiskType"]] = None, + disk_type: Optional[Union[str, "_models.DiskType"]] = None, **kwargs ): - super(VirtualDisk, self).__init__(**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. Known values are: "persistent", + "independent_persistent", and "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. Known values are: "flat", "pmem", + "rawphysical", "rawvirtual", "sparse", "sesparse", and "unknown". + :paramtype disk_type: str or ~azure.mgmt.connectedvmware.models.DiskType + """ + super().__init__(**kwargs) self.name = name self.label = None self.disk_object_id = None @@ -2880,38 +3591,38 @@ def __init__( self.disk_type = disk_type -class VirtualDiskUpdate(msrest.serialization.Model): +class VirtualDiskUpdate(_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'}, + :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. Known values are: "persistent", + "independent_persistent", and "independent_nonpersistent". + :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. Known values are: "flat", "pmem", + "rawphysical", "rawvirtual", "sparse", "sesparse", and "unknown". + :vartype 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__( @@ -2920,14 +3631,34 @@ def __init__( name: Optional[str] = None, disk_size_gb: Optional[int] = None, device_key: Optional[int] = None, - disk_mode: Optional[Union[str, "DiskMode"]] = None, + disk_mode: Optional[Union[str, "_models.DiskMode"]] = None, controller_key: Optional[int] = None, unit_number: Optional[int] = None, device_name: Optional[str] = None, - disk_type: Optional[Union[str, "DiskType"]] = None, + disk_type: Optional[Union[str, "_models.DiskType"]] = None, **kwargs ): - super(VirtualDiskUpdate, self).__init__(**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. Known values are: "persistent", + "independent_persistent", and "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. Known values are: "flat", "pmem", + "rawphysical", "rawvirtual", "sparse", "sesparse", and "unknown". + :paramtype disk_type: str or ~azure.mgmt.connectedvmware.models.DiskType + """ + super().__init__(**kwargs) self.name = name self.disk_size_gb = disk_size_gb self.device_key = device_key @@ -2938,70 +3669,72 @@ def __init__( self.disk_type = disk_type -class VirtualMachine(msrest.serialization.Model): +class VirtualMachine(_serialization.Model): # pylint: disable=too-many-instance-attributes """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 location: Gets or sets the location. Required. + :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: 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 security_profile: Gets the security profile. + :vartype security_profile: ~azure.mgmt.connectedvmware.models.SecurityProfile + :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. Known values are: "bios" and "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. @@ -3017,80 +3750,129 @@ class VirtualMachine(msrest.serialization.Model): """ _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'}, + "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}, } - def __init__( + _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"}, + "security_profile": {"key": "properties.securityProfile", "type": "SecurityProfile"}, + "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__( # pylint: disable=too-many-locals self, *, location: str, - extended_location: Optional["ExtendedLocation"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, tags: Optional[Dict[str, str]] = None, kind: Optional[str] = None, - identity: Optional["Identity"] = None, + identity: Optional["_models.Identity"] = None, resource_pool_id: Optional[str] = None, template_id: Optional[str] = None, v_center_id: Optional[str] = None, - placement_profile: Optional["PlacementProfile"] = None, - os_profile: Optional["OsProfile"] = None, - hardware_profile: Optional["HardwareProfile"] = None, - network_profile: Optional["NetworkProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - guest_agent_profile: Optional["GuestAgentProfile"] = None, + placement_profile: Optional["_models.PlacementProfile"] = None, + os_profile: Optional["_models.OsProfile"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + guest_agent_profile: Optional["_models.GuestAgentProfile"] = None, + security_profile: Optional["_models.SecurityProfile"] = None, mo_ref_id: Optional[str] = None, inventory_item_id: Optional[str] = None, smbios_uuid: Optional[str] = None, - firmware_type: Optional[Union[str, "FirmwareType"]] = None, + firmware_type: Optional[Union[str, "_models.FirmwareType"]] = None, **kwargs ): - super(VirtualMachine, self).__init__(**kwargs) + """ + :keyword location: Gets or sets the location. Required. + :paramtype location: str + :keyword extended_location: Gets or sets the extended location. + :paramtype extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation + :keyword 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 security_profile: Gets the security profile. + :paramtype security_profile: ~azure.mgmt.connectedvmware.models.SecurityProfile + :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. Known values are: "bios" and "efi". + :paramtype firmware_type: str or ~azure.mgmt.connectedvmware.models.FirmwareType + """ + super().__init__(**kwargs) self.location = location self.extended_location = extended_location self.system_data = None @@ -3109,6 +3891,7 @@ def __init__( self.network_profile = network_profile self.storage_profile = storage_profile self.guest_agent_profile = guest_agent_profile + self.security_profile = security_profile self.mo_ref_id = mo_ref_id self.inventory_item_id = inventory_item_id self.mo_name = None @@ -3124,43 +3907,302 @@ def __init__( self.vm_id = None -class VirtualMachineInventoryItem(InventoryItemProperties): +class VirtualMachineAssessPatchesResult(_serialization.Model): + """Describes the properties of an AssessPatches result. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar status: The overall success or failure status of the operation. It remains "InProgress" + until the operation completes. At that point it will become "Unknown", "Failed", "Succeeded", + or "CompletedWithWarnings.". Known values are: "Unknown", "InProgress", "Failed", "Succeeded", + and "CompletedWithWarnings". + :vartype status: str or ~azure.mgmt.connectedvmware.models.PatchOperationStatus + :ivar assessment_activity_id: The activity ID of the operation that produced this result. + :vartype assessment_activity_id: str + :ivar reboot_pending: The overall reboot status of the VM. It will be true when partially + installed patches require a reboot to complete installation but the reboot has not yet + occurred. + :vartype reboot_pending: bool + :ivar available_patch_count_by_classification: Summarization of patches available for + installation on the machine by classification. + :vartype available_patch_count_by_classification: + ~azure.mgmt.connectedvmware.models.AvailablePatchCountByClassification + :ivar start_date_time: The UTC timestamp when the operation began. + :vartype start_date_time: ~datetime.datetime + :ivar last_modified_date_time: The UTC timestamp when the operation finished. + :vartype last_modified_date_time: ~datetime.datetime + :ivar started_by: Indicates if operation was triggered by user or by platform. Known values + are: "User" and "Platform". + :vartype started_by: str or ~azure.mgmt.connectedvmware.models.PatchOperationStartedBy + :ivar patch_service_used: Specifies the patch service used for the operation. Known values are: + "Unknown", "WU", "WU_WSUS", "YUM", "APT", and "Zypper". + :vartype patch_service_used: str or ~azure.mgmt.connectedvmware.models.PatchServiceUsed + :ivar os_type: The operating system type of the machine. Known values are: "Windows" and + "Linux". + :vartype os_type: str or ~azure.mgmt.connectedvmware.models.OsTypeUM + :ivar error_details: The errors that were encountered during execution of the operation. The + details array contains the list of them. + :vartype error_details: ~azure.mgmt.connectedvmware.models.ErrorDetail + """ + + _validation = { + "status": {"readonly": True}, + "assessment_activity_id": {"readonly": True}, + "reboot_pending": {"readonly": True}, + "start_date_time": {"readonly": True}, + "last_modified_date_time": {"readonly": True}, + "started_by": {"readonly": True}, + "patch_service_used": {"readonly": True}, + "os_type": {"readonly": True}, + "error_details": {"readonly": True}, + } + + _attribute_map = { + "status": {"key": "status", "type": "str"}, + "assessment_activity_id": {"key": "assessmentActivityId", "type": "str"}, + "reboot_pending": {"key": "rebootPending", "type": "bool"}, + "available_patch_count_by_classification": { + "key": "availablePatchCountByClassification", + "type": "AvailablePatchCountByClassification", + }, + "start_date_time": {"key": "startDateTime", "type": "iso-8601"}, + "last_modified_date_time": {"key": "lastModifiedDateTime", "type": "iso-8601"}, + "started_by": {"key": "startedBy", "type": "str"}, + "patch_service_used": {"key": "patchServiceUsed", "type": "str"}, + "os_type": {"key": "osType", "type": "str"}, + "error_details": {"key": "errorDetails", "type": "ErrorDetail"}, + } + + def __init__( + self, + *, + available_patch_count_by_classification: Optional["_models.AvailablePatchCountByClassification"] = None, + **kwargs + ): + """ + :keyword available_patch_count_by_classification: Summarization of patches available for + installation on the machine by classification. + :paramtype available_patch_count_by_classification: + ~azure.mgmt.connectedvmware.models.AvailablePatchCountByClassification + """ + super().__init__(**kwargs) + self.status = None + self.assessment_activity_id = None + self.reboot_pending = None + self.available_patch_count_by_classification = available_patch_count_by_classification + self.start_date_time = None + self.last_modified_date_time = None + self.started_by = None + self.patch_service_used = None + self.os_type = None + self.error_details = None + + +class VirtualMachineInstallPatchesParameters(_serialization.Model): + """Input for InstallPatches as directly received by the API. + + All required parameters must be populated in order to send to Azure. + + :ivar maximum_duration: Specifies the maximum amount of time that the operation will run. It + must be an ISO 8601-compliant duration string such as PT4H (4 hours). Required. + :vartype maximum_duration: str + :ivar reboot_setting: Defines when it is acceptable to reboot a VM during a software update + operation. Required. Known values are: "IfRequired", "Never", and "Always". + :vartype reboot_setting: str or ~azure.mgmt.connectedvmware.models.VMGuestPatchRebootSetting + :ivar windows_parameters: Input for InstallPatches on a Windows VM, as directly received by the + API. + :vartype windows_parameters: ~azure.mgmt.connectedvmware.models.WindowsParameters + :ivar linux_parameters: Input for InstallPatches on a Linux VM, as directly received by the + API. + :vartype linux_parameters: ~azure.mgmt.connectedvmware.models.LinuxParameters + """ + + _validation = { + "maximum_duration": {"required": True}, + "reboot_setting": {"required": True}, + } + + _attribute_map = { + "maximum_duration": {"key": "maximumDuration", "type": "str"}, + "reboot_setting": {"key": "rebootSetting", "type": "str"}, + "windows_parameters": {"key": "windowsParameters", "type": "WindowsParameters"}, + "linux_parameters": {"key": "linuxParameters", "type": "LinuxParameters"}, + } + + def __init__( + self, + *, + maximum_duration: str, + reboot_setting: Union[str, "_models.VMGuestPatchRebootSetting"], + windows_parameters: Optional["_models.WindowsParameters"] = None, + linux_parameters: Optional["_models.LinuxParameters"] = None, + **kwargs + ): + """ + :keyword maximum_duration: Specifies the maximum amount of time that the operation will run. It + must be an ISO 8601-compliant duration string such as PT4H (4 hours). Required. + :paramtype maximum_duration: str + :keyword reboot_setting: Defines when it is acceptable to reboot a VM during a software update + operation. Required. Known values are: "IfRequired", "Never", and "Always". + :paramtype reboot_setting: str or ~azure.mgmt.connectedvmware.models.VMGuestPatchRebootSetting + :keyword windows_parameters: Input for InstallPatches on a Windows VM, as directly received by + the API. + :paramtype windows_parameters: ~azure.mgmt.connectedvmware.models.WindowsParameters + :keyword linux_parameters: Input for InstallPatches on a Linux VM, as directly received by the + API. + :paramtype linux_parameters: ~azure.mgmt.connectedvmware.models.LinuxParameters + """ + super().__init__(**kwargs) + self.maximum_duration = maximum_duration + self.reboot_setting = reboot_setting + self.windows_parameters = windows_parameters + self.linux_parameters = linux_parameters + + +class VirtualMachineInstallPatchesResult(_serialization.Model): # pylint: disable=too-many-instance-attributes + """The result summary of an installation operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar status: The overall success or failure status of the operation. It remains "InProgress" + until the operation completes. At that point it will become "Failed", "Succeeded", "Unknown" or + "CompletedWithWarnings.". Known values are: "Unknown", "InProgress", "Failed", "Succeeded", and + "CompletedWithWarnings". + :vartype status: str or ~azure.mgmt.connectedvmware.models.PatchOperationStatus + :ivar installation_activity_id: The activity ID of the operation that produced this result. + :vartype installation_activity_id: str + :ivar reboot_status: The reboot state of the VM following completion of the operation. Known + values are: "Unknown", "NotNeeded", "Required", "Started", "Failed", and "Completed". + :vartype reboot_status: str or ~azure.mgmt.connectedvmware.models.VMGuestPatchRebootStatus + :ivar maintenance_window_exceeded: Whether the operation ran out of time before it completed + all its intended actions. + :vartype maintenance_window_exceeded: bool + :ivar excluded_patch_count: The number of patches that were not installed due to the user + blocking their installation. + :vartype excluded_patch_count: int + :ivar not_selected_patch_count: The number of patches that were detected as available for + install, but did not meet the operation's criteria. + :vartype not_selected_patch_count: int + :ivar pending_patch_count: The number of patches that were identified as meeting the + installation criteria, but were not able to be installed. Typically this happens when + maintenanceWindowExceeded == true. + :vartype pending_patch_count: int + :ivar installed_patch_count: The number of patches successfully installed. + :vartype installed_patch_count: int + :ivar failed_patch_count: The number of patches that could not be installed due to some issue. + See errors for details. + :vartype failed_patch_count: int + :ivar start_date_time: The UTC timestamp when the operation began. + :vartype start_date_time: ~datetime.datetime + :ivar last_modified_date_time: The UTC timestamp when the operation finished. + :vartype last_modified_date_time: ~datetime.datetime + :ivar started_by: Indicates if operation was triggered by user or by platform. Known values + are: "User" and "Platform". + :vartype started_by: str or ~azure.mgmt.connectedvmware.models.PatchOperationStartedBy + :ivar patch_service_used: Specifies the patch service used for the operation. Known values are: + "Unknown", "WU", "WU_WSUS", "YUM", "APT", and "Zypper". + :vartype patch_service_used: str or ~azure.mgmt.connectedvmware.models.PatchServiceUsed + :ivar os_type: The operating system type of the machine. Known values are: "Windows" and + "Linux". + :vartype os_type: str or ~azure.mgmt.connectedvmware.models.OsTypeUM + :ivar error_details: The errors that were encountered during execution of the operation. The + details array contains the list of them. + :vartype error_details: ~azure.mgmt.connectedvmware.models.ErrorDetail + """ + + _validation = { + "status": {"readonly": True}, + "installation_activity_id": {"readonly": True}, + "reboot_status": {"readonly": True}, + "maintenance_window_exceeded": {"readonly": True}, + "excluded_patch_count": {"readonly": True}, + "not_selected_patch_count": {"readonly": True}, + "pending_patch_count": {"readonly": True}, + "installed_patch_count": {"readonly": True}, + "failed_patch_count": {"readonly": True}, + "start_date_time": {"readonly": True}, + "last_modified_date_time": {"readonly": True}, + "started_by": {"readonly": True}, + "patch_service_used": {"readonly": True}, + "os_type": {"readonly": True}, + "error_details": {"readonly": True}, + } + + _attribute_map = { + "status": {"key": "status", "type": "str"}, + "installation_activity_id": {"key": "installationActivityId", "type": "str"}, + "reboot_status": {"key": "rebootStatus", "type": "str"}, + "maintenance_window_exceeded": {"key": "maintenanceWindowExceeded", "type": "bool"}, + "excluded_patch_count": {"key": "excludedPatchCount", "type": "int"}, + "not_selected_patch_count": {"key": "notSelectedPatchCount", "type": "int"}, + "pending_patch_count": {"key": "pendingPatchCount", "type": "int"}, + "installed_patch_count": {"key": "installedPatchCount", "type": "int"}, + "failed_patch_count": {"key": "failedPatchCount", "type": "int"}, + "start_date_time": {"key": "startDateTime", "type": "iso-8601"}, + "last_modified_date_time": {"key": "lastModifiedDateTime", "type": "iso-8601"}, + "started_by": {"key": "startedBy", "type": "str"}, + "patch_service_used": {"key": "patchServiceUsed", "type": "str"}, + "os_type": {"key": "osType", "type": "str"}, + "error_details": {"key": "errorDetails", "type": "ErrorDetail"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.status = None + self.installation_activity_id = None + self.reboot_status = None + self.maintenance_window_exceeded = None + self.excluded_patch_count = None + self.not_selected_patch_count = None + self.pending_patch_count = None + self.installed_patch_count = None + self.failed_patch_count = None + self.start_date_time = None + self.last_modified_date_time = None + self.started_by = None + self.patch_service_used = None + self.os_type = None + self.error_details = None + + +class VirtualMachineInventoryItem(InventoryItemProperties): # pylint: disable=too-many-instance-attributes """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 + :ivar inventory_type: They inventory type. Required. Known values are: "ResourcePool", + "VirtualMachine", "VirtualMachineTemplate", "VirtualNetwork", "Cluster", "Datastore", and + "Host". + :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. Known values are: "Windows", "Linux", and "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 @@ -3174,32 +4216,32 @@ class VirtualMachineInventoryItem(InventoryItemProperties): """ _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'}, + "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__( @@ -3208,18 +4250,45 @@ def __init__( managed_resource_id: Optional[str] = None, mo_ref_id: Optional[str] = None, mo_name: Optional[str] = None, - os_type: Optional[Union[str, "OsType"]] = None, + os_type: Optional[Union[str, "_models.OsType"]] = None, os_name: Optional[str] = None, ip_addresses: Optional[List[str]] = None, folder_path: Optional[str] = None, - host: Optional["InventoryItemDetails"] = None, - resource_pool: Optional["InventoryItemDetails"] = None, + host: Optional["_models.InventoryItemDetails"] = None, + resource_pool: Optional["_models.InventoryItemDetails"] = None, instance_uuid: Optional[str] = None, smbios_uuid: Optional[str] = None, **kwargs ): - 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 + """ + :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. Known values are: "Windows", "Linux", and + "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().__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 self.os_name = os_name self.ip_addresses = ip_addresses @@ -3234,74 +4303,74 @@ def __init__( self.tools_version = None -class VirtualMachinesList(msrest.serialization.Model): +class VirtualMachinesList(_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] + :ivar next_link: Url to follow for getting next page of VirtualMachines. + :vartype next_link: str + :ivar value: Array of VirtualMachines. Required. + :vartype value: list[~azure.mgmt.connectedvmware.models.VirtualMachine] """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[VirtualMachine]'}, + "next_link": {"key": "nextLink", "type": "str"}, + "value": {"key": "value", "type": "[VirtualMachine]"}, } - def __init__( - self, - *, - value: List["VirtualMachine"], - next_link: Optional[str] = None, - **kwargs - ): - super(VirtualMachinesList, self).__init__(**kwargs) + def __init__(self, *, value: List["_models.VirtualMachine"], next_link: Optional[str] = None, **kwargs): + """ + :keyword next_link: Url to follow for getting next page of VirtualMachines. + :paramtype next_link: str + :keyword value: Array of VirtualMachines. Required. + :paramtype value: list[~azure.mgmt.connectedvmware.models.VirtualMachine] + """ + super().__init__(**kwargs) self.next_link = next_link self.value = value -class VirtualMachineTemplate(msrest.serialization.Model): +class VirtualMachineTemplate(_serialization.Model): # pylint: disable=too-many-instance-attributes """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 location: Gets or sets the location. Required. + :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: 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. @@ -3311,7 +4380,7 @@ class VirtualMachineTemplate(msrest.serialization.Model): :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", + :ivar os_type: Gets or sets the type of the os. Known values are: "Windows", "Linux", and "Other". :vartype os_type: str or ~azure.mgmt.connectedvmware.models.OsType :ivar os_name: Gets or sets os name. @@ -3329,7 +4398,7 @@ class VirtualMachineTemplate(msrest.serialization.Model): :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". + :ivar firmware_type: Firmware type. Known values are: "bios" and "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] @@ -3338,64 +4407,64 @@ class VirtualMachineTemplate(msrest.serialization.Model): """ _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'}, + "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}, } - def __init__( + _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__( # pylint: disable=too-many-locals self, *, location: str, - extended_location: Optional["ExtendedLocation"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, tags: Optional[Dict[str, str]] = None, kind: Optional[str] = None, v_center_id: Optional[str] = None, @@ -3403,7 +4472,29 @@ def __init__( inventory_item_id: Optional[str] = None, **kwargs ): - super(VirtualMachineTemplate, self).__init__(**kwargs) + """ + :keyword location: Gets or sets the location. Required. + :paramtype location: str + :keyword extended_location: Gets or sets the extended location. + :paramtype extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation + :keyword 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().__init__(**kwargs) self.location = location self.extended_location = extended_location self.system_data = None @@ -3433,59 +4524,59 @@ def __init__( self.provisioning_state = None -class VirtualMachineTemplateInventoryItem(InventoryItemProperties): +class VirtualMachineTemplateInventoryItem(InventoryItemProperties): # pylint: disable=too-many-instance-attributes """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 + :ivar inventory_type: They inventory type. Required. Known values are: "ResourcePool", + "VirtualMachine", "VirtualMachineTemplate", "VirtualNetwork", "Cluster", "Datastore", and + "Host". + :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. Known values are: "Windows", "Linux", and "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 = { - 'inventory_type': {'required': True}, - 'provisioning_state': {'readonly': True}, + "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'}, + "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__( @@ -3497,13 +4588,37 @@ def __init__( memory_size_mb: Optional[int] = None, num_cp_us: Optional[int] = None, num_cores_per_socket: Optional[int] = None, - os_type: Optional[Union[str, "OsType"]] = None, + os_type: Optional[Union[str, "_models.OsType"]] = None, os_name: Optional[str] = None, folder_path: Optional[str] = None, **kwargs ): - 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 + """ + :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. Known values are: "Windows", "Linux", and + "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().__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 self.num_cp_us = num_cp_us self.num_cores_per_socket = num_cores_per_socket @@ -3512,114 +4627,133 @@ def __init__( self.folder_path = folder_path -class VirtualMachineTemplatesList(msrest.serialization.Model): +class VirtualMachineTemplatesList(_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] + :ivar next_link: Url to follow for getting next page of VirtualMachineTemplates. + :vartype next_link: str + :ivar value: Array of VirtualMachineTemplates. Required. + :vartype value: list[~azure.mgmt.connectedvmware.models.VirtualMachineTemplate] """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[VirtualMachineTemplate]'}, + "next_link": {"key": "nextLink", "type": "str"}, + "value": {"key": "value", "type": "[VirtualMachineTemplate]"}, } - def __init__( - self, - *, - value: List["VirtualMachineTemplate"], - next_link: Optional[str] = None, - **kwargs - ): - super(VirtualMachineTemplatesList, self).__init__(**kwargs) + def __init__(self, *, value: List["_models.VirtualMachineTemplate"], next_link: Optional[str] = None, **kwargs): + """ + :keyword next_link: Url to follow for getting next page of VirtualMachineTemplates. + :paramtype next_link: str + :keyword value: Array of VirtualMachineTemplates. Required. + :paramtype value: list[~azure.mgmt.connectedvmware.models.VirtualMachineTemplate] + """ + super().__init__(**kwargs) self.next_link = next_link self.value = value -class VirtualMachineUpdate(msrest.serialization.Model): +class VirtualMachineUpdate(_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: 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 os_profile: OS properties. + :vartype os_profile: ~azure.mgmt.connectedvmware.models.OsProfileUpdate + :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 = { - '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'}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "Identity"}, + "hardware_profile": {"key": "properties.hardwareProfile", "type": "HardwareProfile"}, + "os_profile": {"key": "properties.osProfile", "type": "OsProfileUpdate"}, + "storage_profile": {"key": "properties.storageProfile", "type": "StorageProfileUpdate"}, + "network_profile": {"key": "properties.networkProfile", "type": "NetworkProfileUpdate"}, } def __init__( self, *, tags: Optional[Dict[str, str]] = None, - identity: Optional["Identity"] = None, - hardware_profile: Optional["HardwareProfile"] = None, - storage_profile: Optional["StorageProfileUpdate"] = None, - network_profile: Optional["NetworkProfileUpdate"] = None, + identity: Optional["_models.Identity"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + os_profile: Optional["_models.OsProfileUpdate"] = None, + storage_profile: Optional["_models.StorageProfileUpdate"] = None, + network_profile: Optional["_models.NetworkProfileUpdate"] = None, **kwargs ): - super(VirtualMachineUpdate, self).__init__(**kwargs) + """ + :keyword 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 os_profile: OS properties. + :paramtype os_profile: ~azure.mgmt.connectedvmware.models.OsProfileUpdate + :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().__init__(**kwargs) self.tags = tags self.identity = identity self.hardware_profile = hardware_profile + self.os_profile = os_profile self.storage_profile = storage_profile self.network_profile = network_profile -class VirtualNetwork(msrest.serialization.Model): +class VirtualNetwork(_serialization.Model): # pylint: disable=too-many-instance-attributes """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 location: Gets or sets the location. Required. + :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: 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. @@ -3631,42 +4765,42 @@ class VirtualNetwork(msrest.serialization.Model): """ _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'}, + "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, *, location: str, - extended_location: Optional["ExtendedLocation"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, tags: Optional[Dict[str, str]] = None, kind: Optional[str] = None, v_center_id: Optional[str] = None, @@ -3674,7 +4808,27 @@ def __init__( inventory_item_id: Optional[str] = None, **kwargs ): - super(VirtualNetwork, self).__init__(**kwargs) + """ + :keyword location: Gets or sets the location. Required. + :paramtype location: str + :keyword extended_location: Gets or sets the extended location. + :paramtype extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation + :keyword 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().__init__(**kwargs) self.location = location self.extended_location = extended_location self.system_data = None @@ -3700,32 +4854,32 @@ 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", - "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 + :ivar inventory_type: They inventory type. Required. Known values are: "ResourcePool", + "VirtualMachine", "VirtualMachineTemplate", "VirtualNetwork", "Cluster", "Datastore", and + "Host". + :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 """ _validation = { - 'inventory_type': {'required': True}, - 'provisioning_state': {'readonly': True}, + "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'}, + "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__( @@ -3736,80 +4890,165 @@ def __init__( mo_name: Optional[str] = None, **kwargs ): - 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 - - -class VirtualNetworksList(msrest.serialization.Model): + """ + :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().__init__(managed_resource_id=managed_resource_id, mo_ref_id=mo_ref_id, mo_name=mo_name, **kwargs) + self.inventory_type = "VirtualNetwork" # type: str + + +class VirtualNetworksList(_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] + :ivar next_link: Url to follow for getting next page of VirtualNetworks. + :vartype next_link: str + :ivar value: Array of VirtualNetworks. Required. + :vartype value: list[~azure.mgmt.connectedvmware.models.VirtualNetwork] """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[VirtualNetwork]'}, + "next_link": {"key": "nextLink", "type": "str"}, + "value": {"key": "value", "type": "[VirtualNetwork]"}, } - def __init__( - self, - *, - value: List["VirtualNetwork"], - next_link: Optional[str] = None, - **kwargs - ): - super(VirtualNetworksList, self).__init__(**kwargs) + def __init__(self, *, value: List["_models.VirtualNetwork"], next_link: Optional[str] = None, **kwargs): + """ + :keyword next_link: Url to follow for getting next page of VirtualNetworks. + :paramtype next_link: str + :keyword value: Array of VirtualNetworks. Required. + :paramtype value: list[~azure.mgmt.connectedvmware.models.VirtualNetwork] + """ + super().__init__(**kwargs) self.next_link = next_link self.value = value -class VirtualSCSIController(msrest.serialization.Model): +class VirtualSCSIController(_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 + :ivar type: Gets or sets the controller type. Known values are: "lsilogic", "buslogic", + "pvscsi", and "lsilogicsas". + :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. Known values are: "noSharing", "physicalSharing", + and "virtualSharing". + :vartype 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'}, + "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, *, - type: Optional[Union[str, "SCSIControllerType"]] = None, + type: Optional[Union[str, "_models.SCSIControllerType"]] = None, controller_key: Optional[int] = None, bus_number: Optional[int] = None, scsi_ctlr_unit_number: Optional[int] = None, - sharing: Optional[Union[str, "VirtualSCSISharing"]] = None, + sharing: Optional[Union[str, "_models.VirtualSCSISharing"]] = None, **kwargs ): - super(VirtualSCSIController, self).__init__(**kwargs) + """ + :keyword type: Gets or sets the controller type. Known values are: "lsilogic", "buslogic", + "pvscsi", and "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. Known values are: "noSharing", + "physicalSharing", and "virtualSharing". + :paramtype sharing: str or ~azure.mgmt.connectedvmware.models.VirtualSCSISharing + """ + super().__init__(**kwargs) self.type = type self.controller_key = controller_key self.bus_number = bus_number self.scsi_ctlr_unit_number = scsi_ctlr_unit_number self.sharing = sharing + + +class WindowsParameters(_serialization.Model): + """Input for InstallPatches on a Windows VM, as directly received by the API. + + :ivar classifications_to_include: The update classifications to select when installing patches + for Windows. + :vartype classifications_to_include: list[str or + ~azure.mgmt.connectedvmware.models.VMGuestPatchClassificationWindows] + :ivar kb_numbers_to_include: Kbs to include in the patch operation. + :vartype kb_numbers_to_include: list[str] + :ivar kb_numbers_to_exclude: Kbs to exclude in the patch operation. + :vartype kb_numbers_to_exclude: list[str] + :ivar exclude_kbs_requiring_reboot: Filters out Kbs that don't have an + InstallationRebootBehavior of 'NeverReboots' when this is set to true. + :vartype exclude_kbs_requiring_reboot: bool + :ivar max_patch_publish_date: This is used to install patches that were published on or before + this given max published date. + :vartype max_patch_publish_date: ~datetime.datetime + """ + + _attribute_map = { + "classifications_to_include": {"key": "classificationsToInclude", "type": "[str]"}, + "kb_numbers_to_include": {"key": "kbNumbersToInclude", "type": "[str]"}, + "kb_numbers_to_exclude": {"key": "kbNumbersToExclude", "type": "[str]"}, + "exclude_kbs_requiring_reboot": {"key": "excludeKbsRequiringReboot", "type": "bool"}, + "max_patch_publish_date": {"key": "maxPatchPublishDate", "type": "iso-8601"}, + } + + def __init__( + self, + *, + classifications_to_include: Optional[List[Union[str, "_models.VMGuestPatchClassificationWindows"]]] = None, + kb_numbers_to_include: Optional[List[str]] = None, + kb_numbers_to_exclude: Optional[List[str]] = None, + exclude_kbs_requiring_reboot: Optional[bool] = None, + max_patch_publish_date: Optional[datetime.datetime] = None, + **kwargs + ): + """ + :keyword classifications_to_include: The update classifications to select when installing + patches for Windows. + :paramtype classifications_to_include: list[str or + ~azure.mgmt.connectedvmware.models.VMGuestPatchClassificationWindows] + :keyword kb_numbers_to_include: Kbs to include in the patch operation. + :paramtype kb_numbers_to_include: list[str] + :keyword kb_numbers_to_exclude: Kbs to exclude in the patch operation. + :paramtype kb_numbers_to_exclude: list[str] + :keyword exclude_kbs_requiring_reboot: Filters out Kbs that don't have an + InstallationRebootBehavior of 'NeverReboots' when this is set to true. + :paramtype exclude_kbs_requiring_reboot: bool + :keyword max_patch_publish_date: This is used to install patches that were published on or + before this given max published date. + :paramtype max_patch_publish_date: ~datetime.datetime + """ + super().__init__(**kwargs) + self.classifications_to_include = classifications_to_include + self.kb_numbers_to_include = kb_numbers_to_include + self.kb_numbers_to_exclude = kb_numbers_to_exclude + self.exclude_kbs_requiring_reboot = exclude_kbs_requiring_reboot + self.max_patch_publish_date = max_patch_publish_date diff --git a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/models/_patch.py b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/__init__.py b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/__init__.py index de63ef86d5dd..f3aa61c6c8b8 100644 --- a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/__init__.py +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/__init__.py @@ -7,12 +7,12 @@ # -------------------------------------------------------------------------- from ._operations import Operations +from ._virtual_machines_operations import VirtualMachinesOperations from ._resource_pools_operations import ResourcePoolsOperations from ._clusters_operations import ClustersOperations from ._hosts_operations import HostsOperations from ._datastores_operations import DatastoresOperations from ._vcenters_operations import VCentersOperations -from ._virtual_machines_operations import VirtualMachinesOperations from ._virtual_machine_templates_operations import VirtualMachineTemplatesOperations from ._virtual_networks_operations import VirtualNetworksOperations from ._inventory_items_operations import InventoryItemsOperations @@ -20,18 +20,24 @@ from ._machine_extensions_operations import MachineExtensionsOperations from ._guest_agents_operations import GuestAgentsOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'ResourcePoolsOperations', - 'ClustersOperations', - 'HostsOperations', - 'DatastoresOperations', - 'VCentersOperations', - 'VirtualMachinesOperations', - 'VirtualMachineTemplatesOperations', - 'VirtualNetworksOperations', - 'InventoryItemsOperations', - 'HybridIdentityMetadataOperations', - 'MachineExtensionsOperations', - 'GuestAgentsOperations', + "Operations", + "VirtualMachinesOperations", + "ResourcePoolsOperations", + "ClustersOperations", + "HostsOperations", + "DatastoresOperations", + "VCentersOperations", + "VirtualMachineTemplatesOperations", + "VirtualNetworksOperations", + "InventoryItemsOperations", + "HybridIdentityMetadataOperations", + "MachineExtensionsOperations", + "GuestAgentsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() 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..22e3fa1dd1b3 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,486 +6,812 @@ # 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 warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_create_request( + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters/{clusterName}", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters/{clusterName}", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters/{clusterName}", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, cluster_name: str, subscription_id: str, *, force: Optional[bool] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters/{clusterName}", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if force is not None: + _params["force"] = _SERIALIZER.query("force", force, "bool") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + accept = _headers.pop("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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + accept = _headers.pop("Accept", "application/json") -class ClustersOperations(object): - """ClustersOperations operations. + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + _url = _format_url_section(_url, **path_format_arguments) - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.connectedvmware.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ClustersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.connectedvmware.AzureArcVMwareManagementServiceAPI`'s + :attr:`clusters` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("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" - 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') - - # 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') + resource_group_name: str, + cluster_name: str, + body: Optional[Union[_models.Cluster, IO]] = None, + **kwargs: Any + ) -> _models.Cluster: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Cluster] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - body_content = None - 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) + if body is not None: + _json = self._serialize.body(body, "Cluster") + else: + _json = None + + request = build_create_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Cluster', pipeline_response) + deserialized = self._deserialize("Cluster", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Cluster', pipeline_response) + deserialized = self._deserialize("Cluster", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters/{clusterName}'} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters/{clusterName}"} # type: ignore + + @overload 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, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Cluster]: """Implements cluster PUT method. Create Or Update cluster. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param cluster_name: Name of the cluster. + :param cluster_name: Name of the cluster. Required. :type cluster_name: str - :param body: Request payload. + :param body: Request payload. Default value is None. :type body: ~azure.mgmt.connectedvmware.models.Cluster + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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 Cluster or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.connectedvmware.models.Cluster] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Cluster"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create( + self, + resource_group_name: str, + cluster_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Cluster]: + """Implements cluster PUT method. + + Create Or Update cluster. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param cluster_name: Name of the cluster. Required. + :type cluster_name: str + :param body: Request payload. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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 Cluster or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.connectedvmware.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + cluster_name: str, + body: Optional[Union[_models.Cluster, IO]] = None, + **kwargs: Any + ) -> LROPoller[_models.Cluster]: + """Implements cluster PUT method. + + Create Or Update cluster. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param cluster_name: Name of the cluster. Required. + :type cluster_name: str + :param body: Request payload. Is either a model type or a IO type. Default value is None. + :type body: ~azure.mgmt.connectedvmware.models.Cluster or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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 Cluster or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.connectedvmware.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Cluster] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_initial( + raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, body=body, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Cluster', pipeline_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) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - 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 + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def get( - self, - resource_group_name, # type: str - cluster_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Cluster" + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters/{clusterName}"} # type: ignore + + @distributed_trace + def get(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> _models.Cluster: """Gets a cluster. Implements cluster GET method. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param cluster_name: Name of the cluster. + :param cluster_name: Name of the cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Cluster, or the result of cls(response) + :return: Cluster or the result of cls(response) :rtype: ~azure.mgmt.connectedvmware.models.Cluster - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - 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" - 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 = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Cluster] + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + deserialized = self._deserialize("Cluster", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters/{clusterName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters/{clusterName}"} # type: ignore + + @overload 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, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Cluster: """Updates a cluster. API to update certain properties of the cluster resource. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param cluster_name: Name of the cluster. + :param cluster_name: Name of the cluster. Required. :type cluster_name: str - :param body: Resource properties to update. + :param body: Resource properties to update. Default value is None. :type body: ~azure.mgmt.connectedvmware.models.ResourcePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Cluster or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.Cluster + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + cluster_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Cluster: + """Updates a cluster. + + API to update certain properties of the cluster resource. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param cluster_name: Name of the cluster. Required. + :type cluster_name: str + :param body: Resource properties to update. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Cluster or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.Cluster + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + cluster_name: str, + body: Optional[Union[_models.ResourcePatch, IO]] = None, + **kwargs: Any + ) -> _models.Cluster: + """Updates a cluster. + + API to update certain properties of the cluster resource. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param cluster_name: Name of the cluster. Required. + :type cluster_name: str + :param body: Resource properties to update. Is either a model type or a IO type. Default value + is None. + :type body: ~azure.mgmt.connectedvmware.models.ResourcePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Cluster, or the result of cls(response) + :return: Cluster or the result of cls(response) :rtype: ~azure.mgmt.connectedvmware.models.Cluster - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - 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.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') - - body_content_kwargs = {} # type: Dict[str, Any] - if body is not None: - body_content = self._serialize.body(body, 'ResourcePatch') + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Cluster] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - body_content = None - 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) + if body is not None: + _json = self._serialize.body(body, "ResourcePatch") + else: + _json = None + + request = build_update_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + deserialized = self._deserialize("Cluster", pipeline_response) if cls: 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 - 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 = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters/{clusterName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, cluster_name: str, force: Optional[bool] = None, **kwargs: Any + ) -> None: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + force=force, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters/{clusterName}'} # type: ignore + _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] + self, resource_group_name: str, cluster_name: str, force: Optional[bool] = None, **kwargs: Any + ) -> LROPoller[None]: """Deletes an cluster. Implements cluster DELETE method. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param cluster_name: Name of the cluster. + :param cluster_name: Name of the cluster. Required. :type cluster_name: str - :param force: Whether force delete was specified. + :param force: Whether force delete was specified. Default value is None. :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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, force=force, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements 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) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - 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 + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def list( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ClustersList"] + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters/{clusterName}"} # type: ignore + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.Cluster"]: """Implements GET clusters in a subscription. List of clusters 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 ClustersList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.connectedvmware.models.ClustersList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Cluster or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.connectedvmware.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClustersList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ClustersList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): 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, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -493,72 +820,71 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) 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 + return ItemPaged(get_next, extract_data) - def list_by_resource_group( - self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ClustersList"] + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/clusters"} # type: ignore + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Cluster"]: """Implements GET clusters in a resource group. List of clusters in a resource group. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :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.paging.ItemPaged[~azure.mgmt.connectedvmware.models.ClustersList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Cluster or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.connectedvmware.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClustersList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ClustersList] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): 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( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -567,17 +893,18 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters'} # type: ignore + return ItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters"} # type: ignore 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..3c461fe76714 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,486 +6,814 @@ # 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 warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_create_request( + resource_group_name: str, datastore_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores/{datastoreName}", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, datastore_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores/{datastoreName}", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, datastore_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores/{datastoreName}", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, datastore_name: str, subscription_id: str, *, force: Optional[bool] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores/{datastoreName}", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if force is not None: + _params["force"] = _SERIALIZER.query("force", force, "bool") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/datastores" + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + accept = _headers.pop("Accept", "application/json") -class DatastoresOperations(object): - """DatastoresOperations operations. + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + _url = _format_url_section(_url, **path_format_arguments) - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.connectedvmware.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class DatastoresOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.connectedvmware.AzureArcVMwareManagementServiceAPI`'s + :attr:`datastores` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("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" - 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') - - # 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') + resource_group_name: str, + datastore_name: str, + body: Optional[Union[_models.Datastore, IO]] = None, + **kwargs: Any + ) -> _models.Datastore: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Datastore] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - body_content = None - 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) + if body is not None: + _json = self._serialize.body(body, "Datastore") + else: + _json = None + + request = build_create_request( + resource_group_name=resource_group_name, + datastore_name=datastore_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Datastore', pipeline_response) + deserialized = self._deserialize("Datastore", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Datastore', pipeline_response) + deserialized = self._deserialize("Datastore", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores/{datastoreName}'} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores/{datastoreName}"} # type: ignore + + @overload 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, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Datastore]: """Implements datastore PUT method. Create Or Update datastore. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param datastore_name: Name of the datastore. + :param datastore_name: Name of the datastore. Required. :type datastore_name: str - :param body: Request payload. + :param body: Request payload. Default value is None. :type body: ~azure.mgmt.connectedvmware.models.Datastore + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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 Datastore or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.connectedvmware.models.Datastore] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Datastore"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create( + self, + resource_group_name: str, + datastore_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Datastore]: + """Implements datastore PUT method. + + Create Or Update datastore. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param datastore_name: Name of the datastore. Required. + :type datastore_name: str + :param body: Request payload. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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 Datastore or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.connectedvmware.models.Datastore] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + datastore_name: str, + body: Optional[Union[_models.Datastore, IO]] = None, + **kwargs: Any + ) -> LROPoller[_models.Datastore]: + """Implements datastore PUT method. + + Create Or Update datastore. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param datastore_name: Name of the datastore. Required. + :type datastore_name: str + :param body: Request payload. Is either a model type or a IO type. Default value is None. + :type body: ~azure.mgmt.connectedvmware.models.Datastore or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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 Datastore or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.connectedvmware.models.Datastore] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Datastore] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_initial( + raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, datastore_name=datastore_name, body=body, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Datastore', pipeline_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) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - 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 + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def get( - self, - resource_group_name, # type: str - datastore_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Datastore" + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores/{datastoreName}"} # type: ignore + + @distributed_trace + def get(self, resource_group_name: str, datastore_name: str, **kwargs: Any) -> _models.Datastore: """Gets a datastore. Implements datastore GET method. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param datastore_name: Name of the datastore. + :param datastore_name: Name of the datastore. Required. :type datastore_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Datastore, or the result of cls(response) + :return: Datastore or the result of cls(response) :rtype: ~azure.mgmt.connectedvmware.models.Datastore - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - 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" - 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 = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Datastore] + + request = build_get_request( + resource_group_name=resource_group_name, + datastore_name=datastore_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + deserialized = self._deserialize("Datastore", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores/{datastoreName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores/{datastoreName}"} # type: ignore + + @overload 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, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Datastore: """Updates a datastore. API to update certain properties of the datastore resource. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param datastore_name: Name of the datastore. + :param datastore_name: Name of the datastore. Required. :type datastore_name: str - :param body: Resource properties to update. + :param body: Resource properties to update. Default value is None. :type body: ~azure.mgmt.connectedvmware.models.ResourcePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Datastore or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.Datastore + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + datastore_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Datastore: + """Updates a datastore. + + API to update certain properties of the datastore resource. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param datastore_name: Name of the datastore. Required. + :type datastore_name: str + :param body: Resource properties to update. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Datastore or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.Datastore + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + datastore_name: str, + body: Optional[Union[_models.ResourcePatch, IO]] = None, + **kwargs: Any + ) -> _models.Datastore: + """Updates a datastore. + + API to update certain properties of the datastore resource. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param datastore_name: Name of the datastore. Required. + :type datastore_name: str + :param body: Resource properties to update. Is either a model type or a IO type. Default value + is None. + :type body: ~azure.mgmt.connectedvmware.models.ResourcePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Datastore, or the result of cls(response) + :return: Datastore or the result of cls(response) :rtype: ~azure.mgmt.connectedvmware.models.Datastore - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - 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.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') - - body_content_kwargs = {} # type: Dict[str, Any] - if body is not None: - body_content = self._serialize.body(body, 'ResourcePatch') + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Datastore] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - body_content = None - 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) + if body is not None: + _json = self._serialize.body(body, "ResourcePatch") + else: + _json = None + + request = build_update_request( + resource_group_name=resource_group_name, + datastore_name=datastore_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + deserialized = self._deserialize("Datastore", pipeline_response) if cls: 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 - 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 = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores/{datastoreName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, datastore_name: str, force: Optional[bool] = None, **kwargs: Any + ) -> None: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + datastore_name=datastore_name, + subscription_id=self._config.subscription_id, + force=force, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores/{datastoreName}'} # type: ignore + _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] + self, resource_group_name: str, datastore_name: str, force: Optional[bool] = None, **kwargs: Any + ) -> LROPoller[None]: """Deletes an datastore. Implements datastore DELETE method. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param datastore_name: Name of the datastore. + :param datastore_name: Name of the datastore. Required. :type datastore_name: str - :param force: Whether force delete was specified. + :param force: Whether force delete was specified. Default value is None. :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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, datastore_name=datastore_name, force=force, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements 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) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - 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 + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def list( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DatastoresList"] + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores/{datastoreName}"} # type: ignore + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.Datastore"]: """Implements GET datastores in a subscription. List of datastores 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 DatastoresList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.connectedvmware.models.DatastoresList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Datastore or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.connectedvmware.models.Datastore] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DatastoresList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DatastoresList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): 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, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -493,72 +822,71 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) 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 + return ItemPaged(get_next, extract_data) - def list_by_resource_group( - self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DatastoresList"] + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/datastores"} # type: ignore + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Datastore"]: """Implements GET datastores in a resource group. List of datastores in a resource group. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :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.paging.ItemPaged[~azure.mgmt.connectedvmware.models.DatastoresList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Datastore or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.connectedvmware.models.Datastore] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DatastoresList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DatastoresList] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): 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( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -567,17 +895,18 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores'} # type: ignore + return ItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores"} # type: ignore 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..ee39cbbd5c64 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,432 +6,640 @@ # 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 warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_create_request( + resource_group_name: str, virtual_machine_name: str, name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/guestAgents/{name}", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, virtual_machine_name: str, name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/guestAgents/{name}", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, virtual_machine_name: str, name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/guestAgents/{name}", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_vm_request( + resource_group_name: str, virtual_machine_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/guestAgents", + ) # pylint: disable=line-too-long + 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"), + } -class GuestAgentsOperations(object): - """GuestAgentsOperations operations. + _url = _format_url_section(_url, **path_format_arguments) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.connectedvmware.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class GuestAgentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.connectedvmware.AzureArcVMwareManagementServiceAPI`'s + :attr:`guest_agents` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("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" - 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') - - # 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') + resource_group_name: str, + virtual_machine_name: str, + name: str, + body: Optional[Union[_models.GuestAgent, IO]] = None, + **kwargs: Any + ) -> _models.GuestAgent: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GuestAgent] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - body_content = None - 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) + if body is not None: + _json = self._serialize.body(body, "GuestAgent") + else: + _json = None + + request = build_create_request( + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('GuestAgent', pipeline_response) + deserialized = self._deserialize("GuestAgent", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GuestAgent', pipeline_response) + deserialized = self._deserialize("GuestAgent", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/guestAgents/{name}'} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/guestAgents/{name}"} # type: ignore + + @overload 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, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GuestAgent]: """Implements GuestAgent PUT method. Create Or Update GuestAgent. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param virtual_machine_name: Name of the vm. + :param virtual_machine_name: Name of the vm. Required. :type virtual_machine_name: str - :param name: Name of the guestAgents. + :param name: Name of the guestAgents. Required. :type name: str - :param body: Request payload. + :param body: Request payload. Default value is None. :type body: ~azure.mgmt.connectedvmware.models.GuestAgent + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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 GuestAgent or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.connectedvmware.models.GuestAgent] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestAgent"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create( + self, + resource_group_name: str, + virtual_machine_name: str, + name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GuestAgent]: + """Implements GuestAgent PUT method. + + Create Or Update GuestAgent. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param virtual_machine_name: Name of the vm. Required. + :type virtual_machine_name: str + :param name: Name of the guestAgents. Required. + :type name: str + :param body: Request payload. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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 GuestAgent or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.connectedvmware.models.GuestAgent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + virtual_machine_name: str, + name: str, + body: Optional[Union[_models.GuestAgent, IO]] = None, + **kwargs: Any + ) -> LROPoller[_models.GuestAgent]: + """Implements GuestAgent PUT method. + + Create Or Update GuestAgent. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param virtual_machine_name: Name of the vm. Required. + :type virtual_machine_name: str + :param name: Name of the guestAgents. Required. + :type name: str + :param body: Request payload. Is either a model type or a IO type. Default value is None. + :type body: ~azure.mgmt.connectedvmware.models.GuestAgent or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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 GuestAgent or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.connectedvmware.models.GuestAgent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GuestAgent] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_initial( + raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, virtual_machine_name=virtual_machine_name, name=name, body=body, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('GuestAgent', pipeline_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) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - 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 + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def get( - self, - resource_group_name, # type: str - virtual_machine_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.GuestAgent" + 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: str, virtual_machine_name: str, name: str, **kwargs: Any) -> _models.GuestAgent: """Gets GuestAgent. Implements GuestAgent GET method. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param virtual_machine_name: Name of the vm. + :param virtual_machine_name: Name of the vm. Required. :type virtual_machine_name: str - :param name: Name of the GuestAgent. + :param name: Name of the GuestAgent. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GuestAgent, or the result of cls(response) + :return: GuestAgent or the result of cls(response) :rtype: ~azure.mgmt.connectedvmware.models.GuestAgent - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - 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" - 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 = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GuestAgent] + + request = build_get_request( + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + deserialized = self._deserialize("GuestAgent", pipeline_response) if cls: 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 - 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 = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/guestAgents/{name}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, virtual_machine_name: str, name: str, **kwargs: Any + ) -> None: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/guestAgents/{name}'} # type: ignore + _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] + self, resource_group_name: str, virtual_machine_name: str, name: str, **kwargs: Any + ) -> LROPoller[None]: """Deletes an GuestAgent. Implements GuestAgent DELETE method. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param virtual_machine_name: Name of the vm. + :param virtual_machine_name: Name of the vm. Required. :type virtual_machine_name: str - :param name: Name of the GuestAgent. + :param name: Name of the GuestAgent. Required. :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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, virtual_machine_name=virtual_machine_name, name=name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements 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) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - 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 + 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"] + self, resource_group_name: str, virtual_machine_name: str, **kwargs: Any + ) -> Iterable["_models.GuestAgent"]: """Implements GET GuestAgent in a vm. Returns the list of GuestAgent of the given vm. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param virtual_machine_name: Name of the vm. + :param virtual_machine_name: Name of the vm. Required. :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.paging.ItemPaged[~azure.mgmt.connectedvmware.models.GuestAgentList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either GuestAgent or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.connectedvmware.models.GuestAgent] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestAgentList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.GuestAgentList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): 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( + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_vm.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -439,17 +648,18 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_vm.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/guestAgents'} # type: ignore + return ItemPaged(get_next, extract_data) + + list_by_vm.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/guestAgents"} # type: ignore 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..9c886748658b 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,486 +6,800 @@ # 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 warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_create_request(resource_group_name: str, host_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts/{hostName}", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(resource_group_name: str, host_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts/{hostName}", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request(resource_group_name: str, host_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts/{hostName}", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, host_name: str, subscription_id: str, *, force: Optional[bool] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts/{hostName}", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if force is not None: + _params["force"] = _SERIALIZER.query("force", force, "bool") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + accept = _headers.pop("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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -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]] +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) -class HostsOperations(object): - """HostsOperations operations. + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.connectedvmware.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class HostsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.connectedvmware.AzureArcVMwareManagementServiceAPI`'s + :attr:`hosts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("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" - 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') - - # 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') + self, resource_group_name: str, host_name: str, body: Optional[Union[_models.Host, IO]] = None, **kwargs: Any + ) -> _models.Host: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Host] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - body_content = None - 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) + if body is not None: + _json = self._serialize.body(body, "Host") + else: + _json = None + + request = build_create_request( + resource_group_name=resource_group_name, + host_name=host_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Host', pipeline_response) + deserialized = self._deserialize("Host", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Host', pipeline_response) + deserialized = self._deserialize("Host", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts/{hostName}'} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts/{hostName}"} # type: ignore + + @overload 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, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Host]: """Implements host PUT method. Create Or Update host. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param host_name: Name of the host. + :param host_name: Name of the host. Required. :type host_name: str - :param body: Request payload. + :param body: Request payload. Default value is None. :type body: ~azure.mgmt.connectedvmware.models.Host + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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 Host or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.connectedvmware.models.Host] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Host"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create( + self, + resource_group_name: str, + host_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Host]: + """Implements host PUT method. + + Create Or Update host. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param host_name: Name of the host. Required. + :type host_name: str + :param body: Request payload. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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 Host or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.connectedvmware.models.Host] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, resource_group_name: str, host_name: str, body: Optional[Union[_models.Host, IO]] = None, **kwargs: Any + ) -> LROPoller[_models.Host]: + """Implements host PUT method. + + Create Or Update host. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param host_name: Name of the host. Required. + :type host_name: str + :param body: Request payload. Is either a model type or a IO type. Default value is None. + :type body: ~azure.mgmt.connectedvmware.models.Host or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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 Host or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.connectedvmware.models.Host] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Host] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_initial( + raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, host_name=host_name, body=body, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Host', pipeline_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) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - 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 + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def get( - self, - resource_group_name, # type: str - host_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Host" + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts/{hostName}"} # type: ignore + + @distributed_trace + def get(self, resource_group_name: str, host_name: str, **kwargs: Any) -> _models.Host: """Gets a host. Implements host GET method. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param host_name: Name of the host. + :param host_name: Name of the host. Required. :type host_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Host, or the result of cls(response) + :return: Host or the result of cls(response) :rtype: ~azure.mgmt.connectedvmware.models.Host - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - 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" - 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 = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Host] + + request = build_get_request( + resource_group_name=resource_group_name, + host_name=host_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + deserialized = self._deserialize("Host", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts/{hostName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts/{hostName}"} # type: ignore + + @overload 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, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Host: """Updates a host. API to update certain properties of the host resource. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param host_name: Name of the host. + :param host_name: Name of the host. Required. :type host_name: str - :param body: Resource properties to update. + :param body: Resource properties to update. Default value is None. :type body: ~azure.mgmt.connectedvmware.models.ResourcePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Host, or the result of cls(response) + :return: Host or the result of cls(response) :rtype: ~azure.mgmt.connectedvmware.models.Host - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - 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.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') - - body_content_kwargs = {} # type: Dict[str, Any] - if body is not None: - body_content = self._serialize.body(body, 'ResourcePatch') + + @overload + def update( + self, + resource_group_name: str, + host_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Host: + """Updates a host. + + API to update certain properties of the host resource. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param host_name: Name of the host. Required. + :type host_name: str + :param body: Resource properties to update. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Host or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.Host + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + host_name: str, + body: Optional[Union[_models.ResourcePatch, IO]] = None, + **kwargs: Any + ) -> _models.Host: + """Updates a host. + + API to update certain properties of the host resource. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param host_name: Name of the host. Required. + :type host_name: str + :param body: Resource properties to update. Is either a model type or a IO type. Default value + is None. + :type body: ~azure.mgmt.connectedvmware.models.ResourcePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Host or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.Host + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Host] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - body_content = None - 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) + if body is not None: + _json = self._serialize.body(body, "ResourcePatch") + else: + _json = None + + request = build_update_request( + resource_group_name=resource_group_name, + host_name=host_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + deserialized = self._deserialize("Host", pipeline_response) if cls: 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 - 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 = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts/{hostName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, host_name: str, force: Optional[bool] = None, **kwargs: Any + ) -> None: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + host_name=host_name, + subscription_id=self._config.subscription_id, + force=force, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts/{hostName}'} # type: ignore + _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] + self, resource_group_name: str, host_name: str, force: Optional[bool] = None, **kwargs: Any + ) -> LROPoller[None]: """Deletes an host. Implements host DELETE method. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param host_name: Name of the host. + :param host_name: Name of the host. Required. :type host_name: str - :param force: Whether force delete was specified. + :param force: Whether force delete was specified. Default value is None. :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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, host_name=host_name, force=force, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements 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) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - 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 + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def list( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.HostsList"] + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts/{hostName}"} # type: ignore + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.Host"]: """Implements GET hosts in a subscription. List of hosts 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 HostsList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.connectedvmware.models.HostsList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Host or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.connectedvmware.models.Host] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.HostsList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.HostsList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): 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, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -493,72 +808,71 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) 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 + return ItemPaged(get_next, extract_data) - def list_by_resource_group( - self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.HostsList"] + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/hosts"} # type: ignore + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Host"]: """Implements GET hosts in a resource group. List of hosts in a resource group. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :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 HostsList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.connectedvmware.models.HostsList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Host or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.connectedvmware.models.Host] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.HostsList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.HostsList] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): 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( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -567,17 +881,18 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts'} # type: ignore + return ItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts"} # type: ignore 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..4a08345435a7 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,307 +6,507 @@ # 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 warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_create_request( + resource_group_name: str, virtual_machine_name: str, metadata_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/hybridIdentityMetadata/{metadataName}", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, virtual_machine_name: str, metadata_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/hybridIdentityMetadata/{metadataName}", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, virtual_machine_name: str, metadata_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/hybridIdentityMetadata/{metadataName}", + ) # pylint: disable=line-too-long + 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"), + } -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + _url = _format_url_section(_url, **path_format_arguments) - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") -class HybridIdentityMetadataOperations(object): - """HybridIdentityMetadataOperations operations. + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.connectedvmware.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + +def build_list_by_vm_request( + resource_group_name: str, virtual_machine_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/hybridIdentityMetadata", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class HybridIdentityMetadataOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.connectedvmware.AzureArcVMwareManagementServiceAPI`'s + :attr:`hybrid_identity_metadata` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @overload 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, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.HybridIdentityMetadata: """Implements HybridIdentityMetadata PUT method. Create Or Update HybridIdentityMetadata. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param virtual_machine_name: Name of the vm. + :param virtual_machine_name: Name of the vm. Required. :type virtual_machine_name: str - :param metadata_name: Name of the hybridIdentityMetadata. + :param metadata_name: Name of the hybridIdentityMetadata. Required. :type metadata_name: str - :param body: Request payload. + :param body: Request payload. Default value is None. :type body: ~azure.mgmt.connectedvmware.models.HybridIdentityMetadata + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: HybridIdentityMetadata, or the result of cls(response) + :return: HybridIdentityMetadata or the result of cls(response) :rtype: ~azure.mgmt.connectedvmware.models.HybridIdentityMetadata - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.HybridIdentityMetadata"] - 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.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') - - body_content_kwargs = {} # type: Dict[str, Any] - if body is not None: - body_content = self._serialize.body(body, 'HybridIdentityMetadata') + + @overload + def create( + self, + resource_group_name: str, + virtual_machine_name: str, + metadata_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.HybridIdentityMetadata: + """Implements HybridIdentityMetadata PUT method. + + Create Or Update HybridIdentityMetadata. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param virtual_machine_name: Name of the vm. Required. + :type virtual_machine_name: str + :param metadata_name: Name of the hybridIdentityMetadata. Required. + :type metadata_name: str + :param body: Request payload. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: HybridIdentityMetadata or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.HybridIdentityMetadata + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + virtual_machine_name: str, + metadata_name: str, + body: Optional[Union[_models.HybridIdentityMetadata, IO]] = None, + **kwargs: Any + ) -> _models.HybridIdentityMetadata: + """Implements HybridIdentityMetadata PUT method. + + Create Or Update HybridIdentityMetadata. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param virtual_machine_name: Name of the vm. Required. + :type virtual_machine_name: str + :param metadata_name: Name of the hybridIdentityMetadata. Required. + :type metadata_name: str + :param body: Request payload. Is either a model type or a IO type. Default value is None. + :type body: ~azure.mgmt.connectedvmware.models.HybridIdentityMetadata or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: HybridIdentityMetadata or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.HybridIdentityMetadata + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.HybridIdentityMetadata] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - body_content = None - 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) + if body is not None: + _json = self._serialize.body(body, "HybridIdentityMetadata") + else: + _json = None + + request = build_create_request( + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + metadata_name=metadata_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + deserialized = self._deserialize("HybridIdentityMetadata", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/hybridIdentityMetadata/{metadataName}'} # type: ignore + 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" + self, resource_group_name: str, virtual_machine_name: str, metadata_name: str, **kwargs: Any + ) -> _models.HybridIdentityMetadata: """Gets HybridIdentityMetadata. Implements HybridIdentityMetadata GET method. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param virtual_machine_name: Name of the vm. + :param virtual_machine_name: Name of the vm. Required. :type virtual_machine_name: str - :param metadata_name: Name of the HybridIdentityMetadata. + :param metadata_name: Name of the HybridIdentityMetadata. Required. :type metadata_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: HybridIdentityMetadata, or the result of cls(response) + :return: HybridIdentityMetadata or the result of cls(response) :rtype: ~azure.mgmt.connectedvmware.models.HybridIdentityMetadata - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.HybridIdentityMetadata"] - 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.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 = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.HybridIdentityMetadata] + + request = build_get_request( + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + metadata_name=metadata_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + deserialized = self._deserialize("HybridIdentityMetadata", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/hybridIdentityMetadata/{metadataName}'} # type: ignore - def delete( - self, - resource_group_name, # type: str - virtual_machine_name, # type: str - metadata_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/hybridIdentityMetadata/{metadataName}"} # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, virtual_machine_name: str, metadata_name: str, **kwargs: Any + ) -> None: """Deletes an HybridIdentityMetadata. Implements HybridIdentityMetadata DELETE method. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param virtual_machine_name: Name of the vm. + :param virtual_machine_name: Name of the vm. Required. :type virtual_machine_name: str - :param metadata_name: Name of the HybridIdentityMetadata. + :param metadata_name: Name of the HybridIdentityMetadata. Required. :type metadata_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - 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.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 = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + metadata_name=metadata_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/hybridIdentityMetadata/{metadataName}'} # type: ignore + 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"] + self, resource_group_name: str, virtual_machine_name: str, **kwargs: Any + ) -> Iterable["_models.HybridIdentityMetadata"]: """Implements GET HybridIdentityMetadata in a vm. Returns the list of HybridIdentityMetadata of the given vm. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param virtual_machine_name: Name of the vm. + :param virtual_machine_name: Name of the vm. Required. :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] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either HybridIdentityMetadata or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.connectedvmware.models.HybridIdentityMetadata] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.HybridIdentityMetadataList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.HybridIdentityMetadataList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): 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( + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_vm.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -314,17 +515,18 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_vm.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/hybridIdentityMetadata'} # type: ignore + return ItemPaged(get_next, extract_data) + + list_by_vm.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/hybridIdentityMetadata"} # type: ignore 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..79dbc374f432 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,307 +6,506 @@ # 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 warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_create_request( + resource_group_name: str, vcenter_name: str, inventory_item_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}/inventoryItems/{inventoryItemName}", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, vcenter_name: str, inventory_item_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}/inventoryItems/{inventoryItemName}", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, vcenter_name: str, inventory_item_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}/inventoryItems/{inventoryItemName}", + ) # pylint: disable=line-too-long + 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"), + } -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + _url = _format_url_section(_url, **path_format_arguments) - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") -class InventoryItemsOperations(object): - """InventoryItemsOperations operations. + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.connectedvmware.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + +def build_list_by_v_center_request( + resource_group_name: str, vcenter_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}/inventoryItems", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class InventoryItemsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.connectedvmware.AzureArcVMwareManagementServiceAPI`'s + :attr:`inventory_items` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @overload 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, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.InventoryItem: """Implements InventoryItem PUT method. Create Or Update InventoryItem. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param vcenter_name: Name of the vCenter. + :param vcenter_name: Name of the vCenter. Required. :type vcenter_name: str - :param inventory_item_name: Name of the inventoryItem. + :param inventory_item_name: Name of the inventoryItem. Required. :type inventory_item_name: str - :param body: Request payload. + :param body: Request payload. Default value is None. :type body: ~azure.mgmt.connectedvmware.models.InventoryItem + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: InventoryItem, or the result of cls(response) + :return: InventoryItem or the result of cls(response) :rtype: ~azure.mgmt.connectedvmware.models.InventoryItem - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.InventoryItem"] - 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.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') - - body_content_kwargs = {} # type: Dict[str, Any] - if body is not None: - body_content = self._serialize.body(body, 'InventoryItem') + + @overload + def create( + self, + resource_group_name: str, + vcenter_name: str, + inventory_item_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.InventoryItem: + """Implements InventoryItem PUT method. + + Create Or Update InventoryItem. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param vcenter_name: Name of the vCenter. Required. + :type vcenter_name: str + :param inventory_item_name: Name of the inventoryItem. Required. + :type inventory_item_name: str + :param body: Request payload. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: InventoryItem or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.InventoryItem + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + vcenter_name: str, + inventory_item_name: str, + body: Optional[Union[_models.InventoryItem, IO]] = None, + **kwargs: Any + ) -> _models.InventoryItem: + """Implements InventoryItem PUT method. + + Create Or Update InventoryItem. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param vcenter_name: Name of the vCenter. Required. + :type vcenter_name: str + :param inventory_item_name: Name of the inventoryItem. Required. + :type inventory_item_name: str + :param body: Request payload. Is either a model type or a IO type. Default value is None. + :type body: ~azure.mgmt.connectedvmware.models.InventoryItem or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: InventoryItem or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.InventoryItem + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.InventoryItem] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - body_content = None - 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) + if body is not None: + _json = self._serialize.body(body, "InventoryItem") + else: + _json = None + + request = build_create_request( + resource_group_name=resource_group_name, + vcenter_name=vcenter_name, + inventory_item_name=inventory_item_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + deserialized = self._deserialize("InventoryItem", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}/inventoryItems/{inventoryItemName}'} # type: ignore + 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" + self, resource_group_name: str, vcenter_name: str, inventory_item_name: str, **kwargs: Any + ) -> _models.InventoryItem: """Gets InventoryItem. Implements InventoryItem GET method. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param vcenter_name: Name of the vCenter. + :param vcenter_name: Name of the vCenter. Required. :type vcenter_name: str - :param inventory_item_name: Name of the inventoryItem. + :param inventory_item_name: Name of the inventoryItem. Required. :type inventory_item_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: InventoryItem, or the result of cls(response) + :return: InventoryItem or the result of cls(response) :rtype: ~azure.mgmt.connectedvmware.models.InventoryItem - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.InventoryItem"] - 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.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 = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.InventoryItem] + + request = build_get_request( + resource_group_name=resource_group_name, + vcenter_name=vcenter_name, + inventory_item_name=inventory_item_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + deserialized = self._deserialize("InventoryItem", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}/inventoryItems/{inventoryItemName}'} # type: ignore - def delete( - self, - resource_group_name, # type: str - vcenter_name, # type: str - inventory_item_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}/inventoryItems/{inventoryItemName}"} # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, vcenter_name: str, inventory_item_name: str, **kwargs: Any + ) -> None: """Deletes an inventoryItem. Implements inventoryItem DELETE method. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param vcenter_name: Name of the vCenter. + :param vcenter_name: Name of the vCenter. Required. :type vcenter_name: str - :param inventory_item_name: Name of the inventoryItem. + :param inventory_item_name: Name of the inventoryItem. Required. :type inventory_item_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - 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.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 = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + vcenter_name=vcenter_name, + inventory_item_name=inventory_item_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}/inventoryItems/{inventoryItemName}'} # type: ignore + 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"] + self, resource_group_name: str, vcenter_name: str, **kwargs: Any + ) -> Iterable["_models.InventoryItem"]: """Implements GET inventoryItems in a vCenter. Returns the list of inventoryItems of the given vCenter. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param vcenter_name: Name of the vCenter. + :param vcenter_name: Name of the vCenter. Required. :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.paging.ItemPaged[~azure.mgmt.connectedvmware.models.InventoryItemsList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either InventoryItem or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.connectedvmware.models.InventoryItem] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.InventoryItemsList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.InventoryItemsList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): 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( + resource_group_name=resource_group_name, + vcenter_name=vcenter_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_v_center.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -314,17 +514,18 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_v_center.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}/inventoryItems'} # type: ignore + return ItemPaged(get_next, extract_data) + + list_by_v_center.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}/inventoryItems"} # type: ignore 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..3e73fdf1bd27 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,564 +6,902 @@ # 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 warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_create_or_update_request( + resource_group_name: str, name: str, extension_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, name: str, extension_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, name: str, extension_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, name: str, extension_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -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]] +def build_list_request( + resource_group_name: str, name: str, subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) -class MachineExtensionsOperations(object): - """MachineExtensionsOperations operations. + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions", + ) # pylint: disable=line-too-long + 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"), + } - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.connectedvmware.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class MachineExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.connectedvmware.AzureArcVMwareManagementServiceAPI`'s + :attr:`machine_extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("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" - 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') - - # 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] - 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) + resource_group_name: str, + name: str, + extension_name: str, + extension_parameters: Union[_models.MachineExtension, IO], + **kwargs: Any + ) -> _models.MachineExtension: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MachineExtension] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(extension_parameters, (IO, bytes)): + _content = extension_parameters + else: + _json = self._serialize.body(extension_parameters, "MachineExtension") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + name=name, + extension_name=extension_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('MachineExtension', pipeline_response) + deserialized = self._deserialize("MachineExtension", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('MachineExtension', pipeline_response) + deserialized = self._deserialize("MachineExtension", pipeline_response) if cls: 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 + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}"} # type: ignore + + @overload 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, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MachineExtension]: """The operation to create or update the extension. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str :param name: The name of the machine where the extension should be created or updated. + Required. :type name: str - :param extension_name: The name of the machine extension. + :param extension_name: The name of the machine extension. Required. :type extension_name: str :param extension_parameters: Parameters supplied to the Create Machine Extension operation. + Required. :type extension_parameters: ~azure.mgmt.connectedvmware.models.MachineExtension + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. - :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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.MachineExtension"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + name: str, + extension_name: str, + extension_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MachineExtension]: + """The operation to create or update the extension. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param name: The name of the machine where the extension should be created or updated. + Required. + :type name: str + :param extension_name: The name of the machine extension. Required. + :type extension_name: str + :param extension_parameters: Parameters supplied to the Create Machine Extension operation. + Required. + :type extension_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.connectedvmware.models.MachineExtension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + name: str, + extension_name: str, + extension_parameters: Union[_models.MachineExtension, IO], + **kwargs: Any + ) -> LROPoller[_models.MachineExtension]: + """The operation to create or update the extension. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param name: The name of the machine where the extension should be created or updated. + Required. + :type name: str + :param extension_name: The name of the machine extension. Required. + :type extension_name: str + :param extension_parameters: Parameters supplied to the Create Machine Extension operation. Is + either a model type or a IO type. Required. + :type extension_parameters: ~azure.mgmt.connectedvmware.models.MachineExtension or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.connectedvmware.models.MachineExtension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MachineExtension] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, name=name, extension_name=extension_name, extension_parameters=extension_parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('MachineExtension', pipeline_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) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - 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 + 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" - 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') - - # 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] - 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) + resource_group_name: str, + name: str, + extension_name: str, + extension_parameters: Union[_models.MachineExtensionUpdate, IO], + **kwargs: Any + ) -> _models.MachineExtension: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MachineExtension] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(extension_parameters, (IO, bytes)): + _content = extension_parameters + else: + _json = self._serialize.body(extension_parameters, "MachineExtensionUpdate") + + request = build_update_request( + resource_group_name=resource_group_name, + name=name, + extension_name=extension_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('MachineExtension', pipeline_response) + deserialized = self._deserialize("MachineExtension", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('MachineExtension', pipeline_response) + deserialized = self._deserialize("MachineExtension", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}'} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}"} # type: ignore + + @overload 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, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MachineExtension]: """The operation to update the extension. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str :param name: The name of the machine where the extension should be created or updated. + Required. :type name: str - :param extension_name: The name of the machine extension. + :param extension_name: The name of the machine extension. Required. :type extension_name: str :param extension_parameters: Parameters supplied to the Create Machine Extension operation. + Required. :type extension_parameters: ~azure.mgmt.connectedvmware.models.MachineExtensionUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. - :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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.MachineExtension"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_update( + self, + resource_group_name: str, + name: str, + extension_name: str, + extension_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.MachineExtension]: + """The operation to update the extension. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param name: The name of the machine where the extension should be created or updated. + Required. + :type name: str + :param extension_name: The name of the machine extension. Required. + :type extension_name: str + :param extension_parameters: Parameters supplied to the Create Machine Extension operation. + Required. + :type extension_parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.connectedvmware.models.MachineExtension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + name: str, + extension_name: str, + extension_parameters: Union[_models.MachineExtensionUpdate, IO], + **kwargs: Any + ) -> LROPoller[_models.MachineExtension]: + """The operation to update the extension. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param name: The name of the machine where the extension should be created or updated. + Required. + :type name: str + :param extension_name: The name of the machine extension. Required. + :type extension_name: str + :param extension_parameters: Parameters supplied to the Create Machine Extension operation. Is + either a model type or a IO type. Required. + :type extension_parameters: ~azure.mgmt.connectedvmware.models.MachineExtensionUpdate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.connectedvmware.models.MachineExtension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.MachineExtension] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, name=name, extension_name=extension_name, extension_parameters=extension_parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('MachineExtension', pipeline_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) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - 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 + 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( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, name: str, extension_name: str, **kwargs: Any + ) -> None: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + name=name, + extension_name=extension_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - def _delete_initial( - self, - resource_group_name, # type: str - name, # type: str - extension_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> 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 = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}'} # type: ignore + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}"} # type: ignore - def begin_delete( - self, - resource_group_name, # type: str - name, # type: str - extension_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, 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. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param name: The name of the machine where the extension should be deleted. + :param name: The name of the machine where the extension should be deleted. Required. :type name: str - :param extension_name: The name of the machine extension. + :param extension_name: The name of the machine extension. Required. :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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, name=name, extension_name=extension_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements 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) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - 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 + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def get( - self, - resource_group_name, # type: str - name, # type: str - extension_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.MachineExtension" + 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: str, name: str, extension_name: str, **kwargs: Any) -> _models.MachineExtension: """The operation to get the extension. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param name: The name of the machine containing the extension. + :param name: The name of the machine containing the extension. Required. :type name: str - :param extension_name: The name of the machine extension. + :param extension_name: The name of the machine extension. Required. :type extension_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MachineExtension, or the result of cls(response) + :return: MachineExtension or the result of cls(response) :rtype: ~azure.mgmt.connectedvmware.models.MachineExtension - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - 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" - 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 = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MachineExtension] + + request = build_get_request( + resource_group_name=resource_group_name, + name=name, + extension_name=extension_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + deserialized = self._deserialize("MachineExtension", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}'} # type: ignore + 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"] + self, resource_group_name: str, name: str, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.MachineExtension"]: """The operation to get all extensions of a non-Azure machine. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param name: The name of the machine containing the extension. + :param name: The name of the machine containing the extension. Required. :type name: str - :param expand: The expand expression to apply on the operation. + :param expand: The expand expression to apply on the operation. Default value is None. :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] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either MachineExtension or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.connectedvmware.models.MachineExtension] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MachineExtensionsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.MachineExtensionsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): 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( + resource_group_name=resource_group_name, + name=name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -571,17 +910,18 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions'} # type: ignore + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions"} # type: ignore 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..2cedeedbdd81 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,87 +6,116 @@ # 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 warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer +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 + -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +def build_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + accept = _headers.pop("Accept", "application/json") -class Operations(object): - """Operations operations. + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.ConnectedVMwarevSphere/operations") - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.connectedvmware.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.connectedvmware.AzureArcVMwareManagementServiceAPI`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationsList"] + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Returns list of all operations. :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.paging.ItemPaged[~azure.mgmt.connectedvmware.models.OperationsList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.connectedvmware.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationsList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationsList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): 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 = self._client.get(url, query_parameters, header_parameters) + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -94,17 +124,18 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) 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': '/providers/Microsoft.ConnectedVMwarevSphere/operations'} # type: ignore + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.ConnectedVMwarevSphere/operations"} # type: ignore diff --git a/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_patch.py b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/connectedvmware/azure-mgmt-connectedvmware/azure/mgmt/connectedvmware/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ 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..09e2c7188729 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,486 +6,822 @@ # 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 warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_create_request( + resource_group_name: str, resource_pool_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools/{resourcePoolName}", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, resource_pool_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools/{resourcePoolName}", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, resource_pool_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools/{resourcePoolName}", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + resource_pool_name: str, + subscription_id: str, + *, + force: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools/{resourcePoolName}", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if force is not None: + _params["force"] = _SERIALIZER.query("force", force, "bool") -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -class ResourcePoolsOperations(object): - """ResourcePoolsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.connectedvmware.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools" + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ResourcePoolsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.connectedvmware.AzureArcVMwareManagementServiceAPI`'s + :attr:`resource_pools` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("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" - 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') - - # 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') + resource_group_name: str, + resource_pool_name: str, + body: Optional[Union[_models.ResourcePool, IO]] = None, + **kwargs: Any + ) -> _models.ResourcePool: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourcePool] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - body_content = None - 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) + if body is not None: + _json = self._serialize.body(body, "ResourcePool") + else: + _json = None + + request = build_create_request( + resource_group_name=resource_group_name, + resource_pool_name=resource_pool_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ResourcePool', pipeline_response) + deserialized = self._deserialize("ResourcePool", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ResourcePool', pipeline_response) + deserialized = self._deserialize("ResourcePool", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools/{resourcePoolName}'} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools/{resourcePoolName}"} # type: ignore + + @overload 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, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ResourcePool]: """Implements resourcePool PUT method. Create Or Update resourcePool. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param resource_pool_name: Name of the resourcePool. + :param resource_pool_name: Name of the resourcePool. Required. :type resource_pool_name: str - :param body: Request payload. + :param body: Request payload. Default value is None. :type body: ~azure.mgmt.connectedvmware.models.ResourcePool + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. - :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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourcePool"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create( + self, + resource_group_name: str, + resource_pool_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ResourcePool]: + """Implements resourcePool PUT method. + + Create Or Update resourcePool. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param resource_pool_name: Name of the resourcePool. Required. + :type resource_pool_name: str + :param body: Request payload. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.connectedvmware.models.ResourcePool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + resource_pool_name: str, + body: Optional[Union[_models.ResourcePool, IO]] = None, + **kwargs: Any + ) -> LROPoller[_models.ResourcePool]: + """Implements resourcePool PUT method. + + Create Or Update resourcePool. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param resource_pool_name: Name of the resourcePool. Required. + :type resource_pool_name: str + :param body: Request payload. Is either a model type or a IO type. Default value is None. + :type body: ~azure.mgmt.connectedvmware.models.ResourcePool or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.connectedvmware.models.ResourcePool] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourcePool] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_initial( + raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, resource_pool_name=resource_pool_name, body=body, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ResourcePool', pipeline_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) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - 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 + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def get( - self, - resource_group_name, # type: str - resource_pool_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ResourcePool" + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools/{resourcePoolName}"} # type: ignore + + @distributed_trace + def get(self, resource_group_name: str, resource_pool_name: str, **kwargs: Any) -> _models.ResourcePool: """Gets a resourcePool. Implements resourcePool GET method. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param resource_pool_name: Name of the resourcePool. + :param resource_pool_name: Name of the resourcePool. Required. :type resource_pool_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourcePool, or the result of cls(response) + :return: ResourcePool or the result of cls(response) :rtype: ~azure.mgmt.connectedvmware.models.ResourcePool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - 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" - 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 = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourcePool] + + request = build_get_request( + resource_group_name=resource_group_name, + resource_pool_name=resource_pool_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + deserialized = self._deserialize("ResourcePool", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools/{resourcePoolName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools/{resourcePoolName}"} # type: ignore + + @overload 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, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ResourcePool: """Updates a resourcePool. API to update certain properties of the resourcePool resource. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param resource_pool_name: Name of the resourcePool. + :param resource_pool_name: Name of the resourcePool. Required. :type resource_pool_name: str - :param body: Resource properties to update. + :param body: Resource properties to update. Default value is None. :type body: ~azure.mgmt.connectedvmware.models.ResourcePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourcePool, or the result of cls(response) + :return: ResourcePool or the result of cls(response) :rtype: ~azure.mgmt.connectedvmware.models.ResourcePool - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - 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.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') - - body_content_kwargs = {} # type: Dict[str, Any] - if body is not None: - body_content = self._serialize.body(body, 'ResourcePatch') + + @overload + def update( + self, + resource_group_name: str, + resource_pool_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ResourcePool: + """Updates a resourcePool. + + API to update certain properties of the resourcePool resource. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param resource_pool_name: Name of the resourcePool. Required. + :type resource_pool_name: str + :param body: Resource properties to update. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourcePool or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.ResourcePool + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + resource_pool_name: str, + body: Optional[Union[_models.ResourcePatch, IO]] = None, + **kwargs: Any + ) -> _models.ResourcePool: + """Updates a resourcePool. + + API to update certain properties of the resourcePool resource. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param resource_pool_name: Name of the resourcePool. Required. + :type resource_pool_name: str + :param body: Resource properties to update. Is either a model type or a IO type. Default value + is None. + :type body: ~azure.mgmt.connectedvmware.models.ResourcePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourcePool or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.ResourcePool + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourcePool] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - body_content = None - 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) + if body is not None: + _json = self._serialize.body(body, "ResourcePatch") + else: + _json = None + + request = build_update_request( + resource_group_name=resource_group_name, + resource_pool_name=resource_pool_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + deserialized = self._deserialize("ResourcePool", pipeline_response) if cls: 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 - 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 = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools/{resourcePoolName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_pool_name: str, force: Optional[bool] = None, **kwargs: Any + ) -> None: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + resource_pool_name=resource_pool_name, + subscription_id=self._config.subscription_id, + force=force, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools/{resourcePoolName}'} # type: ignore + _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] + self, resource_group_name: str, resource_pool_name: str, force: Optional[bool] = None, **kwargs: Any + ) -> LROPoller[None]: """Deletes an resourcePool. Implements resourcePool DELETE method. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param resource_pool_name: Name of the resourcePool. + :param resource_pool_name: Name of the resourcePool. Required. :type resource_pool_name: str - :param force: Whether force delete was specified. + :param force: Whether force delete was specified. Default value is None. :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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_pool_name=resource_pool_name, force=force, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements 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) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - 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 + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def list( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ResourcePoolsList"] + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools/{resourcePoolName}"} # type: ignore + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.ResourcePool"]: """Implements GET resourcePools in a subscription. List of resourcePools 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 ResourcePoolsList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.connectedvmware.models.ResourcePoolsList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ResourcePool or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.connectedvmware.models.ResourcePool] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourcePoolsList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourcePoolsList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): 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, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -493,72 +830,71 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) 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 + return ItemPaged(get_next, extract_data) - def list_by_resource_group( - self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ResourcePoolsList"] + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools"} # type: ignore + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.ResourcePool"]: """Implements GET resourcePools in a resource group. List of resourcePools in a resource group. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :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.paging.ItemPaged[~azure.mgmt.connectedvmware.models.ResourcePoolsList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ResourcePool or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.connectedvmware.models.ResourcePool] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourcePoolsList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourcePoolsList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): 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( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -567,17 +903,18 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools'} # type: ignore + return ItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools"} # type: ignore 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..85ef4c53c075 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,486 +6,812 @@ # 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 warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_create_request( + resource_group_name: str, vcenter_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(resource_group_name: str, vcenter_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, vcenter_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, vcenter_name: str, subscription_id: str, *, force: Optional[bool] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if force is not None: + _params["force"] = _SERIALIZER.query("force", force, "bool") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + accept = _headers.pop("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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + accept = _headers.pop("Accept", "application/json") -class VCentersOperations(object): - """VCentersOperations operations. + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + _url = _format_url_section(_url, **path_format_arguments) - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.connectedvmware.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class VCentersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.connectedvmware.AzureArcVMwareManagementServiceAPI`'s + :attr:`vcenters` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("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" - 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') - - # 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') + resource_group_name: str, + vcenter_name: str, + body: Optional[Union[_models.VCenter, IO]] = None, + **kwargs: Any + ) -> _models.VCenter: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.VCenter] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - body_content = None - 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) + if body is not None: + _json = self._serialize.body(body, "VCenter") + else: + _json = None + + request = build_create_request( + resource_group_name=resource_group_name, + vcenter_name=vcenter_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('VCenter', pipeline_response) + deserialized = self._deserialize("VCenter", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('VCenter', pipeline_response) + deserialized = self._deserialize("VCenter", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}'} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}"} # type: ignore + + @overload 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, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VCenter]: """Implements vCenter PUT method. Create Or Update vCenter. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param vcenter_name: Name of the vCenter. + :param vcenter_name: Name of the vCenter. Required. :type vcenter_name: str - :param body: Request payload. + :param body: Request payload. Default value is None. :type body: ~azure.mgmt.connectedvmware.models.VCenter + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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 VCenter or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.connectedvmware.models.VCenter] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VCenter"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create( + self, + resource_group_name: str, + vcenter_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VCenter]: + """Implements vCenter PUT method. + + Create Or Update vCenter. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param vcenter_name: Name of the vCenter. Required. + :type vcenter_name: str + :param body: Request payload. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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 VCenter or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.connectedvmware.models.VCenter] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + vcenter_name: str, + body: Optional[Union[_models.VCenter, IO]] = None, + **kwargs: Any + ) -> LROPoller[_models.VCenter]: + """Implements vCenter PUT method. + + Create Or Update vCenter. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param vcenter_name: Name of the vCenter. Required. + :type vcenter_name: str + :param body: Request payload. Is either a model type or a IO type. Default value is None. + :type body: ~azure.mgmt.connectedvmware.models.VCenter or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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 VCenter or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.connectedvmware.models.VCenter] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.VCenter] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_initial( + raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, vcenter_name=vcenter_name, body=body, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('VCenter', pipeline_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) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - 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 + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def get( - self, - resource_group_name, # type: str - vcenter_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.VCenter" + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}"} # type: ignore + + @distributed_trace + def get(self, resource_group_name: str, vcenter_name: str, **kwargs: Any) -> _models.VCenter: """Gets a vCenter. Implements vCenter GET method. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param vcenter_name: Name of the vCenter. + :param vcenter_name: Name of the vCenter. Required. :type vcenter_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: VCenter, or the result of cls(response) + :return: VCenter or the result of cls(response) :rtype: ~azure.mgmt.connectedvmware.models.VCenter - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - 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" - 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 = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.VCenter] + + request = build_get_request( + resource_group_name=resource_group_name, + vcenter_name=vcenter_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + deserialized = self._deserialize("VCenter", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}"} # type: ignore + + @overload 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, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.VCenter: """Updates a vCenter. API to update certain properties of the vCenter resource. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param vcenter_name: Name of the vCenter. + :param vcenter_name: Name of the vCenter. Required. :type vcenter_name: str - :param body: Resource properties to update. + :param body: Resource properties to update. Default value is None. :type body: ~azure.mgmt.connectedvmware.models.ResourcePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: VCenter or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.VCenter + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + vcenter_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.VCenter: + """Updates a vCenter. + + API to update certain properties of the vCenter resource. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param vcenter_name: Name of the vCenter. Required. + :type vcenter_name: str + :param body: Resource properties to update. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: VCenter or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.VCenter + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + vcenter_name: str, + body: Optional[Union[_models.ResourcePatch, IO]] = None, + **kwargs: Any + ) -> _models.VCenter: + """Updates a vCenter. + + API to update certain properties of the vCenter resource. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param vcenter_name: Name of the vCenter. Required. + :type vcenter_name: str + :param body: Resource properties to update. Is either a model type or a IO type. Default value + is None. + :type body: ~azure.mgmt.connectedvmware.models.ResourcePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: VCenter, or the result of cls(response) + :return: VCenter or the result of cls(response) :rtype: ~azure.mgmt.connectedvmware.models.VCenter - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - 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.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') - - body_content_kwargs = {} # type: Dict[str, Any] - if body is not None: - body_content = self._serialize.body(body, 'ResourcePatch') + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.VCenter] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - body_content = None - 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) + if body is not None: + _json = self._serialize.body(body, "ResourcePatch") + else: + _json = None + + request = build_update_request( + resource_group_name=resource_group_name, + vcenter_name=vcenter_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + deserialized = self._deserialize("VCenter", pipeline_response) if cls: 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 - 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 = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, vcenter_name: str, force: Optional[bool] = None, **kwargs: Any + ) -> None: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + vcenter_name=vcenter_name, + subscription_id=self._config.subscription_id, + force=force, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}'} # type: ignore + _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] + self, resource_group_name: str, vcenter_name: str, force: Optional[bool] = None, **kwargs: Any + ) -> LROPoller[None]: """Deletes an vCenter. Implements vCenter DELETE method. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param vcenter_name: Name of the vCenter. + :param vcenter_name: Name of the vCenter. Required. :type vcenter_name: str - :param force: Whether force delete was specified. + :param force: Whether force delete was specified. Default value is None. :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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, vcenter_name=vcenter_name, force=force, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements 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) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - 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 + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def list( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.VCentersList"] + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}"} # type: ignore + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.VCenter"]: """Implements GET vCenters in a subscription. List of vCenters 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 VCentersList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.connectedvmware.models.VCentersList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either VCenter or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.connectedvmware.models.VCenter] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VCentersList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.VCentersList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): 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, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -493,72 +820,71 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) 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 + return ItemPaged(get_next, extract_data) - def list_by_resource_group( - self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.VCentersList"] + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/vcenters"} # type: ignore + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.VCenter"]: """Implements GET vCenters in a resource group. List of vCenters in a resource group. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :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.paging.ItemPaged[~azure.mgmt.connectedvmware.models.VCentersList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either VCenter or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.connectedvmware.models.VCenter] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VCentersList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.VCentersList] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): 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( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -567,17 +893,18 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters'} # type: ignore + return ItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters"} # type: ignore 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..ee751153b0dd 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,486 +6,837 @@ # 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 warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_create_request( + resource_group_name: str, virtual_machine_template_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates/{virtualMachineTemplateName}", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, virtual_machine_template_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates/{virtualMachineTemplateName}", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, virtual_machine_template_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates/{virtualMachineTemplateName}", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + virtual_machine_template_name: str, + subscription_id: str, + *, + force: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates/{virtualMachineTemplateName}", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if force is not None: + _params["force"] = _SERIALIZER.query("force", force, "bool") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + accept = _headers.pop("Accept", "application/json") -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + _url = _format_url_section(_url, **path_format_arguments) -class VirtualMachineTemplatesOperations(object): - """VirtualMachineTemplatesOperations operations. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.connectedvmware.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class VirtualMachineTemplatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.connectedvmware.AzureArcVMwareManagementServiceAPI`'s + :attr:`virtual_machine_templates` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("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" - 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') - - # 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') + resource_group_name: str, + virtual_machine_template_name: str, + body: Optional[Union[_models.VirtualMachineTemplate, IO]] = None, + **kwargs: Any + ) -> _models.VirtualMachineTemplate: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.VirtualMachineTemplate] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - body_content = None - 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) + if body is not None: + _json = self._serialize.body(body, "VirtualMachineTemplate") + else: + _json = None + + request = build_create_request( + resource_group_name=resource_group_name, + virtual_machine_template_name=virtual_machine_template_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('VirtualMachineTemplate', pipeline_response) + deserialized = self._deserialize("VirtualMachineTemplate", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('VirtualMachineTemplate', pipeline_response) + deserialized = self._deserialize("VirtualMachineTemplate", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates/{virtualMachineTemplateName}'} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates/{virtualMachineTemplateName}"} # type: ignore + + @overload 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, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualMachineTemplate]: """Implements virtual machine template PUT method. Create Or Update virtual machine template. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param virtual_machine_template_name: Name of the virtual machine template resource. + :param virtual_machine_template_name: Name of the virtual machine template resource. Required. :type virtual_machine_template_name: str - :param body: Request payload. + :param body: Request payload. Default value is None. :type body: ~azure.mgmt.connectedvmware.models.VirtualMachineTemplate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. - :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] + :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] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineTemplate"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create( + self, + resource_group_name: str, + virtual_machine_template_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualMachineTemplate]: + """Implements virtual machine template PUT method. + + Create Or Update virtual machine template. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param virtual_machine_template_name: Name of the virtual machine template resource. Required. + :type virtual_machine_template_name: str + :param body: Request payload. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + virtual_machine_template_name: str, + body: Optional[Union[_models.VirtualMachineTemplate, IO]] = None, + **kwargs: Any + ) -> LROPoller[_models.VirtualMachineTemplate]: + """Implements virtual machine template PUT method. + + Create Or Update virtual machine template. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param virtual_machine_template_name: Name of the virtual machine template resource. Required. + :type virtual_machine_template_name: str + :param body: Request payload. Is either a model type or a IO type. Default value is None. + :type body: ~azure.mgmt.connectedvmware.models.VirtualMachineTemplate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.VirtualMachineTemplate] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_initial( + raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, virtual_machine_template_name=virtual_machine_template_name, body=body, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('VirtualMachineTemplate', pipeline_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) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - 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 + 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" + self, resource_group_name: str, virtual_machine_template_name: str, **kwargs: Any + ) -> _models.VirtualMachineTemplate: """Gets a virtual machine template. Implements virtual machine template GET method. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param virtual_machine_template_name: Name of the virtual machine template resource. + :param virtual_machine_template_name: Name of the virtual machine template resource. Required. :type virtual_machine_template_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: VirtualMachineTemplate, or the result of cls(response) + :return: VirtualMachineTemplate or the result of cls(response) :rtype: ~azure.mgmt.connectedvmware.models.VirtualMachineTemplate - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - 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" - 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 = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.VirtualMachineTemplate] + + request = build_get_request( + resource_group_name=resource_group_name, + virtual_machine_template_name=virtual_machine_template_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + deserialized = self._deserialize("VirtualMachineTemplate", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates/{virtualMachineTemplateName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates/{virtualMachineTemplateName}"} # type: ignore + + @overload 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, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.VirtualMachineTemplate: """Updates a virtual machine template. API to update certain properties of the virtual machine template resource. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param virtual_machine_template_name: Name of the virtual machine template resource. + :param virtual_machine_template_name: Name of the virtual machine template resource. Required. :type virtual_machine_template_name: str - :param body: Resource properties to update. + :param body: Resource properties to update. Default value is None. :type body: ~azure.mgmt.connectedvmware.models.ResourcePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: VirtualMachineTemplate or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.VirtualMachineTemplate + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + virtual_machine_template_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.VirtualMachineTemplate: + """Updates a virtual machine template. + + API to update certain properties of the virtual machine template resource. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param virtual_machine_template_name: Name of the virtual machine template resource. Required. + :type virtual_machine_template_name: str + :param body: Resource properties to update. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: VirtualMachineTemplate, or the result of cls(response) + :return: VirtualMachineTemplate or the result of cls(response) :rtype: ~azure.mgmt.connectedvmware.models.VirtualMachineTemplate - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - 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.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') - - body_content_kwargs = {} # type: Dict[str, Any] - if body is not None: - body_content = self._serialize.body(body, 'ResourcePatch') + + @distributed_trace + def update( + self, + resource_group_name: str, + virtual_machine_template_name: str, + body: Optional[Union[_models.ResourcePatch, IO]] = None, + **kwargs: Any + ) -> _models.VirtualMachineTemplate: + """Updates a virtual machine template. + + API to update certain properties of the virtual machine template resource. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param virtual_machine_template_name: Name of the virtual machine template resource. Required. + :type virtual_machine_template_name: str + :param body: Resource properties to update. Is either a model type or a IO type. Default value + is None. + :type body: ~azure.mgmt.connectedvmware.models.ResourcePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: VirtualMachineTemplate or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.VirtualMachineTemplate + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.VirtualMachineTemplate] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - body_content = None - 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) + if body is not None: + _json = self._serialize.body(body, "ResourcePatch") + else: + _json = None + + request = build_update_request( + resource_group_name=resource_group_name, + virtual_machine_template_name=virtual_machine_template_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + deserialized = self._deserialize("VirtualMachineTemplate", pipeline_response) if cls: 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 - 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 = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates/{virtualMachineTemplateName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, virtual_machine_template_name: str, force: Optional[bool] = None, **kwargs: Any + ) -> None: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + virtual_machine_template_name=virtual_machine_template_name, + subscription_id=self._config.subscription_id, + force=force, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates/{virtualMachineTemplateName}'} # type: ignore + _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] + self, 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. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param virtual_machine_template_name: Name of the virtual machine template resource. + :param virtual_machine_template_name: Name of the virtual machine template resource. Required. :type virtual_machine_template_name: str - :param force: Whether force delete was specified. + :param force: Whether force delete was specified. Default value is None. :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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, virtual_machine_template_name=virtual_machine_template_name, force=force, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements 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) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - 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 + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def list( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.VirtualMachineTemplatesList"] + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates/{virtualMachineTemplateName}"} # type: ignore + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.VirtualMachineTemplate"]: """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] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either VirtualMachineTemplate or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.connectedvmware.models.VirtualMachineTemplate] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineTemplatesList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.VirtualMachineTemplatesList] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): 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, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -493,72 +845,74 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) 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 + 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"] + self, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.VirtualMachineTemplate"]: """Implements GET virtualMachineTemplates in a resource group. List of virtualMachineTemplates in a resource group. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :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] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either VirtualMachineTemplate or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.connectedvmware.models.VirtualMachineTemplate] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachineTemplatesList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.VirtualMachineTemplatesList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): 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( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -567,17 +921,18 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates'} # type: ignore + return ItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates"} # type: ignore 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..9c7a8fe10f99 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,901 +6,1833 @@ # 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 warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_assess_patches_request( + resource_group_name: str, name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/assessPatches", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_install_patches_request( + resource_group_name: str, name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/installPatches", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request( + resource_group_name: str, virtual_machine_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, virtual_machine_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, virtual_machine_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + virtual_machine_name: str, + subscription_id: str, + *, + force: Optional[bool] = None, + retain: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if force is not None: + _params["force"] = _SERIALIZER.query("force", force, "bool") + if retain is not None: + _params["retain"] = _SERIALIZER.query("retain", retain, "bool") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_stop_request( + resource_group_name: str, virtual_machine_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/stop", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_start_request( + resource_group_name: str, virtual_machine_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/start", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_restart_request( + resource_group_name: str, virtual_machine_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/restart", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines" + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + accept = _headers.pop("Accept", "application/json") -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + _url = _format_url_section(_url, **path_format_arguments) -class VirtualMachinesOperations(object): - """VirtualMachinesOperations operations. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.connectedvmware.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class VirtualMachinesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.connectedvmware.AzureArcVMwareManagementServiceAPI`'s + :attr:`virtual_machines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + def _assess_patches_initial( + self, resource_group_name: str, name: str, **kwargs: Any + ) -> Optional[_models.VirtualMachineAssessPatchesResult]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.VirtualMachineAssessPatchesResult]] + + request = build_assess_patches_request( + resource_group_name=resource_group_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._assess_patches_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("VirtualMachineAssessPatchesResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _assess_patches_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/assessPatches"} # type: ignore + + @distributed_trace + def begin_assess_patches( + self, resource_group_name: str, name: str, **kwargs: Any + ) -> LROPoller[_models.VirtualMachineAssessPatchesResult]: + """The operation to assess patches on a vSphere VMware machine identity in Azure. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param name: The name of the vSphere VMware machine. Required. + :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. + :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 VirtualMachineAssessPatchesResult or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.connectedvmware.models.VirtualMachineAssessPatchesResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.VirtualMachineAssessPatchesResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._assess_patches_initial( # type: ignore + resource_group_name=resource_group_name, + name=name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("VirtualMachineAssessPatchesResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_assess_patches.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/assessPatches"} # type: ignore + + def _install_patches_initial( + self, + resource_group_name: str, + name: str, + install_patches_input: Union[_models.VirtualMachineInstallPatchesParameters, IO], + **kwargs: Any + ) -> Optional[_models.VirtualMachineInstallPatchesResult]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.VirtualMachineInstallPatchesResult]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(install_patches_input, (IO, bytes)): + _content = install_patches_input + else: + _json = self._serialize.body(install_patches_input, "VirtualMachineInstallPatchesParameters") + + request = build_install_patches_request( + resource_group_name=resource_group_name, + name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._install_patches_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("VirtualMachineInstallPatchesResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _install_patches_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/installPatches"} # type: ignore + + @overload + def begin_install_patches( + self, + resource_group_name: str, + name: str, + install_patches_input: _models.VirtualMachineInstallPatchesParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualMachineInstallPatchesResult]: + """The operation to install patches on a vSphere VMware machine identity in Azure. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param name: The name of the vSphere VMware machine. Required. + :type name: str + :param install_patches_input: Input for InstallPatches as directly received by the API. + Required. + :type install_patches_input: + ~azure.mgmt.connectedvmware.models.VirtualMachineInstallPatchesParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. + :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 VirtualMachineInstallPatchesResult or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.connectedvmware.models.VirtualMachineInstallPatchesResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_install_patches( + self, + resource_group_name: str, + name: str, + install_patches_input: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualMachineInstallPatchesResult]: + """The operation to install patches on a vSphere VMware machine identity in Azure. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param name: The name of the vSphere VMware machine. Required. + :type name: str + :param install_patches_input: Input for InstallPatches as directly received by the API. + Required. + :type install_patches_input: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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 VirtualMachineInstallPatchesResult or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.connectedvmware.models.VirtualMachineInstallPatchesResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_install_patches( + self, + resource_group_name: str, + name: str, + install_patches_input: Union[_models.VirtualMachineInstallPatchesParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.VirtualMachineInstallPatchesResult]: + """The operation to install patches on a vSphere VMware machine identity in Azure. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param name: The name of the vSphere VMware machine. Required. + :type name: str + :param install_patches_input: Input for InstallPatches as directly received by the API. Is + either a model type or a IO type. Required. + :type install_patches_input: + ~azure.mgmt.connectedvmware.models.VirtualMachineInstallPatchesParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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 VirtualMachineInstallPatchesResult or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.connectedvmware.models.VirtualMachineInstallPatchesResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.VirtualMachineInstallPatchesResult] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._install_patches_initial( # type: ignore + resource_group_name=resource_group_name, + name=name, + install_patches_input=install_patches_input, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("VirtualMachineInstallPatchesResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_install_patches.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/installPatches"} # type: ignore 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" - 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') - - # 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') + resource_group_name: str, + virtual_machine_name: str, + body: Optional[Union[_models.VirtualMachine, IO]] = None, + **kwargs: Any + ) -> _models.VirtualMachine: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.VirtualMachine] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - body_content = None - 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) + if body is not None: + _json = self._serialize.body(body, "VirtualMachine") + else: + _json = None + + request = build_create_request( + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('VirtualMachine', pipeline_response) + deserialized = self._deserialize("VirtualMachine", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('VirtualMachine', pipeline_response) + deserialized = self._deserialize("VirtualMachine", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}'} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}"} # type: ignore + + @overload 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, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualMachine]: """Implements virtual machine PUT method. Create Or Update virtual machine. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param virtual_machine_name: Name of the virtual machine resource. + :param virtual_machine_name: Name of the virtual machine resource. Required. :type virtual_machine_name: str - :param body: Request payload. + :param body: Request payload. Default value is None. :type body: ~azure.mgmt.connectedvmware.models.VirtualMachine + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. - :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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create( + self, + resource_group_name: str, + virtual_machine_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualMachine]: + """Implements virtual machine PUT method. + + Create Or Update virtual machine. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param virtual_machine_name: Name of the virtual machine resource. Required. + :type virtual_machine_name: str + :param body: Request payload. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.connectedvmware.models.VirtualMachine] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + virtual_machine_name: str, + body: Optional[Union[_models.VirtualMachine, IO]] = None, + **kwargs: Any + ) -> LROPoller[_models.VirtualMachine]: + """Implements virtual machine PUT method. + + Create Or Update virtual machine. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param virtual_machine_name: Name of the virtual machine resource. Required. + :type virtual_machine_name: str + :param body: Request payload. Is either a model type or a IO type. Default value is None. + :type body: ~azure.mgmt.connectedvmware.models.VirtualMachine or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.connectedvmware.models.VirtualMachine] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.VirtualMachine] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_initial( + raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, virtual_machine_name=virtual_machine_name, body=body, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('VirtualMachine', pipeline_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) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - 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 + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def get( - self, - resource_group_name, # type: str - virtual_machine_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.VirtualMachine" + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}"} # type: ignore + + @distributed_trace + def get(self, resource_group_name: str, virtual_machine_name: str, **kwargs: Any) -> _models.VirtualMachine: """Gets a virtual machine. Implements virtual machine GET method. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param virtual_machine_name: Name of the virtual machine resource. + :param virtual_machine_name: Name of the virtual machine resource. Required. :type virtual_machine_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: VirtualMachine, or the result of cls(response) + :return: VirtualMachine or the result of cls(response) :rtype: ~azure.mgmt.connectedvmware.models.VirtualMachine - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - 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" - 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 = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.VirtualMachine] + + request = build_get_request( + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + deserialized = self._deserialize("VirtualMachine", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}'} # type: ignore + + 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"] - 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') - - body_content_kwargs = {} # type: Dict[str, Any] - if body is not None: - body_content = self._serialize.body(body, 'VirtualMachineUpdate') + resource_group_name: str, + virtual_machine_name: str, + body: Optional[Union[_models.VirtualMachineUpdate, IO]] = None, + **kwargs: Any + ) -> Optional[_models.VirtualMachine]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.VirtualMachine]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - body_content = None - 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) + if body is not None: + _json = self._serialize.body(body, "VirtualMachineUpdate") + else: + _json = None + + request = build_update_request( + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = None if response.status_code == 200: - deserialized = self._deserialize('VirtualMachine', pipeline_response) + deserialized = self._deserialize("VirtualMachine", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('VirtualMachine', pipeline_response) + deserialized = self._deserialize("VirtualMachine", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}'} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}"} # type: ignore + + @overload 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, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualMachine]: """Updates a virtual machine. API to update certain properties of the virtual machine resource. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param virtual_machine_name: Name of the virtual machine resource. + :param virtual_machine_name: Name of the virtual machine resource. Required. :type virtual_machine_name: str - :param body: Resource properties to update. + :param body: Resource properties to update. Default value is None. :type body: ~azure.mgmt.connectedvmware.models.VirtualMachineUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. - :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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachine"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_update( + self, + resource_group_name: str, + virtual_machine_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualMachine]: + """Updates a virtual machine. + + API to update certain properties of the virtual machine resource. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param virtual_machine_name: Name of the virtual machine resource. Required. + :type virtual_machine_name: str + :param body: Resource properties to update. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.connectedvmware.models.VirtualMachine] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + virtual_machine_name: str, + body: Optional[Union[_models.VirtualMachineUpdate, IO]] = None, + **kwargs: Any + ) -> LROPoller[_models.VirtualMachine]: + """Updates a virtual machine. + + API to update certain properties of the virtual machine resource. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param virtual_machine_name: Name of the virtual machine resource. Required. + :type virtual_machine_name: str + :param body: Resource properties to update. Is either a model type or a IO type. Default value + is None. + :type body: ~azure.mgmt.connectedvmware.models.VirtualMachineUpdate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.connectedvmware.models.VirtualMachine] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.VirtualMachine] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, virtual_machine_name=virtual_machine_name, body=body, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('VirtualMachine', pipeline_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) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - 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 + 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( + def _delete_initial( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - virtual_machine_name, # type: str - force=None, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> 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 = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + resource_group_name: str, + virtual_machine_name: str, + force: Optional[bool] = None, + retain: Optional[bool] = None, + **kwargs: Any + ) -> None: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + subscription_id=self._config.subscription_id, + force=force, + retain=retain, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}'} # type: ignore + _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, + retain: Optional[bool] = None, + **kwargs: Any + ) -> LROPoller[None]: """Deletes an virtual machine. Implements virtual machine DELETE method. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param virtual_machine_name: Name of the virtual machine resource. + :param virtual_machine_name: Name of the virtual machine resource. Required. :type virtual_machine_name: str - :param force: Whether force delete was specified. + :param force: Whether force delete was specified. Default value is None. :type force: bool + :param retain: Whether to just disable the VM from azure and retain the VM in the VMM. Default + value is None. + :type retain: 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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, virtual_machine_name=virtual_machine_name, force=force, - cls=lambda x,y,z: x, + retain=retain, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements 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) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - 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 + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def _stop_initial( + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}"} # type: ignore + + def _stop_initial( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - virtual_machine_name, # type: str - body=None, # type: Optional["_models.StopVirtualMachineOptions"] - **kwargs # type: Any - ): - # type: (...) -> 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') - - # 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') + resource_group_name: str, + virtual_machine_name: str, + body: Optional[Union[_models.StopVirtualMachineOptions, IO]] = None, + **kwargs: Any + ) -> None: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + if body is not None: + _json = self._serialize.body(body, "StopVirtualMachineOptions") + else: + _json = None + + request = build_stop_request( + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._stop_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _stop_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/stop'} # type: ignore + _stop_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/stop"} # type: ignore + @overload 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, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: """Implements the operation to stop a virtual machine. Stop virtual machine. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param virtual_machine_name: Name of the virtual machine resource. + :param virtual_machine_name: Name of the virtual machine resource. Required. :type virtual_machine_name: str - :param body: Virtualmachine stop action payload. + :param body: Virtualmachine stop action payload. Default value is None. :type body: ~azure.mgmt.connectedvmware.models.StopVirtualMachineOptions + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_stop( + self, + resource_group_name: str, + virtual_machine_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Implements the operation to stop a virtual machine. + + Stop virtual machine. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param virtual_machine_name: Name of the virtual machine resource. Required. + :type virtual_machine_name: str + :param body: Virtualmachine stop action payload. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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 None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_stop( + self, + resource_group_name: str, + virtual_machine_name: str, + body: Optional[Union[_models.StopVirtualMachineOptions, IO]] = None, + **kwargs: Any + ) -> LROPoller[None]: + """Implements the operation to stop a virtual machine. + + Stop virtual machine. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param virtual_machine_name: Name of the virtual machine resource. Required. + :type virtual_machine_name: str + :param body: Virtualmachine stop action payload. Is either a model type or a IO type. Default + value is None. + :type body: ~azure.mgmt.connectedvmware.models.StopVirtualMachineOptions or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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 None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._stop_initial( + raw_result = self._stop_initial( # type: ignore resource_group_name=resource_group_name, virtual_machine_name=virtual_machine_name, body=body, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements 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) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - 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 + 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( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, virtual_machine_name: str, **kwargs: Any + ) -> None: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_start_request( + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._start_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - def _start_initial( - self, - resource_group_name, # type: str - virtual_machine_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> 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 = 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _start_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/start'} # type: ignore + _start_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/start"} # type: ignore - def begin_start( - self, - resource_group_name, # type: str - virtual_machine_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_start(self, resource_group_name: str, virtual_machine_name: str, **kwargs: Any) -> LROPoller[None]: """Implements the operation to start a virtual machine. Start virtual machine. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param virtual_machine_name: Name of the virtual machine resource. + :param virtual_machine_name: Name of the virtual machine resource. Required. :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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._start_initial( + raw_result = self._start_initial( # type: ignore resource_group_name=resource_group_name, virtual_machine_name=virtual_machine_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements 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) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - 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 + 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( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, virtual_machine_name: str, **kwargs: Any + ) -> None: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_restart_request( + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._restart_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - def _restart_initial( - self, - resource_group_name, # type: str - virtual_machine_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> 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 = 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) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _restart_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/restart'} # type: ignore + _restart_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/restart"} # type: ignore - def begin_restart( - self, - resource_group_name, # type: str - virtual_machine_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_restart(self, resource_group_name: str, virtual_machine_name: str, **kwargs: Any) -> LROPoller[None]: """Implements the operation to restart a virtual machine. Restart virtual machine. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param virtual_machine_name: Name of the virtual machine resource. + :param virtual_machine_name: Name of the virtual machine resource. Required. :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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, virtual_machine_name=virtual_machine_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements 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) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - 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 + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def list( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.VirtualMachinesList"] + begin_restart.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/restart"} # type: ignore + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.VirtualMachine"]: """Implements GET virtualMachines in a subscription. List of virtualMachines 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 VirtualMachinesList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.connectedvmware.models.VirtualMachinesList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either VirtualMachine or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.connectedvmware.models.VirtualMachine] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachinesList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.VirtualMachinesList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): 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, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -908,72 +1841,71 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) 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 + return ItemPaged(get_next, extract_data) - def list_by_resource_group( - self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.VirtualMachinesList"] + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines"} # type: ignore + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.VirtualMachine"]: """Implements GET virtualMachines in a resource group. List of virtualMachines in a resource group. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :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.paging.ItemPaged[~azure.mgmt.connectedvmware.models.VirtualMachinesList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either VirtualMachine or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.connectedvmware.models.VirtualMachine] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachinesList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.VirtualMachinesList] + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): 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( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -982,17 +1914,18 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines'} # type: ignore + return ItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines"} # type: ignore 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..3f1a62cf9f93 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,486 +6,822 @@ # 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 warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_create_request( + resource_group_name: str, virtual_network_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks/{virtualNetworkName}", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, virtual_network_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks/{virtualNetworkName}", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, virtual_network_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks/{virtualNetworkName}", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + virtual_network_name: str, + subscription_id: str, + *, + force: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks/{virtualNetworkName}", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if force is not None: + _params["force"] = _SERIALIZER.query("force", force, "bool") -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -class VirtualNetworksOperations(object): - """VirtualNetworksOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.connectedvmware.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks" + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-10-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks", + ) # pylint: disable=line-too-long + 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 + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class VirtualNetworksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.connectedvmware.AzureArcVMwareManagementServiceAPI`'s + :attr:`virtual_networks` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("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" - 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') - - # 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') + resource_group_name: str, + virtual_network_name: str, + body: Optional[Union[_models.VirtualNetwork, IO]] = None, + **kwargs: Any + ) -> _models.VirtualNetwork: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.VirtualNetwork] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - body_content = None - 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) + if body is not None: + _json = self._serialize.body(body, "VirtualNetwork") + else: + _json = None + + request = build_create_request( + resource_group_name=resource_group_name, + virtual_network_name=virtual_network_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('VirtualNetwork', pipeline_response) + deserialized = self._deserialize("VirtualNetwork", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('VirtualNetwork', pipeline_response) + deserialized = self._deserialize("VirtualNetwork", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks/{virtualNetworkName}'} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks/{virtualNetworkName}"} # type: ignore + + @overload 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, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualNetwork]: """Implements virtual network PUT method. Create Or Update virtual network. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param virtual_network_name: Name of the virtual network resource. + :param virtual_network_name: Name of the virtual network resource. Required. :type virtual_network_name: str - :param body: Request payload. + :param body: Request payload. Default value is None. :type body: ~azure.mgmt.connectedvmware.models.VirtualNetwork + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: 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. - :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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetwork"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create( + self, + resource_group_name: str, + virtual_network_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.VirtualNetwork]: + """Implements virtual network PUT method. + + Create Or Update virtual network. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param virtual_network_name: Name of the virtual network resource. Required. + :type virtual_network_name: str + :param body: Request payload. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.connectedvmware.models.VirtualNetwork] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + virtual_network_name: str, + body: Optional[Union[_models.VirtualNetwork, IO]] = None, + **kwargs: Any + ) -> LROPoller[_models.VirtualNetwork]: + """Implements virtual network PUT method. + + Create Or Update virtual network. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param virtual_network_name: Name of the virtual network resource. Required. + :type virtual_network_name: str + :param body: Request payload. Is either a model type or a IO type. Default value is None. + :type body: ~azure.mgmt.connectedvmware.models.VirtualNetwork or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: 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. + :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) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.connectedvmware.models.VirtualNetwork] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.VirtualNetwork] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_initial( + raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, virtual_network_name=virtual_network_name, body=body, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('VirtualNetwork', pipeline_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) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - 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 + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def get( - self, - resource_group_name, # type: str - virtual_network_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.VirtualNetwork" + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks/{virtualNetworkName}"} # type: ignore + + @distributed_trace + def get(self, resource_group_name: str, virtual_network_name: str, **kwargs: Any) -> _models.VirtualNetwork: """Gets a virtual network. Implements virtual network GET method. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param virtual_network_name: Name of the virtual network resource. + :param virtual_network_name: Name of the virtual network resource. Required. :type virtual_network_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: VirtualNetwork, or the result of cls(response) + :return: VirtualNetwork or the result of cls(response) :rtype: ~azure.mgmt.connectedvmware.models.VirtualNetwork - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - 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" - 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 = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.VirtualNetwork] + + request = build_get_request( + resource_group_name=resource_group_name, + virtual_network_name=virtual_network_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + deserialized = self._deserialize("VirtualNetwork", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks/{virtualNetworkName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks/{virtualNetworkName}"} # type: ignore + + @overload 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, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.VirtualNetwork: """Updates a virtual network. API to update certain properties of the virtual network resource. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param virtual_network_name: Name of the virtual network resource. + :param virtual_network_name: Name of the virtual network resource. Required. :type virtual_network_name: str - :param body: Resource properties to update. + :param body: Resource properties to update. Default value is None. :type body: ~azure.mgmt.connectedvmware.models.ResourcePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: VirtualNetwork, or the result of cls(response) + :return: VirtualNetwork or the result of cls(response) :rtype: ~azure.mgmt.connectedvmware.models.VirtualNetwork - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - 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.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') - - body_content_kwargs = {} # type: Dict[str, Any] - if body is not None: - body_content = self._serialize.body(body, 'ResourcePatch') + + @overload + def update( + self, + resource_group_name: str, + virtual_network_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.VirtualNetwork: + """Updates a virtual network. + + API to update certain properties of the virtual network resource. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param virtual_network_name: Name of the virtual network resource. Required. + :type virtual_network_name: str + :param body: Resource properties to update. Default value is None. + :type body: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: VirtualNetwork or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.VirtualNetwork + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + virtual_network_name: str, + body: Optional[Union[_models.ResourcePatch, IO]] = None, + **kwargs: Any + ) -> _models.VirtualNetwork: + """Updates a virtual network. + + API to update certain properties of the virtual network resource. + + :param resource_group_name: The Resource Group Name. Required. + :type resource_group_name: str + :param virtual_network_name: Name of the virtual network resource. Required. + :type virtual_network_name: str + :param body: Resource properties to update. Is either a model type or a IO type. Default value + is None. + :type body: ~azure.mgmt.connectedvmware.models.ResourcePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: VirtualNetwork or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.VirtualNetwork + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.VirtualNetwork] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - body_content = None - 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) + if body is not None: + _json = self._serialize.body(body, "ResourcePatch") + else: + _json = None + + request = build_update_request( + resource_group_name=resource_group_name, + virtual_network_name=virtual_network_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + deserialized = self._deserialize("VirtualNetwork", pipeline_response) if cls: 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 - 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 = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks/{virtualNetworkName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, virtual_network_name: str, force: Optional[bool] = None, **kwargs: Any + ) -> None: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + virtual_network_name=virtual_network_name, + subscription_id=self._config.subscription_id, + force=force, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks/{virtualNetworkName}'} # type: ignore + _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] + self, 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. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :type resource_group_name: str - :param virtual_network_name: Name of the virtual network resource. + :param virtual_network_name: Name of the virtual network resource. Required. :type virtual_network_name: str - :param force: Whether force delete was specified. + :param force: Whether force delete was specified. Default value is None. :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: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, virtual_network_name=virtual_network_name, force=force, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements 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) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - 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 + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def list( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.VirtualNetworksList"] + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks/{virtualNetworkName}"} # type: ignore + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.VirtualNetwork"]: """Implements GET virtualNetworks in a subscription. List of virtualNetworks 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 VirtualNetworksList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.connectedvmware.models.VirtualNetworksList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either VirtualNetwork or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.connectedvmware.models.VirtualNetwork] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetworksList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.VirtualNetworksList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): 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, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -493,72 +830,71 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) 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 + return ItemPaged(get_next, extract_data) - def list_by_resource_group( - self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.VirtualNetworksList"] + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks"} # type: ignore + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.VirtualNetwork"]: """Implements GET virtualNetworks in a resource group. List of virtualNetworks in a resource group. - :param resource_group_name: The Resource Group Name. + :param resource_group_name: The Resource Group Name. Required. :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.paging.ItemPaged[~azure.mgmt.connectedvmware.models.VirtualNetworksList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either VirtualNetwork or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.connectedvmware.models.VirtualNetwork] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualNetworksList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.VirtualNetworksList] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): 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( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -567,17 +903,18 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks'} # type: ignore + return ItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks"} # type: ignore