diff --git a/sdk/compute/azure-mgmt-avs/_meta.json b/sdk/compute/azure-mgmt-avs/_meta.json index 4fab822097da..cab8a687149b 100644 --- a/sdk/compute/azure-mgmt-avs/_meta.json +++ b/sdk/compute/azure-mgmt-avs/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.4.5", + "autorest": "3.9.2", "use": [ - "@autorest/python@5.8.4", - "@autorest/modelerfour@4.19.2" + "@autorest/python@6.1.11", + "@autorest/modelerfour@4.24.3" ], - "commit": "69e98508ef71f09851b2a79971d2d8e12560adc5", + "commit": "9e9c5abf08db39d2c3130bc9c079a1f22ff03903", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/vmware/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/vmware/resource-manager/readme.md --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.1.11 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", "readme": "specification/vmware/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/__init__.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/__init__.py index 45ca0700235f..554a3d3f273c 100644 --- a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/__init__.py +++ b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/__init__.py @@ -10,10 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['AVSClient'] 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__ = ["AVSClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/_avs_client.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/_avs_client.py index 26d2b7070316..44177702b58d 100644 --- a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/_avs_client.py +++ b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/_avs_client.py @@ -6,39 +6,40 @@ # 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 AVSClientConfiguration +from ._serialization import Deserializer, Serializer +from .operations import ( + AddonsOperations, + AuthorizationsOperations, + CloudLinksOperations, + ClustersOperations, + DatastoresOperations, + GlobalReachConnectionsOperations, + HcxEnterpriseSitesOperations, + LocationsOperations, + Operations, + PlacementPoliciesOperations, + PrivateCloudsOperations, + ScriptCmdletsOperations, + ScriptExecutionsOperations, + ScriptPackagesOperations, + VirtualMachinesOperations, + WorkloadNetworksOperations, +) 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 AVSClientConfiguration -from .operations import Operations -from .operations import LocationsOperations -from .operations import PrivateCloudsOperations -from .operations import ClustersOperations -from .operations import DatastoresOperations -from .operations import HcxEnterpriseSitesOperations -from .operations import AuthorizationsOperations -from .operations import GlobalReachConnectionsOperations -from .operations import WorkloadNetworksOperations -from .operations import CloudLinksOperations -from .operations import AddonsOperations -from .operations import VirtualMachinesOperations -from .operations import PlacementPoliciesOperations -from .operations import ScriptPackagesOperations -from .operations import ScriptCmdletsOperations -from .operations import ScriptExecutionsOperations -from . import models -class AVSClient(object): +class AVSClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Azure VMware Solution API. :ivar operations: Operations operations @@ -73,82 +74,83 @@ class AVSClient(object): :vartype script_cmdlets: azure.mgmt.avs.operations.ScriptCmdletsOperations :ivar script_executions: ScriptExecutionsOperations operations :vartype script_executions: azure.mgmt.avs.operations.ScriptExecutionsOperations - :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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. 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-05-01". 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 = AVSClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = AVSClientConfiguration(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.locations = LocationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.private_clouds = PrivateCloudsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.clusters = ClustersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.datastores = DatastoresOperations( - 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.locations = LocationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_clouds = PrivateCloudsOperations(self._client, self._config, self._serialize, self._deserialize) + self.clusters = ClustersOperations(self._client, self._config, self._serialize, self._deserialize) + self.datastores = DatastoresOperations(self._client, self._config, self._serialize, self._deserialize) self.hcx_enterprise_sites = HcxEnterpriseSitesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.authorizations = AuthorizationsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.authorizations = AuthorizationsOperations(self._client, self._config, self._serialize, self._deserialize) self.global_reach_connections = GlobalReachConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.workload_networks = WorkloadNetworksOperations( - self._client, self._config, self._serialize, self._deserialize) - self.cloud_links = CloudLinksOperations( - self._client, self._config, self._serialize, self._deserialize) - self.addons = AddonsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.cloud_links = CloudLinksOperations(self._client, self._config, self._serialize, self._deserialize) + self.addons = AddonsOperations(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.placement_policies = PlacementPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.script_packages = ScriptPackagesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.script_cmdlets = ScriptCmdletsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.script_packages = ScriptPackagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.script_cmdlets = ScriptCmdletsOperations(self._client, self._config, self._serialize, self._deserialize) self.script_executions = ScriptExecutionsOperations( - self._client, self._config, self._serialize, self._deserialize) + 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', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/_configuration.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/_configuration.py index 89bb55be8f92..ffec9c69b0cd 100644 --- a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/_configuration.py +++ b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/_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 AVSClientConfiguration(Configuration): +class AVSClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AVSClient. 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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-05-01". 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(AVSClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2022-05-01") # 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(AVSClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-12-01" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-avs/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-avs/{}".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/compute/azure-mgmt-avs/azure/mgmt/avs/_metadata.json b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/_metadata.json deleted file mode 100644 index 06d19041cc08..000000000000 --- a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/_metadata.json +++ /dev/null @@ -1,118 +0,0 @@ -{ - "chosen_version": "2021-12-01", - "total_api_version_list": ["2021-12-01"], - "client": { - "name": "AVSClient", - "filename": "_avs_client", - "description": "Azure VMware Solution API.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, - "azure_arm": true, - "has_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AVSClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AVSClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", - "docstring_type": "str", - "required": true - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version=None, # type: Optional[str]", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false - }, - "base_url": { - "signature": "base_url=None, # type: Optional[str]", - "description": "Service URL", - "docstring_type": "str", - "required": false - }, - "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "operations": "Operations", - "locations": "LocationsOperations", - "private_clouds": "PrivateCloudsOperations", - "clusters": "ClustersOperations", - "datastores": "DatastoresOperations", - "hcx_enterprise_sites": "HcxEnterpriseSitesOperations", - "authorizations": "AuthorizationsOperations", - "global_reach_connections": "GlobalReachConnectionsOperations", - "workload_networks": "WorkloadNetworksOperations", - "cloud_links": "CloudLinksOperations", - "addons": "AddonsOperations", - "virtual_machines": "VirtualMachinesOperations", - "placement_policies": "PlacementPoliciesOperations", - "script_packages": "ScriptPackagesOperations", - "script_cmdlets": "ScriptCmdletsOperations", - "script_executions": "ScriptExecutionsOperations" - } -} \ No newline at end of file diff --git a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/_patch.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/_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/compute/azure-mgmt-avs/azure/mgmt/avs/_serialization.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/_serialization.py new file mode 100644 index 000000000000..7c1dedb5133d --- /dev/null +++ b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/_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.debug( + "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/compute/azure-mgmt-avs/azure/mgmt/avs/_vendor.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/_vendor.py new file mode 100644 index 000000000000..9aad73fc743e --- /dev/null +++ b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/_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/compute/azure-mgmt-avs/azure/mgmt/avs/_version.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/_version.py index 364f3c906cf9..e5754a47ce68 100644 --- a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/_version.py +++ b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "7.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/__init__.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/__init__.py index 7cbca6ac278a..a88218ea3cea 100644 --- a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/__init__.py +++ b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/__init__.py @@ -7,4 +7,15 @@ # -------------------------------------------------------------------------- from ._avs_client import AVSClient -__all__ = ['AVSClient'] + +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__ = ["AVSClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/_avs_client.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/_avs_client.py index 05eb5e11d5ee..29dd78004ef9 100644 --- a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/_avs_client.py +++ b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/_avs_client.py @@ -6,37 +6,40 @@ # 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 AVSClientConfiguration +from .operations import ( + AddonsOperations, + AuthorizationsOperations, + CloudLinksOperations, + ClustersOperations, + DatastoresOperations, + GlobalReachConnectionsOperations, + HcxEnterpriseSitesOperations, + LocationsOperations, + Operations, + PlacementPoliciesOperations, + PrivateCloudsOperations, + ScriptCmdletsOperations, + ScriptExecutionsOperations, + ScriptPackagesOperations, + VirtualMachinesOperations, + WorkloadNetworksOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import AVSClientConfiguration -from .operations import Operations -from .operations import LocationsOperations -from .operations import PrivateCloudsOperations -from .operations import ClustersOperations -from .operations import DatastoresOperations -from .operations import HcxEnterpriseSitesOperations -from .operations import AuthorizationsOperations -from .operations import GlobalReachConnectionsOperations -from .operations import WorkloadNetworksOperations -from .operations import CloudLinksOperations -from .operations import AddonsOperations -from .operations import VirtualMachinesOperations -from .operations import PlacementPoliciesOperations -from .operations import ScriptPackagesOperations -from .operations import ScriptCmdletsOperations -from .operations import ScriptExecutionsOperations -from .. import models - -class AVSClient(object): +class AVSClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Azure VMware Solution API. :ivar operations: Operations operations @@ -54,7 +57,8 @@ class AVSClient(object): :ivar authorizations: AuthorizationsOperations operations :vartype authorizations: azure.mgmt.avs.aio.operations.AuthorizationsOperations :ivar global_reach_connections: GlobalReachConnectionsOperations operations - :vartype global_reach_connections: azure.mgmt.avs.aio.operations.GlobalReachConnectionsOperations + :vartype global_reach_connections: + azure.mgmt.avs.aio.operations.GlobalReachConnectionsOperations :ivar workload_networks: WorkloadNetworksOperations operations :vartype workload_networks: azure.mgmt.avs.aio.operations.WorkloadNetworksOperations :ivar cloud_links: CloudLinksOperations operations @@ -71,80 +75,83 @@ class AVSClient(object): :vartype script_cmdlets: azure.mgmt.avs.aio.operations.ScriptCmdletsOperations :ivar script_executions: ScriptExecutionsOperations operations :vartype script_executions: azure.mgmt.avs.aio.operations.ScriptExecutionsOperations - :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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. 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-05-01". 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 = AVSClientConfiguration(credential, subscription_id, **kwargs) + self._config = AVSClientConfiguration(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.locations = LocationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.private_clouds = PrivateCloudsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.clusters = ClustersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.datastores = DatastoresOperations( - 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.locations = LocationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_clouds = PrivateCloudsOperations(self._client, self._config, self._serialize, self._deserialize) + self.clusters = ClustersOperations(self._client, self._config, self._serialize, self._deserialize) + self.datastores = DatastoresOperations(self._client, self._config, self._serialize, self._deserialize) self.hcx_enterprise_sites = HcxEnterpriseSitesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.authorizations = AuthorizationsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.authorizations = AuthorizationsOperations(self._client, self._config, self._serialize, self._deserialize) self.global_reach_connections = GlobalReachConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.workload_networks = WorkloadNetworksOperations( - self._client, self._config, self._serialize, self._deserialize) - self.cloud_links = CloudLinksOperations( - self._client, self._config, self._serialize, self._deserialize) - self.addons = AddonsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.cloud_links = CloudLinksOperations(self._client, self._config, self._serialize, self._deserialize) + self.addons = AddonsOperations(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.placement_policies = PlacementPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.script_packages = ScriptPackagesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.script_cmdlets = ScriptCmdletsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.script_packages = ScriptPackagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.script_cmdlets = ScriptCmdletsOperations(self._client, self._config, self._serialize, self._deserialize) self.script_executions = ScriptExecutionsOperations( - self._client, self._config, self._serialize, self._deserialize) + 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', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/_configuration.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/_configuration.py index 7337376a2a03..ad6419e619fd 100644 --- a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/_configuration.py +++ b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/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 AVSClientConfiguration(Configuration): +class AVSClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AVSClient. 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 ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-05-01". 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(AVSClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2022-05-01") # 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(AVSClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-12-01" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-avs/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-avs/{}".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/compute/azure-mgmt-avs/azure/mgmt/avs/aio/_patch.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/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/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/__init__.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/__init__.py index d60908801950..f7d8649d903a 100644 --- a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/__init__.py +++ b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/__init__.py @@ -23,21 +23,27 @@ from ._script_cmdlets_operations import ScriptCmdletsOperations from ._script_executions_operations import ScriptExecutionsOperations +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', - 'LocationsOperations', - 'PrivateCloudsOperations', - 'ClustersOperations', - 'DatastoresOperations', - 'HcxEnterpriseSitesOperations', - 'AuthorizationsOperations', - 'GlobalReachConnectionsOperations', - 'WorkloadNetworksOperations', - 'CloudLinksOperations', - 'AddonsOperations', - 'VirtualMachinesOperations', - 'PlacementPoliciesOperations', - 'ScriptPackagesOperations', - 'ScriptCmdletsOperations', - 'ScriptExecutionsOperations', + "Operations", + "LocationsOperations", + "PrivateCloudsOperations", + "ClustersOperations", + "DatastoresOperations", + "HcxEnterpriseSitesOperations", + "AuthorizationsOperations", + "GlobalReachConnectionsOperations", + "WorkloadNetworksOperations", + "CloudLinksOperations", + "AddonsOperations", + "VirtualMachinesOperations", + "PlacementPoliciesOperations", + "ScriptPackagesOperations", + "ScriptCmdletsOperations", + "ScriptExecutionsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_addons_operations.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_addons_operations.py index e28ecff2dc74..5eaaec920a97 100644 --- a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_addons_operations.py +++ b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_addons_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,98 +6,125 @@ # 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 +import urllib.parse 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, + ResourceNotModifiedError, + 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._addons_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AddonsOperations: - """AddonsOperations 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 AddonsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.avs.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.avs.aio.AVSClient`'s + :attr:`addons` 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, - resource_group_name: str, - private_cloud_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.AddonList"]: + @distributed_trace + def list(self, resource_group_name: str, private_cloud_name: str, **kwargs: Any) -> AsyncIterable["_models.Addon"]: """List addons in a private cloud. List addons in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AddonList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.avs.models.AddonList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Addon or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.avs.models.Addon] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AddonList"] + _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.AddonList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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('AddonList', pipeline_response) + deserialized = self._deserialize("AddonList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -105,7 +133,9 @@ 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]: @@ -114,116 +144,127 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/addons'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/addons"} # type: ignore + + @distributed_trace_async async def get( - self, - resource_group_name: str, - private_cloud_name: str, - addon_name: str, - **kwargs: Any - ) -> "_models.Addon": + self, resource_group_name: str, private_cloud_name: str, addon_name: str, **kwargs: Any + ) -> _models.Addon: """Get an addon by name in a private cloud. Get an addon by name in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param addon_name: Name of the addon for the private cloud. + :param addon_name: Name of the addon for the private cloud. Required. :type addon_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Addon, or the result of cls(response) + :return: Addon or the result of cls(response) :rtype: ~azure.mgmt.avs.models.Addon - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Addon"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'addonName': self._serialize.url("addon_name", addon_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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.Addon] + + request = build_get_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + addon_name=addon_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 - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Addon', pipeline_response) + deserialized = self._deserialize("Addon", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/addons/{addonName}'} # type: ignore + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/addons/{addonName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, private_cloud_name: str, addon_name: str, - addon: "_models.Addon", + addon: Union[_models.Addon, IO], **kwargs: Any - ) -> "_models.Addon": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Addon"] + ) -> _models.Addon: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'addonName': self._serialize.url("addon_name", addon_name, 'str'), - } - url = self._client.format_url(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(addon, 'Addon') - 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) + 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.Addon] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(addon, (IO, bytes)): + _content = addon + else: + _json = self._serialize.body(addon, "Addon") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + addon_name=addon_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]: @@ -231,130 +272,216 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Addon', pipeline_response) + deserialized = self._deserialize("Addon", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Addon', pipeline_response) + deserialized = self._deserialize("Addon", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/addons/{addonName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/addons/{addonName}"} # type: ignore + + @overload async def begin_create_or_update( self, resource_group_name: str, private_cloud_name: str, addon_name: str, - addon: "_models.Addon", + addon: _models.Addon, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.Addon"]: + ) -> AsyncLROPoller[_models.Addon]: """Create or update a addon in a private cloud. Create or update a addon in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: The name of the private cloud. + :param private_cloud_name: The name of the private cloud. Required. :type private_cloud_name: str - :param addon_name: Name of the addon for the private cloud. + :param addon_name: Name of the addon for the private cloud. Required. :type addon_name: str - :param addon: A addon in the private cloud. + :param addon: A addon in the private cloud. Required. :type addon: ~azure.mgmt.avs.models.Addon + :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 Addon or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.Addon] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Addon"] - 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, + private_cloud_name: str, + addon_name: str, + addon: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Addon]: + """Create or update a addon in a private cloud. + + Create or update a addon in a private cloud. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: The name of the private cloud. Required. + :type private_cloud_name: str + :param addon_name: Name of the addon for the private cloud. Required. + :type addon_name: str + :param addon: A addon in the private cloud. Required. + :type addon: 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 Addon or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.Addon] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + private_cloud_name: str, + addon_name: str, + addon: Union[_models.Addon, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.Addon]: + """Create or update a addon in a private cloud. + + Create or update a addon in a private cloud. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: The name of the private cloud. Required. + :type private_cloud_name: str + :param addon_name: Name of the addon for the private cloud. Required. + :type addon_name: str + :param addon: A addon in the private cloud. Is either a model type or a IO type. Required. + :type addon: ~azure.mgmt.avs.models.Addon 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 Addon or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.Addon] + :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.Addon] + 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, private_cloud_name=private_cloud_name, addon_name=addon_name, addon=addon, - 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('Addon', pipeline_response) - + deserialized = self._deserialize("Addon", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'addonName': self._serialize.url("addon_name", addon_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_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/addons/{addonName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - async def _delete_initial( - self, - resource_group_name: str, - private_cloud_name: str, - addon_name: str, - **kwargs: Any + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/addons/{addonName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, private_cloud_name: str, addon_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'addonName': self._serialize.url("addon_name", addon_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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, + private_cloud_name=private_cloud_name, + addon_name=addon_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 - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -364,75 +491,73 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/addons/{addonName}'} # type: ignore + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/addons/{addonName}"} # type: ignore + @distributed_trace_async async def begin_delete( - self, - resource_group_name: str, - private_cloud_name: str, - addon_name: str, - **kwargs: Any + self, resource_group_name: str, private_cloud_name: str, addon_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete a addon in a private cloud. Delete a addon in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param addon_name: Name of the addon for the private cloud. + :param addon_name: Name of the addon for the private cloud. Required. :type addon_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, private_cloud_name=private_cloud_name, addon_name=addon_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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'addonName': self._serialize.url("addon_name", addon_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.AVS/privateClouds/{privateCloudName}/addons/{addonName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/addons/{addonName}"} # type: ignore diff --git a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_authorizations_operations.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_authorizations_operations.py index c4a94c95e750..89dd923e810a 100644 --- a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_authorizations_operations.py +++ b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_authorizations_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,98 +6,129 @@ # 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 +import urllib.parse 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, + ResourceNotModifiedError, + 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._authorizations_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AuthorizationsOperations: - """AuthorizationsOperations 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 AuthorizationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.avs.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.avs.aio.AVSClient`'s + :attr:`authorizations` 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") + @distributed_trace def list( - self, - resource_group_name: str, - private_cloud_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ExpressRouteAuthorizationList"]: + self, resource_group_name: str, private_cloud_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ExpressRouteAuthorization"]: """List ExpressRoute Circuit Authorizations in a private cloud. List ExpressRoute Circuit Authorizations in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExpressRouteAuthorizationList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.avs.models.ExpressRouteAuthorizationList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ExpressRouteAuthorization or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.avs.models.ExpressRouteAuthorization] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExpressRouteAuthorizationList"] + _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.ExpressRouteAuthorizationList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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('ExpressRouteAuthorizationList', pipeline_response) + deserialized = self._deserialize("ExpressRouteAuthorizationList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -105,7 +137,9 @@ 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]: @@ -114,116 +148,128 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/authorizations'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/authorizations"} # type: ignore + + @distributed_trace_async async def get( - self, - resource_group_name: str, - private_cloud_name: str, - authorization_name: str, - **kwargs: Any - ) -> "_models.ExpressRouteAuthorization": + self, resource_group_name: str, private_cloud_name: str, authorization_name: str, **kwargs: Any + ) -> _models.ExpressRouteAuthorization: """Get an ExpressRoute Circuit Authorization by name in a private cloud. Get an ExpressRoute Circuit Authorization by name in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :param authorization_name: Name of the ExpressRoute Circuit Authorization in the private cloud. + Required. :type authorization_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ExpressRouteAuthorization, or the result of cls(response) + :return: ExpressRouteAuthorization or the result of cls(response) :rtype: ~azure.mgmt.avs.models.ExpressRouteAuthorization - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExpressRouteAuthorization"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'authorizationName': self._serialize.url("authorization_name", authorization_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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.ExpressRouteAuthorization] + + request = build_get_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + authorization_name=authorization_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 - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ExpressRouteAuthorization', pipeline_response) + deserialized = self._deserialize("ExpressRouteAuthorization", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/authorizations/{authorizationName}'} # type: ignore + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/authorizations/{authorizationName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, private_cloud_name: str, authorization_name: str, - authorization: "_models.ExpressRouteAuthorization", + authorization: Union[_models.ExpressRouteAuthorization, IO], **kwargs: Any - ) -> "_models.ExpressRouteAuthorization": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExpressRouteAuthorization"] + ) -> _models.ExpressRouteAuthorization: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'authorizationName': self._serialize.url("authorization_name", authorization_name, 'str'), - } - url = self._client.format_url(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(authorization, 'ExpressRouteAuthorization') - 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) + 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.ExpressRouteAuthorization] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(authorization, (IO, bytes)): + _content = authorization + else: + _json = self._serialize.body(authorization, "ExpressRouteAuthorization") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + authorization_name=authorization_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]: @@ -231,130 +277,223 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ExpressRouteAuthorization', pipeline_response) + deserialized = self._deserialize("ExpressRouteAuthorization", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ExpressRouteAuthorization', pipeline_response) + deserialized = self._deserialize("ExpressRouteAuthorization", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/authorizations/{authorizationName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/authorizations/{authorizationName}"} # type: ignore + + @overload async def begin_create_or_update( self, resource_group_name: str, private_cloud_name: str, authorization_name: str, - authorization: "_models.ExpressRouteAuthorization", + authorization: _models.ExpressRouteAuthorization, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.ExpressRouteAuthorization"]: + ) -> AsyncLROPoller[_models.ExpressRouteAuthorization]: """Create or update an ExpressRoute Circuit Authorization in a private cloud. Create or update an ExpressRoute Circuit Authorization in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: The name of the private cloud. + :param private_cloud_name: The name of the private cloud. Required. :type private_cloud_name: str :param authorization_name: Name of the ExpressRoute Circuit Authorization in the private cloud. + Required. :type authorization_name: str - :param authorization: An ExpressRoute Circuit Authorization. + :param authorization: An ExpressRoute Circuit Authorization. Required. :type authorization: ~azure.mgmt.avs.models.ExpressRouteAuthorization + :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 ExpressRouteAuthorization 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 ExpressRouteAuthorization or the + result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.ExpressRouteAuthorization] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExpressRouteAuthorization"] - 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, + private_cloud_name: str, + authorization_name: str, + authorization: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ExpressRouteAuthorization]: + """Create or update an ExpressRoute Circuit Authorization in a private cloud. + + Create or update an ExpressRoute Circuit Authorization in a private cloud. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: The name of the private cloud. Required. + :type private_cloud_name: str + :param authorization_name: Name of the ExpressRoute Circuit Authorization in the private cloud. + Required. + :type authorization_name: str + :param authorization: An ExpressRoute Circuit Authorization. Required. + :type authorization: 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 ExpressRouteAuthorization or the + result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.ExpressRouteAuthorization] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + private_cloud_name: str, + authorization_name: str, + authorization: Union[_models.ExpressRouteAuthorization, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ExpressRouteAuthorization]: + """Create or update an ExpressRoute Circuit Authorization in a private cloud. + + Create or update an ExpressRoute Circuit Authorization in a private cloud. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: The name of the private cloud. Required. + :type private_cloud_name: str + :param authorization_name: Name of the ExpressRoute Circuit Authorization in the private cloud. + Required. + :type authorization_name: str + :param authorization: An ExpressRoute Circuit Authorization. Is either a model type or a IO + type. Required. + :type authorization: ~azure.mgmt.avs.models.ExpressRouteAuthorization 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 ExpressRouteAuthorization or the + result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.ExpressRouteAuthorization] + :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.ExpressRouteAuthorization] + 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, private_cloud_name=private_cloud_name, authorization_name=authorization_name, authorization=authorization, - 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('ExpressRouteAuthorization', pipeline_response) - + deserialized = self._deserialize("ExpressRouteAuthorization", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'authorizationName': self._serialize.url("authorization_name", authorization_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_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/authorizations/{authorizationName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - async def _delete_initial( - self, - resource_group_name: str, - private_cloud_name: str, - authorization_name: str, - **kwargs: Any + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/authorizations/{authorizationName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, private_cloud_name: str, authorization_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'authorizationName': self._serialize.url("authorization_name", authorization_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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, + private_cloud_name=private_cloud_name, + authorization_name=authorization_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 - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -364,75 +503,74 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/authorizations/{authorizationName}'} # type: ignore + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/authorizations/{authorizationName}"} # type: ignore + @distributed_trace_async async def begin_delete( - self, - resource_group_name: str, - private_cloud_name: str, - authorization_name: str, - **kwargs: Any + self, resource_group_name: str, private_cloud_name: str, authorization_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete an ExpressRoute Circuit Authorization in a private cloud. Delete an ExpressRoute Circuit Authorization in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :param authorization_name: Name of the ExpressRoute Circuit Authorization in the private cloud. + Required. :type authorization_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, private_cloud_name=private_cloud_name, authorization_name=authorization_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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'authorizationName': self._serialize.url("authorization_name", authorization_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.AVS/privateClouds/{privateCloudName}/authorizations/{authorizationName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/authorizations/{authorizationName}"} # type: ignore diff --git a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_cloud_links_operations.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_cloud_links_operations.py index 42f494bd9cbe..0ae5cf596318 100644 --- a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_cloud_links_operations.py +++ b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_cloud_links_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,98 +6,127 @@ # 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 +import urllib.parse 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, + ResourceNotModifiedError, + 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._cloud_links_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class CloudLinksOperations: - """CloudLinksOperations 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 CloudLinksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.avs.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.avs.aio.AVSClient`'s + :attr:`cloud_links` 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") + @distributed_trace def list( - self, - resource_group_name: str, - private_cloud_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.CloudLinkList"]: + self, resource_group_name: str, private_cloud_name: str, **kwargs: Any + ) -> AsyncIterable["_models.CloudLink"]: """List cloud link in a private cloud. List cloud link in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CloudLinkList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.avs.models.CloudLinkList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either CloudLink or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.avs.models.CloudLink] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudLinkList"] + _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.CloudLinkList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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('CloudLinkList', pipeline_response) + deserialized = self._deserialize("CloudLinkList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -105,7 +135,9 @@ 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]: @@ -114,116 +146,127 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/cloudLinks'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/cloudLinks"} # type: ignore + + @distributed_trace_async async def get( - self, - resource_group_name: str, - private_cloud_name: str, - cloud_link_name: str, - **kwargs: Any - ) -> "_models.CloudLink": + self, resource_group_name: str, private_cloud_name: str, cloud_link_name: str, **kwargs: Any + ) -> _models.CloudLink: """Get an cloud link by name in a private cloud. Get an cloud link by name in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param cloud_link_name: Name of the cloud link resource. + :param cloud_link_name: Name of the cloud link resource. Required. :type cloud_link_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CloudLink, or the result of cls(response) + :return: CloudLink or the result of cls(response) :rtype: ~azure.mgmt.avs.models.CloudLink - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudLink"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'cloudLinkName': self._serialize.url("cloud_link_name", cloud_link_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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.CloudLink] + + request = build_get_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + cloud_link_name=cloud_link_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 - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CloudLink', pipeline_response) + deserialized = self._deserialize("CloudLink", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/cloudLinks/{cloudLinkName}'} # type: ignore + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/cloudLinks/{cloudLinkName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, private_cloud_name: str, cloud_link_name: str, - cloud_link: "_models.CloudLink", + cloud_link: Union[_models.CloudLink, IO], **kwargs: Any - ) -> "_models.CloudLink": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudLink"] + ) -> _models.CloudLink: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'cloudLinkName': self._serialize.url("cloud_link_name", cloud_link_name, 'str'), - } - url = self._client.format_url(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(cloud_link, 'CloudLink') - 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) + 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.CloudLink] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(cloud_link, (IO, bytes)): + _content = cloud_link + else: + _json = self._serialize.body(cloud_link, "CloudLink") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + cloud_link_name=cloud_link_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]: @@ -231,130 +274,220 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CloudLink', pipeline_response) + deserialized = self._deserialize("CloudLink", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CloudLink', pipeline_response) + deserialized = self._deserialize("CloudLink", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/cloudLinks/{cloudLinkName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/cloudLinks/{cloudLinkName}"} # type: ignore + + @overload async def begin_create_or_update( self, resource_group_name: str, private_cloud_name: str, cloud_link_name: str, - cloud_link: "_models.CloudLink", + cloud_link: _models.CloudLink, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.CloudLink"]: + ) -> AsyncLROPoller[_models.CloudLink]: """Create or update a cloud link in a private cloud. Create or update a cloud link in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: The name of the private cloud. + :param private_cloud_name: The name of the private cloud. Required. :type private_cloud_name: str - :param cloud_link_name: Name of the cloud link resource. + :param cloud_link_name: Name of the cloud link resource. Required. :type cloud_link_name: str - :param cloud_link: A cloud link in the private cloud. + :param cloud_link: A cloud link in the private cloud. Required. :type cloud_link: ~azure.mgmt.avs.models.CloudLink + :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 CloudLink 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 CloudLink or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.CloudLink] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudLink"] - 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, + private_cloud_name: str, + cloud_link_name: str, + cloud_link: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CloudLink]: + """Create or update a cloud link in a private cloud. + + Create or update a cloud link in a private cloud. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: The name of the private cloud. Required. + :type private_cloud_name: str + :param cloud_link_name: Name of the cloud link resource. Required. + :type cloud_link_name: str + :param cloud_link: A cloud link in the private cloud. Required. + :type cloud_link: 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 CloudLink or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.CloudLink] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + private_cloud_name: str, + cloud_link_name: str, + cloud_link: Union[_models.CloudLink, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.CloudLink]: + """Create or update a cloud link in a private cloud. + + Create or update a cloud link in a private cloud. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: The name of the private cloud. Required. + :type private_cloud_name: str + :param cloud_link_name: Name of the cloud link resource. Required. + :type cloud_link_name: str + :param cloud_link: A cloud link in the private cloud. Is either a model type or a IO type. + Required. + :type cloud_link: ~azure.mgmt.avs.models.CloudLink 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 CloudLink or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.CloudLink] + :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.CloudLink] + 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, private_cloud_name=private_cloud_name, cloud_link_name=cloud_link_name, cloud_link=cloud_link, - 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('CloudLink', pipeline_response) - + deserialized = self._deserialize("CloudLink", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'cloudLinkName': self._serialize.url("cloud_link_name", cloud_link_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_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/cloudLinks/{cloudLinkName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - async def _delete_initial( - self, - resource_group_name: str, - private_cloud_name: str, - cloud_link_name: str, - **kwargs: Any + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/cloudLinks/{cloudLinkName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, private_cloud_name: str, cloud_link_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 = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'cloudLinkName': self._serialize.url("cloud_link_name", cloud_link_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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, + private_cloud_name=private_cloud_name, + cloud_link_name=cloud_link_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 - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -364,75 +497,73 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/cloudLinks/{cloudLinkName}'} # type: ignore + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/cloudLinks/{cloudLinkName}"} # type: ignore + @distributed_trace_async async def begin_delete( - self, - resource_group_name: str, - private_cloud_name: str, - cloud_link_name: str, - **kwargs: Any + self, resource_group_name: str, private_cloud_name: str, cloud_link_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete a cloud link in a private cloud. Delete a cloud link in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param cloud_link_name: Name of the cloud link resource. + :param cloud_link_name: Name of the cloud link resource. Required. :type cloud_link_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, private_cloud_name=private_cloud_name, cloud_link_name=cloud_link_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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'cloudLinkName': self._serialize.url("cloud_link_name", cloud_link_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.AVS/privateClouds/{privateCloudName}/cloudLinks/{cloudLinkName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/cloudLinks/{cloudLinkName}"} # type: ignore diff --git a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_clusters_operations.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_clusters_operations.py index 07eb94fe5269..510fe54f4e52 100644 --- a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_clusters_operations.py +++ b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/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,98 +6,129 @@ # 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 +import urllib.parse 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, + ResourceNotModifiedError, + 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_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_list_zones_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.avs.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.avs.aio.AVSClient`'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") + @distributed_trace def list( - self, - resource_group_name: str, - private_cloud_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ClusterList"]: + self, resource_group_name: str, private_cloud_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Cluster"]: """List clusters in a private cloud. List clusters in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ClusterList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.avs.models.ClusterList] - :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.avs.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClusterList"] + _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.ClusterList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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('ClusterList', pipeline_response) + deserialized = self._deserialize("ClusterList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -105,7 +137,9 @@ 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]: @@ -114,116 +148,127 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters"} # type: ignore + + @distributed_trace_async async def get( - self, - resource_group_name: str, - private_cloud_name: str, - cluster_name: str, - **kwargs: Any - ) -> "_models.Cluster": + self, resource_group_name: str, private_cloud_name: str, cluster_name: str, **kwargs: Any + ) -> _models.Cluster: """Get a cluster by name in a private cloud. Get a cluster by name in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param cluster_name: Name of the cluster in the private cloud. + :param cluster_name: Name of the cluster in the private cloud. 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.avs.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 = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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, + private_cloud_name=private_cloud_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 - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, 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.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}'} # type: ignore + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, private_cloud_name: str, cluster_name: str, - cluster: "_models.Cluster", + cluster: Union[_models.Cluster, IO], **kwargs: Any - ) -> "_models.Cluster": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Cluster"] + ) -> _models.Cluster: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(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(cluster, 'Cluster') - 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) + 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(cluster, (IO, bytes)): + _content = cluster + else: + _json = self._serialize.body(cluster, "Cluster") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_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_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]: @@ -231,136 +276,236 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, 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_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}"} # type: ignore + + @overload async def begin_create_or_update( self, resource_group_name: str, private_cloud_name: str, cluster_name: str, - cluster: "_models.Cluster", + cluster: _models.Cluster, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.Cluster"]: + ) -> AsyncLROPoller[_models.Cluster]: """Create or update a cluster in a private cloud. Create or update a cluster in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: The name of the private cloud. + :param private_cloud_name: The name of the private cloud. Required. :type private_cloud_name: str - :param cluster_name: Name of the cluster in the private cloud. + :param cluster_name: Name of the cluster in the private cloud. Required. :type cluster_name: str - :param cluster: A cluster in the private cloud. + :param cluster: A cluster in the private cloud. Required. :type cluster: ~azure.mgmt.avs.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.avs.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_or_update( + self, + resource_group_name: str, + private_cloud_name: str, + cluster_name: str, + cluster: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Cluster]: + """Create or update a cluster in a private cloud. + + Create or update a cluster in a private cloud. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: The name of the private cloud. Required. + :type private_cloud_name: str + :param cluster_name: Name of the cluster in the private cloud. Required. + :type cluster_name: str + :param cluster: A cluster in the private cloud. Required. + :type cluster: 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.avs.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + private_cloud_name: str, + cluster_name: str, + cluster: Union[_models.Cluster, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.Cluster]: + """Create or update a cluster in a private cloud. + + Create or update a cluster in a private cloud. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: The name of the private cloud. Required. + :type private_cloud_name: str + :param cluster_name: Name of the cluster in the private cloud. Required. + :type cluster_name: str + :param cluster: A cluster in the private cloud. Is either a model type or a IO type. Required. + :type cluster: ~azure.mgmt.avs.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.avs.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_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, private_cloud_name=private_cloud_name, cluster_name=cluster_name, cluster=cluster, - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_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_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}'} # 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.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}"} # type: ignore async def _update_initial( self, resource_group_name: str, private_cloud_name: str, cluster_name: str, - cluster_update: "_models.ClusterUpdate", + cluster_update: Union[_models.ClusterUpdate, IO], **kwargs: Any - ) -> "_models.Cluster": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Cluster"] + ) -> _models.Cluster: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(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(cluster_update, 'ClusterUpdate') - 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) + 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(cluster_update, (IO, bytes)): + _content = cluster_update + else: + _json = self._serialize.body(cluster_update, "ClusterUpdate") + + request = build_update_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_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_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]: @@ -368,130 +513,220 @@ async def _update_initial( raise HttpResponseError(response=response, 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 - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}'} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}"} # type: ignore + + @overload async def begin_update( self, resource_group_name: str, private_cloud_name: str, cluster_name: str, - cluster_update: "_models.ClusterUpdate", + cluster_update: _models.ClusterUpdate, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.Cluster"]: + ) -> AsyncLROPoller[_models.Cluster]: """Update a cluster in a private cloud. Update a cluster in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param cluster_name: Name of the cluster in the private cloud. + :param cluster_name: Name of the cluster in the private cloud. Required. :type cluster_name: str - :param cluster_update: The cluster properties to be updated. + :param cluster_update: The cluster properties to be updated. Required. :type cluster_update: ~azure.mgmt.avs.models.ClusterUpdate + :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.avs.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_update( + self, + resource_group_name: str, + private_cloud_name: str, + cluster_name: str, + cluster_update: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Cluster]: + """Update a cluster in a private cloud. + + Update a cluster in a private cloud. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param cluster_name: Name of the cluster in the private cloud. Required. + :type cluster_name: str + :param cluster_update: The cluster properties to be updated. Required. + :type cluster_update: 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.avs.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + private_cloud_name: str, + cluster_name: str, + cluster_update: Union[_models.ClusterUpdate, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.Cluster]: + """Update a cluster in a private cloud. + + Update a cluster in a private cloud. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param cluster_name: Name of the cluster in the private cloud. Required. + :type cluster_name: str + :param cluster_update: The cluster properties to be updated. Is either a model type or a IO + type. Required. + :type cluster_update: ~azure.mgmt.avs.models.ClusterUpdate 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.avs.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._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, private_cloud_name=private_cloud_name, cluster_name=cluster_name, cluster_update=cluster_update, - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_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_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - async def _delete_initial( - self, - resource_group_name: str, - private_cloud_name: str, - cluster_name: str, - **kwargs: Any + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, private_cloud_name: str, cluster_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_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') + 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, + private_cloud_name=private_cloud_name, + cluster_name=cluster_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 - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -501,75 +736,139 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}'} # type: ignore + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}"} # type: ignore + @distributed_trace_async async def begin_delete( - self, - resource_group_name: str, - private_cloud_name: str, - cluster_name: str, - **kwargs: Any + self, resource_group_name: str, private_cloud_name: str, cluster_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete a cluster in a private cloud. Delete a cluster in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param cluster_name: Name of the cluster in the private cloud. + :param cluster_name: Name of the cluster in the private cloud. Required. :type cluster_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, private_cloud_name=private_cloud_name, cluster_name=cluster_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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_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.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}"} # type: ignore + + @distributed_trace_async + async def list_zones( + self, resource_group_name: str, private_cloud_name: str, cluster_name: str, **kwargs: Any + ) -> _models.ClusterZoneList: + """List hosts by zone in a cluster. + + List hosts by zone in a cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param cluster_name: Name of the cluster in the private cloud. Required. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ClusterZoneList or the result of cls(response) + :rtype: ~azure.mgmt.avs.models.ClusterZoneList + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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.ClusterZoneList] + + request = build_list_zones_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_zones.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ClusterZoneList", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_zones.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/listZones"} # type: ignore diff --git a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_datastores_operations.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_datastores_operations.py index 45419a8075ca..55655ddfd666 100644 --- a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_datastores_operations.py +++ b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/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,102 +6,130 @@ # 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 +import urllib.parse 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, + ResourceNotModifiedError, + 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_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -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.avs.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.avs.aio.AVSClient`'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") + @distributed_trace def list( - self, - resource_group_name: str, - private_cloud_name: str, - cluster_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.DatastoreList"]: + self, resource_group_name: str, private_cloud_name: str, cluster_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Datastore"]: """List datastores in a private cloud cluster. List datastores in a private cloud cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param cluster_name: Name of the cluster in the private cloud. + :param cluster_name: Name of the cluster in the private cloud. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DatastoreList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.avs.models.DatastoreList] - :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.avs.models.Datastore] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DatastoreList"] + _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.DatastoreList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + cluster_name=cluster_name, + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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('DatastoreList', pipeline_response) + deserialized = self._deserialize("DatastoreList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -109,7 +138,9 @@ 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]: @@ -118,78 +149,78 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/datastores'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/datastores"} # type: ignore + + @distributed_trace_async async def get( - self, - resource_group_name: str, - private_cloud_name: str, - cluster_name: str, - datastore_name: str, - **kwargs: Any - ) -> "_models.Datastore": + self, resource_group_name: str, private_cloud_name: str, cluster_name: str, datastore_name: str, **kwargs: Any + ) -> _models.Datastore: """Get a datastore in a private cloud cluster. Get a datastore in a private cloud cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param cluster_name: Name of the cluster in the private cloud. + :param cluster_name: Name of the cluster in the private cloud. Required. :type cluster_name: str - :param datastore_name: Name of the datastore in the private cloud cluster. + :param datastore_name: Name of the datastore in the private cloud cluster. 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.avs.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 + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_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') + 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, + private_cloud_name=private_cloud_name, + cluster_name=cluster_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 - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, 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.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/datastores/{datastoreName}'} # type: ignore + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/datastores/{datastoreName}"} # type: ignore async def _create_or_update_initial( self, @@ -197,43 +228,53 @@ async def _create_or_update_initial( private_cloud_name: str, cluster_name: str, datastore_name: str, - datastore: "_models.Datastore", + datastore: Union[_models.Datastore, IO], **kwargs: Any - ) -> "_models.Datastore": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Datastore"] + ) -> _models.Datastore: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_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] - body_content = self._serialize.body(datastore, 'Datastore') - 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) + 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(datastore, (IO, bytes)): + _content = datastore + else: + _json = self._serialize.body(datastore, "Datastore") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + cluster_name=cluster_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_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]: @@ -241,137 +282,231 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, 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_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/datastores/{datastoreName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/datastores/{datastoreName}"} # type: ignore + + @overload async def begin_create_or_update( self, resource_group_name: str, private_cloud_name: str, cluster_name: str, datastore_name: str, - datastore: "_models.Datastore", + datastore: _models.Datastore, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.Datastore"]: + ) -> AsyncLROPoller[_models.Datastore]: """Create or update a datastore in a private cloud cluster. Create or update a datastore in a private cloud cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param cluster_name: Name of the cluster in the private cloud. + :param cluster_name: Name of the cluster in the private cloud. Required. :type cluster_name: str - :param datastore_name: Name of the datastore in the private cloud cluster. + :param datastore_name: Name of the datastore in the private cloud cluster. Required. :type datastore_name: str - :param datastore: A datastore in a private cloud cluster. + :param datastore: A datastore in a private cloud cluster. Required. :type datastore: ~azure.mgmt.avs.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.avs.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_or_update( + self, + resource_group_name: str, + private_cloud_name: str, + cluster_name: str, + datastore_name: str, + datastore: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Datastore]: + """Create or update a datastore in a private cloud cluster. + + Create or update a datastore in a private cloud cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param cluster_name: Name of the cluster in the private cloud. Required. + :type cluster_name: str + :param datastore_name: Name of the datastore in the private cloud cluster. Required. + :type datastore_name: str + :param datastore: A datastore in a private cloud cluster. Required. + :type datastore: 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.avs.models.Datastore] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + private_cloud_name: str, + cluster_name: str, + datastore_name: str, + datastore: Union[_models.Datastore, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.Datastore]: + """Create or update a datastore in a private cloud cluster. + + Create or update a datastore in a private cloud cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param cluster_name: Name of the cluster in the private cloud. Required. + :type cluster_name: str + :param datastore_name: Name of the datastore in the private cloud cluster. Required. + :type datastore_name: str + :param datastore: A datastore in a private cloud cluster. Is either a model type or a IO type. + Required. + :type datastore: ~azure.mgmt.avs.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.avs.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_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, private_cloud_name=private_cloud_name, cluster_name=cluster_name, datastore_name=datastore_name, datastore=datastore, - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_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_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/datastores/{datastoreName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - async def _delete_initial( - self, - resource_group_name: str, - private_cloud_name: str, - cluster_name: str, - datastore_name: str, - **kwargs: Any + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/datastores/{datastoreName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, private_cloud_name: str, cluster_name: str, datastore_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 = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'datastoreName': self._serialize.url("datastore_name", datastore_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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, + private_cloud_name=private_cloud_name, + cluster_name=cluster_name, + datastore_name=datastore_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 - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -381,80 +516,76 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/datastores/{datastoreName}'} # type: ignore + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/datastores/{datastoreName}"} # type: ignore + @distributed_trace_async async def begin_delete( - self, - resource_group_name: str, - private_cloud_name: str, - cluster_name: str, - datastore_name: str, - **kwargs: Any + self, resource_group_name: str, private_cloud_name: str, cluster_name: str, datastore_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete a datastore in a private cloud cluster. Delete a datastore in a private cloud cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param cluster_name: Name of the cluster in the private cloud. + :param cluster_name: Name of the cluster in the private cloud. Required. :type cluster_name: str - :param datastore_name: Name of the datastore in the private cloud cluster. + :param datastore_name: Name of the datastore in the private cloud cluster. Required. :type datastore_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, private_cloud_name=private_cloud_name, cluster_name=cluster_name, datastore_name=datastore_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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_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.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/datastores/{datastoreName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/datastores/{datastoreName}"} # type: ignore diff --git a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_global_reach_connections_operations.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_global_reach_connections_operations.py index 901567d59c4a..90e4eebbc944 100644 --- a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_global_reach_connections_operations.py +++ b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_global_reach_connections_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,98 +6,128 @@ # 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 +import urllib.parse 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, + ResourceNotModifiedError, + 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._global_reach_connections_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class GlobalReachConnectionsOperations: - """GlobalReachConnectionsOperations 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 GlobalReachConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.avs.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.avs.aio.AVSClient`'s + :attr:`global_reach_connections` 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") + @distributed_trace def list( - self, - resource_group_name: str, - private_cloud_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.GlobalReachConnectionList"]: + self, resource_group_name: str, private_cloud_name: str, **kwargs: Any + ) -> AsyncIterable["_models.GlobalReachConnection"]: """List global reach connections in a private cloud. List global reach connections in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GlobalReachConnectionList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.avs.models.GlobalReachConnectionList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either GlobalReachConnection or the result of + cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.avs.models.GlobalReachConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GlobalReachConnectionList"] + _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.GlobalReachConnectionList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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('GlobalReachConnectionList', pipeline_response) + deserialized = self._deserialize("GlobalReachConnectionList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -105,7 +136,9 @@ 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]: @@ -114,116 +147,128 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/globalReachConnections'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/globalReachConnections"} # type: ignore + + @distributed_trace_async async def get( - self, - resource_group_name: str, - private_cloud_name: str, - global_reach_connection_name: str, - **kwargs: Any - ) -> "_models.GlobalReachConnection": + self, resource_group_name: str, private_cloud_name: str, global_reach_connection_name: str, **kwargs: Any + ) -> _models.GlobalReachConnection: """Get a global reach connection by name in a private cloud. Get a global reach connection by name in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :param global_reach_connection_name: Name of the global reach connection in the private cloud. + Required. :type global_reach_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GlobalReachConnection, or the result of cls(response) + :return: GlobalReachConnection or the result of cls(response) :rtype: ~azure.mgmt.avs.models.GlobalReachConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GlobalReachConnection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'globalReachConnectionName': self._serialize.url("global_reach_connection_name", global_reach_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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.GlobalReachConnection] + + request = build_get_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + global_reach_connection_name=global_reach_connection_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 - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GlobalReachConnection', pipeline_response) + deserialized = self._deserialize("GlobalReachConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/globalReachConnections/{globalReachConnectionName}'} # type: ignore + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/globalReachConnections/{globalReachConnectionName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, private_cloud_name: str, global_reach_connection_name: str, - global_reach_connection: "_models.GlobalReachConnection", + global_reach_connection: Union[_models.GlobalReachConnection, IO], **kwargs: Any - ) -> "_models.GlobalReachConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.GlobalReachConnection"] + ) -> _models.GlobalReachConnection: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'globalReachConnectionName': self._serialize.url("global_reach_connection_name", global_reach_connection_name, 'str'), - } - url = self._client.format_url(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(global_reach_connection, 'GlobalReachConnection') - 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) + 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.GlobalReachConnection] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(global_reach_connection, (IO, bytes)): + _content = global_reach_connection + else: + _json = self._serialize.body(global_reach_connection, "GlobalReachConnection") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + global_reach_connection_name=global_reach_connection_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]: @@ -231,130 +276,223 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('GlobalReachConnection', pipeline_response) + deserialized = self._deserialize("GlobalReachConnection", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GlobalReachConnection', pipeline_response) + deserialized = self._deserialize("GlobalReachConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/globalReachConnections/{globalReachConnectionName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/globalReachConnections/{globalReachConnectionName}"} # type: ignore + + @overload async def begin_create_or_update( self, resource_group_name: str, private_cloud_name: str, global_reach_connection_name: str, - global_reach_connection: "_models.GlobalReachConnection", + global_reach_connection: _models.GlobalReachConnection, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.GlobalReachConnection"]: + ) -> AsyncLROPoller[_models.GlobalReachConnection]: """Create or update a global reach connection in a private cloud. Create or update a global reach connection in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: The name of the private cloud. + :param private_cloud_name: The name of the private cloud. Required. :type private_cloud_name: str :param global_reach_connection_name: Name of the global reach connection in the private cloud. + Required. :type global_reach_connection_name: str - :param global_reach_connection: A global reach connection in the private cloud. + :param global_reach_connection: A global reach connection in the private cloud. Required. :type global_reach_connection: ~azure.mgmt.avs.models.GlobalReachConnection + :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 GlobalReachConnection 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 GlobalReachConnection or the result + of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.GlobalReachConnection] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GlobalReachConnection"] - 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, + private_cloud_name: str, + global_reach_connection_name: str, + global_reach_connection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.GlobalReachConnection]: + """Create or update a global reach connection in a private cloud. + + Create or update a global reach connection in a private cloud. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: The name of the private cloud. Required. + :type private_cloud_name: str + :param global_reach_connection_name: Name of the global reach connection in the private cloud. + Required. + :type global_reach_connection_name: str + :param global_reach_connection: A global reach connection in the private cloud. Required. + :type global_reach_connection: 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 GlobalReachConnection or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.GlobalReachConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + private_cloud_name: str, + global_reach_connection_name: str, + global_reach_connection: Union[_models.GlobalReachConnection, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.GlobalReachConnection]: + """Create or update a global reach connection in a private cloud. + + Create or update a global reach connection in a private cloud. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: The name of the private cloud. Required. + :type private_cloud_name: str + :param global_reach_connection_name: Name of the global reach connection in the private cloud. + Required. + :type global_reach_connection_name: str + :param global_reach_connection: A global reach connection in the private cloud. Is either a + model type or a IO type. Required. + :type global_reach_connection: ~azure.mgmt.avs.models.GlobalReachConnection 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 GlobalReachConnection or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.GlobalReachConnection] + :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.GlobalReachConnection] + 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, private_cloud_name=private_cloud_name, global_reach_connection_name=global_reach_connection_name, global_reach_connection=global_reach_connection, - 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('GlobalReachConnection', pipeline_response) - + deserialized = self._deserialize("GlobalReachConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'globalReachConnectionName': self._serialize.url("global_reach_connection_name", global_reach_connection_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_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/globalReachConnections/{globalReachConnectionName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - async def _delete_initial( - self, - resource_group_name: str, - private_cloud_name: str, - global_reach_connection_name: str, - **kwargs: Any + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/globalReachConnections/{globalReachConnectionName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, private_cloud_name: str, global_reach_connection_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'globalReachConnectionName': self._serialize.url("global_reach_connection_name", global_reach_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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, + private_cloud_name=private_cloud_name, + global_reach_connection_name=global_reach_connection_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 - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -364,75 +502,74 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/globalReachConnections/{globalReachConnectionName}'} # type: ignore + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/globalReachConnections/{globalReachConnectionName}"} # type: ignore + @distributed_trace_async async def begin_delete( - self, - resource_group_name: str, - private_cloud_name: str, - global_reach_connection_name: str, - **kwargs: Any + self, resource_group_name: str, private_cloud_name: str, global_reach_connection_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete a global reach connection in a private cloud. Delete a global reach connection in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :param global_reach_connection_name: Name of the global reach connection in the private cloud. + Required. :type global_reach_connection_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, private_cloud_name=private_cloud_name, global_reach_connection_name=global_reach_connection_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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'globalReachConnectionName': self._serialize.url("global_reach_connection_name", global_reach_connection_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.AVS/privateClouds/{privateCloudName}/globalReachConnections/{globalReachConnectionName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/globalReachConnections/{globalReachConnectionName}"} # type: ignore diff --git a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_hcx_enterprise_sites_operations.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_hcx_enterprise_sites_operations.py index 3b651916242e..b128b45b174f 100644 --- a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_hcx_enterprise_sites_operations.py +++ b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_hcx_enterprise_sites_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,96 +6,125 @@ # 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, overload +import urllib.parse 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, + ResourceNotModifiedError, + 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._hcx_enterprise_sites_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class HcxEnterpriseSitesOperations: - """HcxEnterpriseSitesOperations 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 HcxEnterpriseSitesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.avs.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.avs.aio.AVSClient`'s + :attr:`hcx_enterprise_sites` 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") + @distributed_trace def list( - self, - resource_group_name: str, - private_cloud_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.HcxEnterpriseSiteList"]: + self, resource_group_name: str, private_cloud_name: str, **kwargs: Any + ) -> AsyncIterable["_models.HcxEnterpriseSite"]: """List HCX Enterprise Sites in a private cloud. List HCX Enterprise Sites in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either HcxEnterpriseSiteList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.avs.models.HcxEnterpriseSiteList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either HcxEnterpriseSite or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.avs.models.HcxEnterpriseSite] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.HcxEnterpriseSiteList"] + _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.HcxEnterpriseSiteList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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('HcxEnterpriseSiteList', pipeline_response) + deserialized = self._deserialize("HcxEnterpriseSiteList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -103,7 +133,9 @@ 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]: @@ -112,133 +144,220 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/hcxEnterpriseSites'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/hcxEnterpriseSites"} # type: ignore + @distributed_trace_async async def get( - self, - resource_group_name: str, - private_cloud_name: str, - hcx_enterprise_site_name: str, - **kwargs: Any - ) -> "_models.HcxEnterpriseSite": + self, resource_group_name: str, private_cloud_name: str, hcx_enterprise_site_name: str, **kwargs: Any + ) -> _models.HcxEnterpriseSite: """Get an HCX Enterprise Site by name in a private cloud. Get an HCX Enterprise Site by name in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :param hcx_enterprise_site_name: Name of the HCX Enterprise Site in the private cloud. + Required. :type hcx_enterprise_site_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: HcxEnterpriseSite, or the result of cls(response) + :return: HcxEnterpriseSite or the result of cls(response) :rtype: ~azure.mgmt.avs.models.HcxEnterpriseSite - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.HcxEnterpriseSite"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'hcxEnterpriseSiteName': self._serialize.url("hcx_enterprise_site_name", hcx_enterprise_site_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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.HcxEnterpriseSite] + + request = build_get_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + hcx_enterprise_site_name=hcx_enterprise_site_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 - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('HcxEnterpriseSite', pipeline_response) + deserialized = self._deserialize("HcxEnterpriseSite", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/hcxEnterpriseSites/{hcxEnterpriseSiteName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/hcxEnterpriseSites/{hcxEnterpriseSiteName}"} # type: ignore + + @overload async def create_or_update( self, resource_group_name: str, private_cloud_name: str, hcx_enterprise_site_name: str, - hcx_enterprise_site: "_models.HcxEnterpriseSite", + hcx_enterprise_site: _models.HcxEnterpriseSite, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.HcxEnterpriseSite": + ) -> _models.HcxEnterpriseSite: """Create or update an HCX Enterprise Site in a private cloud. Create or update an HCX Enterprise Site in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: The name of the private cloud. + :param private_cloud_name: The name of the private cloud. Required. :type private_cloud_name: str :param hcx_enterprise_site_name: Name of the HCX Enterprise Site in the private cloud. + Required. :type hcx_enterprise_site_name: str - :param hcx_enterprise_site: The HCX Enterprise Site. + :param hcx_enterprise_site: The HCX Enterprise Site. Required. :type hcx_enterprise_site: ~azure.mgmt.avs.models.HcxEnterpriseSite + :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: HcxEnterpriseSite or the result of cls(response) + :rtype: ~azure.mgmt.avs.models.HcxEnterpriseSite + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + private_cloud_name: str, + hcx_enterprise_site_name: str, + hcx_enterprise_site: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.HcxEnterpriseSite: + """Create or update an HCX Enterprise Site in a private cloud. + + Create or update an HCX Enterprise Site in a private cloud. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: The name of the private cloud. Required. + :type private_cloud_name: str + :param hcx_enterprise_site_name: Name of the HCX Enterprise Site in the private cloud. + Required. + :type hcx_enterprise_site_name: str + :param hcx_enterprise_site: The HCX Enterprise Site. Required. + :type hcx_enterprise_site: 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: HcxEnterpriseSite, or the result of cls(response) + :return: HcxEnterpriseSite or the result of cls(response) :rtype: ~azure.mgmt.avs.models.HcxEnterpriseSite - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + private_cloud_name: str, + hcx_enterprise_site_name: str, + hcx_enterprise_site: Union[_models.HcxEnterpriseSite, IO], + **kwargs: Any + ) -> _models.HcxEnterpriseSite: + """Create or update an HCX Enterprise Site in a private cloud. + + Create or update an HCX Enterprise Site in a private cloud. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: The name of the private cloud. Required. + :type private_cloud_name: str + :param hcx_enterprise_site_name: Name of the HCX Enterprise Site in the private cloud. + Required. + :type hcx_enterprise_site_name: str + :param hcx_enterprise_site: The HCX Enterprise Site. Is either a model type or a IO type. + Required. + :type hcx_enterprise_site: ~azure.mgmt.avs.models.HcxEnterpriseSite 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: HcxEnterpriseSite or the result of cls(response) + :rtype: ~azure.mgmt.avs.models.HcxEnterpriseSite + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.HcxEnterpriseSite"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'hcxEnterpriseSiteName': self._serialize.url("hcx_enterprise_site_name", hcx_enterprise_site_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(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(hcx_enterprise_site, 'HcxEnterpriseSite') - 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) + 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.HcxEnterpriseSite] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(hcx_enterprise_site, (IO, bytes)): + _content = hcx_enterprise_site + else: + _json = self._serialize.body(hcx_enterprise_site, "HcxEnterpriseSite") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + hcx_enterprise_site_name=hcx_enterprise_site_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.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]: @@ -246,67 +365,70 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('HcxEnterpriseSite', pipeline_response) + deserialized = self._deserialize("HcxEnterpriseSite", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('HcxEnterpriseSite', pipeline_response) + deserialized = self._deserialize("HcxEnterpriseSite", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/hcxEnterpriseSites/{hcxEnterpriseSiteName}'} # type: ignore - async def delete( - self, - resource_group_name: str, - private_cloud_name: str, - hcx_enterprise_site_name: str, - **kwargs: Any + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/hcxEnterpriseSites/{hcxEnterpriseSiteName}"} # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, private_cloud_name: str, hcx_enterprise_site_name: str, **kwargs: Any ) -> None: """Delete an HCX Enterprise Site in a private cloud. Delete an HCX Enterprise Site in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :param hcx_enterprise_site_name: Name of the HCX Enterprise Site in the private cloud. + Required. :type hcx_enterprise_site_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 + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'hcxEnterpriseSiteName': self._serialize.url("hcx_enterprise_site_name", hcx_enterprise_site_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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, + private_cloud_name=private_cloud_name, + hcx_enterprise_site_name=hcx_enterprise_site_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 - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -316,4 +438,4 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/hcxEnterpriseSites/{hcxEnterpriseSiteName}'} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/hcxEnterpriseSites/{hcxEnterpriseSiteName}"} # type: ignore diff --git a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_locations_operations.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_locations_operations.py index 74aba316ee8e..0358c97e062f 100644 --- a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_locations_operations.py +++ b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_locations_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,145 +6,220 @@ # 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, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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_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 +from ..._vendor import _convert_request +from ...operations._locations_operations import ( + build_check_quota_availability_request, + build_check_trial_availability_request, +) -T = TypeVar('T') +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class LocationsOperations: - """LocationsOperations 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 LocationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.avs.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.avs.aio.AVSClient`'s + :attr:`locations` 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 check_trial_availability( - self, - location: str, - **kwargs: Any - ) -> "_models.Trial": + self, location: str, sku: Optional[_models.Sku] = None, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.Trial: """Return trial status for subscription by region. - :param location: Azure region. + :param location: Azure region. Required. :type location: str + :param sku: The sku to check for trial availability. Default value is None. + :type sku: ~azure.mgmt.avs.models.Sku + :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: Trial, or the result of cls(response) + :return: Trial or the result of cls(response) :rtype: ~azure.mgmt.avs.models.Trial - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_trial_availability( + self, location: str, sku: Optional[IO] = None, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.Trial: + """Return trial status for subscription by region. + + :param location: Azure region. Required. + :type location: str + :param sku: The sku to check for trial availability. Default value is None. + :type sku: 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: Trial or the result of cls(response) + :rtype: ~azure.mgmt.avs.models.Trial + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Trial"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.check_trial_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'location': self._serialize.url("location", location, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + @distributed_trace_async + async def check_trial_availability( + self, location: str, sku: Optional[Union[_models.Sku, IO]] = None, **kwargs: Any + ) -> _models.Trial: + """Return trial status for subscription by region. - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + :param location: Azure region. Required. + :type location: str + :param sku: The sku to check for trial availability. Is either a model type or a IO type. + Default value is None. + :type sku: ~azure.mgmt.avs.models.Sku 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: Trial or the result of cls(response) + :rtype: ~azure.mgmt.avs.models.Trial + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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.Trial] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(sku, (IO, bytes)): + _content = sku + else: + if sku is not None: + _json = self._serialize.body(sku, "Sku") + else: + _json = None + + request = build_check_trial_availability_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.check_trial_availability.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 + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Trial', pipeline_response) + deserialized = self._deserialize("Trial", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_trial_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.AVS/locations/{location}/checkTrialAvailability'} # type: ignore - async def check_quota_availability( - self, - location: str, - **kwargs: Any - ) -> "_models.Quota": + check_trial_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AVS/locations/{location}/checkTrialAvailability"} # type: ignore + + @distributed_trace_async + async def check_quota_availability(self, location: str, **kwargs: Any) -> _models.Quota: """Return quota for subscription by region. - :param location: Azure region. + :param location: Azure region. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Quota, or the result of cls(response) + :return: Quota or the result of cls(response) :rtype: ~azure.mgmt.avs.models.Quota - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Quota"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.check_quota_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'location': self._serialize.url("location", location, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # 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.Quota] + + request = build_check_quota_availability_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.check_quota_availability.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 + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Quota', pipeline_response) + deserialized = self._deserialize("Quota", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_quota_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.AVS/locations/{location}/checkQuotaAvailability'} # type: ignore + + check_quota_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AVS/locations/{location}/checkQuotaAvailability"} # type: ignore diff --git a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_operations.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_operations.py index 40f77ebfb3e7..13ccb089b6da 100644 --- a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_operations.py +++ b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/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,107 @@ # 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 +import urllib.parse 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, + ResourceNotModifiedError, + 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.avs.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.avs.aio.AVSClient`'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.OperationList"]: + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.avs.models.OperationList] - :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.avs.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationList"] + _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.OperationList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - request = 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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('OperationList', pipeline_response) + deserialized = self._deserialize("OperationList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -89,7 +115,9 @@ 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]: @@ -98,7 +126,6 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.AVS/operations'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.AVS/operations"} # type: ignore diff --git a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_patch.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/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/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_placement_policies_operations.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_placement_policies_operations.py index aa54a3b239f0..577aeb675d28 100644 --- a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_placement_policies_operations.py +++ b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_placement_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,102 +6,131 @@ # 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 +import urllib.parse 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, + ResourceNotModifiedError, + 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._placement_policies_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 PlacementPoliciesOperations: - """PlacementPoliciesOperations 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 PlacementPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.avs.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.avs.aio.AVSClient`'s + :attr:`placement_policies` 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") + @distributed_trace def list( - self, - resource_group_name: str, - private_cloud_name: str, - cluster_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.PlacementPoliciesList"]: + self, resource_group_name: str, private_cloud_name: str, cluster_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PlacementPolicy"]: """List placement policies in a private cloud cluster. List placement policies in a private cloud cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param cluster_name: Name of the cluster in the private cloud. + :param cluster_name: Name of the cluster in the private cloud. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PlacementPoliciesList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.avs.models.PlacementPoliciesList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either PlacementPolicy or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.avs.models.PlacementPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PlacementPoliciesList"] + _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.PlacementPoliciesList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + cluster_name=cluster_name, + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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('PlacementPoliciesList', pipeline_response) + deserialized = self._deserialize("PlacementPoliciesList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -109,7 +139,9 @@ 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]: @@ -118,11 +150,11 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/placementPolicies'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/placementPolicies"} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -130,67 +162,72 @@ async def get( cluster_name: str, placement_policy_name: str, **kwargs: Any - ) -> "_models.PlacementPolicy": + ) -> _models.PlacementPolicy: """Get a placement policy by name in a private cloud cluster. Get a placement policy by name in a private cloud cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param cluster_name: Name of the cluster in the private cloud. + :param cluster_name: Name of the cluster in the private cloud. Required. :type cluster_name: str :param placement_policy_name: Name of the VMware vSphere Distributed Resource Scheduler (DRS) - placement policy. + placement policy. Required. :type placement_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PlacementPolicy, or the result of cls(response) + :return: PlacementPolicy or the result of cls(response) :rtype: ~azure.mgmt.avs.models.PlacementPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PlacementPolicy"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'placementPolicyName': self._serialize.url("placement_policy_name", placement_policy_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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.PlacementPolicy] + + request = build_get_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + cluster_name=cluster_name, + placement_policy_name=placement_policy_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 - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PlacementPolicy', pipeline_response) + deserialized = self._deserialize("PlacementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/placementPolicies/{placementPolicyName}'} # type: ignore + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/placementPolicies/{placementPolicyName}"} # type: ignore async def _create_or_update_initial( self, @@ -198,43 +235,53 @@ async def _create_or_update_initial( private_cloud_name: str, cluster_name: str, placement_policy_name: str, - placement_policy: "_models.PlacementPolicy", + placement_policy: Union[_models.PlacementPolicy, IO], **kwargs: Any - ) -> "_models.PlacementPolicy": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PlacementPolicy"] + ) -> _models.PlacementPolicy: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'placementPolicyName': self._serialize.url("placement_policy_name", placement_policy_name, 'str'), - } - url = self._client.format_url(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(placement_policy, 'PlacementPolicy') - 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) + 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.PlacementPolicy] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(placement_policy, (IO, bytes)): + _content = placement_policy + else: + _json = self._serialize.body(placement_policy, "PlacementPolicy") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + cluster_name=cluster_name, + placement_policy_name=placement_policy_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]: @@ -242,100 +289,198 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PlacementPolicy', pipeline_response) + deserialized = self._deserialize("PlacementPolicy", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PlacementPolicy', pipeline_response) + deserialized = self._deserialize("PlacementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/placementPolicies/{placementPolicyName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/placementPolicies/{placementPolicyName}"} # type: ignore + + @overload async def begin_create_or_update( self, resource_group_name: str, private_cloud_name: str, cluster_name: str, placement_policy_name: str, - placement_policy: "_models.PlacementPolicy", + placement_policy: _models.PlacementPolicy, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.PlacementPolicy"]: + ) -> AsyncLROPoller[_models.PlacementPolicy]: """Create or update a placement policy in a private cloud cluster. Create or update a placement policy in a private cloud cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param cluster_name: Name of the cluster in the private cloud. + :param cluster_name: Name of the cluster in the private cloud. Required. :type cluster_name: str :param placement_policy_name: Name of the VMware vSphere Distributed Resource Scheduler (DRS) - placement policy. + placement policy. Required. :type placement_policy_name: str - :param placement_policy: A placement policy in the private cloud cluster. + :param placement_policy: A placement policy in the private cloud cluster. Required. :type placement_policy: ~azure.mgmt.avs.models.PlacementPolicy + :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 PlacementPolicy 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 PlacementPolicy or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.PlacementPolicy] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PlacementPolicy"] - 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, + private_cloud_name: str, + cluster_name: str, + placement_policy_name: str, + placement_policy: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PlacementPolicy]: + """Create or update a placement policy in a private cloud cluster. + + Create or update a placement policy in a private cloud cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param cluster_name: Name of the cluster in the private cloud. Required. + :type cluster_name: str + :param placement_policy_name: Name of the VMware vSphere Distributed Resource Scheduler (DRS) + placement policy. Required. + :type placement_policy_name: str + :param placement_policy: A placement policy in the private cloud cluster. Required. + :type placement_policy: 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 PlacementPolicy or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.PlacementPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + private_cloud_name: str, + cluster_name: str, + placement_policy_name: str, + placement_policy: Union[_models.PlacementPolicy, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.PlacementPolicy]: + """Create or update a placement policy in a private cloud cluster. + + Create or update a placement policy in a private cloud cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param cluster_name: Name of the cluster in the private cloud. Required. + :type cluster_name: str + :param placement_policy_name: Name of the VMware vSphere Distributed Resource Scheduler (DRS) + placement policy. Required. + :type placement_policy_name: str + :param placement_policy: A placement policy in the private cloud cluster. Is either a model + type or a IO type. Required. + :type placement_policy: ~azure.mgmt.avs.models.PlacementPolicy 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 PlacementPolicy or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.PlacementPolicy] + :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.PlacementPolicy] + 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, private_cloud_name=private_cloud_name, cluster_name=cluster_name, placement_policy_name=placement_policy_name, placement_policy=placement_policy, - 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('PlacementPolicy', pipeline_response) - + deserialized = self._deserialize("PlacementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'placementPolicyName': self._serialize.url("placement_policy_name", placement_policy_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_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/placementPolicies/{placementPolicyName}'} # 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.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/placementPolicies/{placementPolicyName}"} # type: ignore async def _update_initial( self, @@ -343,43 +488,53 @@ async def _update_initial( private_cloud_name: str, cluster_name: str, placement_policy_name: str, - placement_policy_update: "_models.PlacementPolicyUpdate", + placement_policy_update: Union[_models.PlacementPolicyUpdate, IO], **kwargs: Any - ) -> "_models.PlacementPolicy": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PlacementPolicy"] + ) -> _models.PlacementPolicy: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'placementPolicyName': self._serialize.url("placement_policy_name", placement_policy_name, 'str'), - } - url = self._client.format_url(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(placement_policy_update, 'PlacementPolicyUpdate') - 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) + 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.PlacementPolicy] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(placement_policy_update, (IO, bytes)): + _content = placement_policy_update + else: + _json = self._serialize.body(placement_policy_update, "PlacementPolicyUpdate") + + request = build_update_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + cluster_name=cluster_name, + placement_policy_name=placement_policy_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, 202]: @@ -387,102 +542,200 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PlacementPolicy', pipeline_response) + deserialized = self._deserialize("PlacementPolicy", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('PlacementPolicy', pipeline_response) + deserialized = self._deserialize("PlacementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/placementPolicies/{placementPolicyName}'} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/placementPolicies/{placementPolicyName}"} # type: ignore + + @overload async def begin_update( self, resource_group_name: str, private_cloud_name: str, cluster_name: str, placement_policy_name: str, - placement_policy_update: "_models.PlacementPolicyUpdate", + placement_policy_update: _models.PlacementPolicyUpdate, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.PlacementPolicy"]: + ) -> AsyncLROPoller[_models.PlacementPolicy]: """Update a placement policy in a private cloud cluster. Update a placement policy in a private cloud cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param cluster_name: Name of the cluster in the private cloud. + :param cluster_name: Name of the cluster in the private cloud. Required. :type cluster_name: str :param placement_policy_name: Name of the VMware vSphere Distributed Resource Scheduler (DRS) - placement policy. + placement policy. Required. :type placement_policy_name: str - :param placement_policy_update: The placement policy properties that may be updated. + :param placement_policy_update: The placement policy properties that may be updated. Required. :type placement_policy_update: ~azure.mgmt.avs.models.PlacementPolicyUpdate + :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 PlacementPolicy 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 PlacementPolicy or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.PlacementPolicy] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PlacementPolicy"] - 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, + private_cloud_name: str, + cluster_name: str, + placement_policy_name: str, + placement_policy_update: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PlacementPolicy]: + """Update a placement policy in a private cloud cluster. + + Update a placement policy in a private cloud cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param cluster_name: Name of the cluster in the private cloud. Required. + :type cluster_name: str + :param placement_policy_name: Name of the VMware vSphere Distributed Resource Scheduler (DRS) + placement policy. Required. + :type placement_policy_name: str + :param placement_policy_update: The placement policy properties that may be updated. Required. + :type placement_policy_update: 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 PlacementPolicy or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.PlacementPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + private_cloud_name: str, + cluster_name: str, + placement_policy_name: str, + placement_policy_update: Union[_models.PlacementPolicyUpdate, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.PlacementPolicy]: + """Update a placement policy in a private cloud cluster. + + Update a placement policy in a private cloud cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param cluster_name: Name of the cluster in the private cloud. Required. + :type cluster_name: str + :param placement_policy_name: Name of the VMware vSphere Distributed Resource Scheduler (DRS) + placement policy. Required. + :type placement_policy_name: str + :param placement_policy_update: The placement policy properties that may be updated. Is either + a model type or a IO type. Required. + :type placement_policy_update: ~azure.mgmt.avs.models.PlacementPolicyUpdate 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 PlacementPolicy or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.PlacementPolicy] + :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.PlacementPolicy] + 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, private_cloud_name=private_cloud_name, cluster_name=cluster_name, placement_policy_name=placement_policy_name, placement_policy_update=placement_policy_update, - 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('PlacementPolicy', pipeline_response) - + deserialized = self._deserialize("PlacementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'placementPolicyName': self._serialize.url("placement_policy_name", placement_policy_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.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/placementPolicies/{placementPolicyName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/placementPolicies/{placementPolicyName}"} # type: ignore - async def _delete_initial( + async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, private_cloud_name: str, @@ -490,35 +743,38 @@ async def _delete_initial( placement_policy_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'placementPolicyName': self._serialize.url("placement_policy_name", placement_policy_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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, + private_cloud_name=private_cloud_name, + cluster_name=cluster_name, + placement_policy_name=placement_policy_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 - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -528,8 +784,9 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/placementPolicies/{placementPolicyName}'} # type: ignore + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/placementPolicies/{placementPolicyName}"} # type: ignore + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -543,66 +800,66 @@ async def begin_delete( Delete a placement policy in a private cloud cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param cluster_name: Name of the cluster in the private cloud. + :param cluster_name: Name of the cluster in the private cloud. Required. :type cluster_name: str :param placement_policy_name: Name of the VMware vSphere Distributed Resource Scheduler (DRS) - placement policy. + placement policy. Required. :type placement_policy_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, private_cloud_name=private_cloud_name, cluster_name=cluster_name, placement_policy_name=placement_policy_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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'placementPolicyName': self._serialize.url("placement_policy_name", placement_policy_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.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/placementPolicies/{placementPolicyName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/placementPolicies/{placementPolicyName}"} # type: ignore diff --git a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_private_clouds_operations.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_private_clouds_operations.py index ba1ad880549f..56487dd3139f 100644 --- a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_private_clouds_operations.py +++ b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_private_clouds_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,94 +6,127 @@ # 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 +import urllib.parse 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, + ResourceNotModifiedError, + 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._private_clouds_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_admin_credentials_request, + build_list_in_subscription_request, + build_list_request, + build_rotate_nsxt_password_request, + build_rotate_vcenter_password_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PrivateCloudsOperations: - """PrivateCloudsOperations 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 PrivateCloudsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.avs.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.avs.aio.AVSClient`'s + :attr:`private_clouds` 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, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.PrivateCloudList"]: + @distributed_trace + def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.PrivateCloud"]: """List private clouds in a resource group. List private clouds in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 PrivateCloudList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.avs.models.PrivateCloudList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either PrivateCloud or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.avs.models.PrivateCloud] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateCloudList"] + _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.PrivateCloudList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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('PrivateCloudList', pipeline_response) + deserialized = self._deserialize("PrivateCloudList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -101,7 +135,9 @@ 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]: @@ -110,57 +146,68 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - def list_in_subscription( - self, - **kwargs: Any - ) -> AsyncIterable["_models.PrivateCloudList"]: + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds"} # type: ignore + + @distributed_trace + def list_in_subscription(self, **kwargs: Any) -> AsyncIterable["_models.PrivateCloud"]: """List private clouds in a subscription. List private clouds 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 PrivateCloudList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.avs.models.PrivateCloudList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either PrivateCloud or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.avs.models.PrivateCloud] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateCloudList"] + _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.PrivateCloudList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_in_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_in_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_in_subscription.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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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('PrivateCloudList', pipeline_response) + deserialized = self._deserialize("PrivateCloudList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -169,7 +216,9 @@ 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]: @@ -178,110 +227,120 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_in_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.AVS/privateClouds'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def get( - self, - resource_group_name: str, - private_cloud_name: str, - **kwargs: Any - ) -> "_models.PrivateCloud": + list_in_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AVS/privateClouds"} # type: ignore + + @distributed_trace_async + async def get(self, resource_group_name: str, private_cloud_name: str, **kwargs: Any) -> _models.PrivateCloud: """Get a private cloud. Get a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateCloud, or the result of cls(response) + :return: PrivateCloud or the result of cls(response) :rtype: ~azure.mgmt.avs.models.PrivateCloud - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateCloud"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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.PrivateCloud] + + request = build_get_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_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 - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateCloud', pipeline_response) + deserialized = self._deserialize("PrivateCloud", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}'} # type: ignore + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, private_cloud_name: str, - private_cloud: "_models.PrivateCloud", + private_cloud: Union[_models.PrivateCloud, IO], **kwargs: Any - ) -> "_models.PrivateCloud": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateCloud"] + ) -> _models.PrivateCloud: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - } - url = self._client.format_url(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(private_cloud, 'PrivateCloud') - 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) + 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.PrivateCloud] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_cloud, (IO, bytes)): + _content = private_cloud + else: + _json = self._serialize.body(private_cloud, "PrivateCloud") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_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]: @@ -289,129 +348,224 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateCloud', pipeline_response) + deserialized = self._deserialize("PrivateCloud", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateCloud', pipeline_response) + deserialized = self._deserialize("PrivateCloud", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}"} # type: ignore + + @overload async def begin_create_or_update( self, resource_group_name: str, private_cloud_name: str, - private_cloud: "_models.PrivateCloud", + private_cloud: _models.PrivateCloud, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.PrivateCloud"]: + ) -> AsyncLROPoller[_models.PrivateCloud]: """Create or update a private cloud. Create or update a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param private_cloud: The private cloud. + :param private_cloud: The private cloud. Required. :type private_cloud: ~azure.mgmt.avs.models.PrivateCloud + :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 PrivateCloud 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 PrivateCloud or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.PrivateCloud] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateCloud"] - 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, + private_cloud_name: str, + private_cloud: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateCloud]: + """Create or update a private cloud. + + Create or update a private cloud. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param private_cloud: The private cloud. Required. + :type private_cloud: 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 PrivateCloud or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.PrivateCloud] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + private_cloud_name: str, + private_cloud: Union[_models.PrivateCloud, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateCloud]: + """Create or update a private cloud. + + Create or update a private cloud. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param private_cloud: The private cloud. Is either a model type or a IO type. Required. + :type private_cloud: ~azure.mgmt.avs.models.PrivateCloud 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 PrivateCloud or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.PrivateCloud] + :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.PrivateCloud] + 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, private_cloud_name=private_cloud_name, private_cloud=private_cloud, - 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('PrivateCloud', pipeline_response) - + deserialized = self._deserialize("PrivateCloud", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_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_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}'} # 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.AVS/privateClouds/{privateCloudName}"} # type: ignore async def _update_initial( self, resource_group_name: str, private_cloud_name: str, - private_cloud_update: "_models.PrivateCloudUpdate", + private_cloud_update: Union[_models.PrivateCloudUpdate, IO], **kwargs: Any - ) -> "_models.PrivateCloud": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateCloud"] + ) -> _models.PrivateCloud: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(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(private_cloud_update, 'PrivateCloudUpdate') - 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) + 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.PrivateCloud] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_cloud_update, (IO, bytes)): + _content = private_cloud_update + else: + _json = self._serialize.body(private_cloud_update, "PrivateCloudUpdate") + + request = build_update_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_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]: @@ -419,123 +573,209 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateCloud', pipeline_response) + deserialized = self._deserialize("PrivateCloud", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateCloud', pipeline_response) + deserialized = self._deserialize("PrivateCloud", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}'} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}"} # type: ignore + + @overload async def begin_update( self, resource_group_name: str, private_cloud_name: str, - private_cloud_update: "_models.PrivateCloudUpdate", + private_cloud_update: _models.PrivateCloudUpdate, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.PrivateCloud"]: + ) -> AsyncLROPoller[_models.PrivateCloud]: """Update a private cloud. Update a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param private_cloud_update: The private cloud properties to be updated. + :param private_cloud_update: The private cloud properties to be updated. Required. :type private_cloud_update: ~azure.mgmt.avs.models.PrivateCloudUpdate + :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 PrivateCloud 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 PrivateCloud or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.PrivateCloud] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateCloud"] - 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, + private_cloud_name: str, + private_cloud_update: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateCloud]: + """Update a private cloud. + + Update a private cloud. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param private_cloud_update: The private cloud properties to be updated. Required. + :type private_cloud_update: 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 PrivateCloud or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.PrivateCloud] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + private_cloud_name: str, + private_cloud_update: Union[_models.PrivateCloudUpdate, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateCloud]: + """Update a private cloud. + + Update a private cloud. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param private_cloud_update: The private cloud properties to be updated. Is either a model type + or a IO type. Required. + :type private_cloud_update: ~azure.mgmt.avs.models.PrivateCloudUpdate 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 PrivateCloud or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.PrivateCloud] + :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.PrivateCloud] + 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, private_cloud_name=private_cloud_name, private_cloud_update=private_cloud_update, - 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('PrivateCloud', pipeline_response) - + deserialized = self._deserialize("PrivateCloud", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_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.AVS/privateClouds/{privateCloudName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - async def _delete_initial( - self, - resource_group_name: str, - private_cloud_name: str, - **kwargs: Any + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, private_cloud_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 = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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, + private_cloud_name=private_cloud_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 - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -545,107 +785,107 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}'} # type: ignore + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}"} # type: ignore + @distributed_trace_async async def begin_delete( - self, - resource_group_name: str, - private_cloud_name: str, - **kwargs: Any + self, resource_group_name: str, private_cloud_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete a private cloud. Delete a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_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, private_cloud_name=private_cloud_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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_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.AVS/privateClouds/{privateCloudName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - async def _rotate_vcenter_password_initial( - self, - resource_group_name: str, - private_cloud_name: str, - **kwargs: Any + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}"} # type: ignore + + async def _rotate_vcenter_password_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, private_cloud_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 = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self._rotate_vcenter_password_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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_rotate_vcenter_password_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._rotate_vcenter_password_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -655,107 +895,107 @@ async def _rotate_vcenter_password_initial( if cls: return cls(pipeline_response, None, {}) - _rotate_vcenter_password_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/rotateVcenterPassword'} # type: ignore + _rotate_vcenter_password_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/rotateVcenterPassword"} # type: ignore + @distributed_trace_async async def begin_rotate_vcenter_password( - self, - resource_group_name: str, - private_cloud_name: str, - **kwargs: Any + self, resource_group_name: str, private_cloud_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Rotate the vCenter password. Rotate the vCenter password. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_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._rotate_vcenter_password_initial( + raw_result = await self._rotate_vcenter_password_initial( # type: ignore resource_group_name=resource_group_name, private_cloud_name=private_cloud_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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_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_rotate_vcenter_password.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/rotateVcenterPassword'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - async def _rotate_nsxt_password_initial( - self, - resource_group_name: str, - private_cloud_name: str, - **kwargs: Any + begin_rotate_vcenter_password.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/rotateVcenterPassword"} # type: ignore + + async def _rotate_nsxt_password_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, private_cloud_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 = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self._rotate_nsxt_password_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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_rotate_nsxt_password_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._rotate_nsxt_password_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -765,130 +1005,133 @@ async def _rotate_nsxt_password_initial( if cls: return cls(pipeline_response, None, {}) - _rotate_nsxt_password_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/rotateNsxtPassword'} # type: ignore + _rotate_nsxt_password_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/rotateNsxtPassword"} # type: ignore + @distributed_trace_async async def begin_rotate_nsxt_password( - self, - resource_group_name: str, - private_cloud_name: str, - **kwargs: Any + self, resource_group_name: str, private_cloud_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Rotate the NSX-T Manager password. Rotate the NSX-T Manager password. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_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._rotate_nsxt_password_initial( + raw_result = await self._rotate_nsxt_password_initial( # type: ignore resource_group_name=resource_group_name, private_cloud_name=private_cloud_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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_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_rotate_nsxt_password.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/rotateNsxtPassword'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_rotate_nsxt_password.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/rotateNsxtPassword"} # type: ignore + + @distributed_trace_async async def list_admin_credentials( - self, - resource_group_name: str, - private_cloud_name: str, - **kwargs: Any - ) -> "_models.AdminCredentials": + self, resource_group_name: str, private_cloud_name: str, **kwargs: Any + ) -> _models.AdminCredentials: """List the admin credentials for the private cloud. List the admin credentials for the private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AdminCredentials, or the result of cls(response) + :return: AdminCredentials or the result of cls(response) :rtype: ~azure.mgmt.avs.models.AdminCredentials - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AdminCredentials"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.list_admin_credentials.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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.AdminCredentials] + + request = build_list_admin_credentials_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_admin_credentials.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('AdminCredentials', pipeline_response) + deserialized = self._deserialize("AdminCredentials", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_admin_credentials.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/listAdminCredentials'} # type: ignore + + list_admin_credentials.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/listAdminCredentials"} # type: ignore diff --git a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_script_cmdlets_operations.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_script_cmdlets_operations.py index 77dd7139bf2b..a6d29da8e0ee 100644 --- a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_script_cmdlets_operations.py +++ b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_script_cmdlets_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,99 +6,122 @@ # 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 +import urllib.parse 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, + ResourceNotModifiedError, + 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 +from ..._vendor import _convert_request +from ...operations._script_cmdlets_operations import build_get_request, build_list_request -T = TypeVar('T') +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ScriptCmdletsOperations: - """ScriptCmdletsOperations 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 ScriptCmdletsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.avs.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.avs.aio.AVSClient`'s + :attr:`script_cmdlets` 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") + @distributed_trace def list( - self, - resource_group_name: str, - private_cloud_name: str, - script_package_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ScriptCmdletsList"]: + self, resource_group_name: str, private_cloud_name: str, script_package_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ScriptCmdlet"]: """List script cmdlet resources available for a private cloud to create a script execution resource on a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param script_package_name: Name of the script package in the private cloud. + :param script_package_name: Name of the script package in the private cloud. Required. :type script_package_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ScriptCmdletsList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.avs.models.ScriptCmdletsList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ScriptCmdlet or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.avs.models.ScriptCmdlet] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScriptCmdletsList"] + _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.ScriptCmdletsList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'scriptPackageName': self._serialize.url("script_package_name", script_package_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + script_package_name=script_package_name, + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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('ScriptCmdletsList', pipeline_response) + deserialized = self._deserialize("ScriptCmdletsList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -106,7 +130,9 @@ 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]: @@ -115,11 +141,11 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptPackages/{scriptPackageName}/scriptCmdlets'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptPackages/{scriptPackageName}/scriptCmdlets"} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -127,62 +153,67 @@ async def get( script_package_name: str, script_cmdlet_name: str, **kwargs: Any - ) -> "_models.ScriptCmdlet": + ) -> _models.ScriptCmdlet: """Return information about a script cmdlet resource in a specific package on a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param script_package_name: Name of the script package in the private cloud. + :param script_package_name: Name of the script package in the private cloud. Required. :type script_package_name: str :param script_cmdlet_name: Name of the script cmdlet resource in the script package in the - private cloud. + private cloud. Required. :type script_cmdlet_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScriptCmdlet, or the result of cls(response) + :return: ScriptCmdlet or the result of cls(response) :rtype: ~azure.mgmt.avs.models.ScriptCmdlet - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScriptCmdlet"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'scriptPackageName': self._serialize.url("script_package_name", script_package_name, 'str'), - 'scriptCmdletName': self._serialize.url("script_cmdlet_name", script_cmdlet_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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.ScriptCmdlet] + + request = build_get_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + script_package_name=script_package_name, + script_cmdlet_name=script_cmdlet_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 - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ScriptCmdlet', pipeline_response) + deserialized = self._deserialize("ScriptCmdlet", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptPackages/{scriptPackageName}/scriptCmdlets/{scriptCmdletName}'} # type: ignore + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptPackages/{scriptPackageName}/scriptCmdlets/{scriptCmdletName}"} # type: ignore diff --git a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_script_executions_operations.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_script_executions_operations.py index 1b309004b286..a7983f296400 100644 --- a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_script_executions_operations.py +++ b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_script_executions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,98 +6,128 @@ # 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, List, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload +import urllib.parse 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, + ResourceNotModifiedError, + 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._script_executions_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_execution_logs_request, + build_get_request, + build_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ScriptExecutionsOperations: - """ScriptExecutionsOperations 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 ScriptExecutionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.avs.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.avs.aio.AVSClient`'s + :attr:`script_executions` 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") + @distributed_trace def list( - self, - resource_group_name: str, - private_cloud_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ScriptExecutionsList"]: + self, resource_group_name: str, private_cloud_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ScriptExecution"]: """List script executions in a private cloud. List script executions in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ScriptExecutionsList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.avs.models.ScriptExecutionsList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ScriptExecution or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.avs.models.ScriptExecution] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScriptExecutionsList"] + _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.ScriptExecutionsList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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('ScriptExecutionsList', pipeline_response) + deserialized = self._deserialize("ScriptExecutionsList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -105,7 +136,9 @@ 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]: @@ -114,116 +147,127 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptExecutions'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptExecutions"} # type: ignore + @distributed_trace_async async def get( - self, - resource_group_name: str, - private_cloud_name: str, - script_execution_name: str, - **kwargs: Any - ) -> "_models.ScriptExecution": + self, resource_group_name: str, private_cloud_name: str, script_execution_name: str, **kwargs: Any + ) -> _models.ScriptExecution: """Get an script execution by name in a private cloud. Get an script execution by name in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param script_execution_name: Name of the user-invoked script execution resource. + :param script_execution_name: Name of the user-invoked script execution resource. Required. :type script_execution_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScriptExecution, or the result of cls(response) + :return: ScriptExecution or the result of cls(response) :rtype: ~azure.mgmt.avs.models.ScriptExecution - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScriptExecution"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'scriptExecutionName': self._serialize.url("script_execution_name", script_execution_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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.ScriptExecution] + + request = build_get_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + script_execution_name=script_execution_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 - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ScriptExecution', pipeline_response) + deserialized = self._deserialize("ScriptExecution", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptExecutions/{scriptExecutionName}'} # type: ignore + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptExecutions/{scriptExecutionName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, private_cloud_name: str, script_execution_name: str, - script_execution: "_models.ScriptExecution", + script_execution: Union[_models.ScriptExecution, IO], **kwargs: Any - ) -> "_models.ScriptExecution": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScriptExecution"] + ) -> _models.ScriptExecution: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'scriptExecutionName': self._serialize.url("script_execution_name", script_execution_name, 'str'), - } - url = self._client.format_url(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(script_execution, 'ScriptExecution') - 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) + 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.ScriptExecution] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(script_execution, (IO, bytes)): + _content = script_execution + else: + _json = self._serialize.body(script_execution, "ScriptExecution") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + script_execution_name=script_execution_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]: @@ -231,130 +275,220 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ScriptExecution', pipeline_response) + deserialized = self._deserialize("ScriptExecution", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ScriptExecution', pipeline_response) + deserialized = self._deserialize("ScriptExecution", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptExecutions/{scriptExecutionName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptExecutions/{scriptExecutionName}"} # type: ignore + + @overload async def begin_create_or_update( self, resource_group_name: str, private_cloud_name: str, script_execution_name: str, - script_execution: "_models.ScriptExecution", + script_execution: _models.ScriptExecution, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.ScriptExecution"]: + ) -> AsyncLROPoller[_models.ScriptExecution]: """Create or update a script execution in a private cloud. Create or update a script execution in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: The name of the private cloud. + :param private_cloud_name: The name of the private cloud. Required. :type private_cloud_name: str - :param script_execution_name: Name of the user-invoked script execution resource. + :param script_execution_name: Name of the user-invoked script execution resource. Required. :type script_execution_name: str - :param script_execution: A script running in the private cloud. + :param script_execution: A script running in the private cloud. Required. :type script_execution: ~azure.mgmt.avs.models.ScriptExecution + :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 ScriptExecution 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 ScriptExecution or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.ScriptExecution] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScriptExecution"] - 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, + private_cloud_name: str, + script_execution_name: str, + script_execution: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ScriptExecution]: + """Create or update a script execution in a private cloud. + + Create or update a script execution in a private cloud. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: The name of the private cloud. Required. + :type private_cloud_name: str + :param script_execution_name: Name of the user-invoked script execution resource. Required. + :type script_execution_name: str + :param script_execution: A script running in the private cloud. Required. + :type script_execution: 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 ScriptExecution or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.ScriptExecution] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + private_cloud_name: str, + script_execution_name: str, + script_execution: Union[_models.ScriptExecution, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ScriptExecution]: + """Create or update a script execution in a private cloud. + + Create or update a script execution in a private cloud. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: The name of the private cloud. Required. + :type private_cloud_name: str + :param script_execution_name: Name of the user-invoked script execution resource. Required. + :type script_execution_name: str + :param script_execution: A script running in the private cloud. Is either a model type or a IO + type. Required. + :type script_execution: ~azure.mgmt.avs.models.ScriptExecution 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 ScriptExecution or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.ScriptExecution] + :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.ScriptExecution] + 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, private_cloud_name=private_cloud_name, script_execution_name=script_execution_name, script_execution=script_execution, - 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('ScriptExecution', pipeline_response) - + deserialized = self._deserialize("ScriptExecution", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'scriptExecutionName': self._serialize.url("script_execution_name", script_execution_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_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptExecutions/{scriptExecutionName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - async def _delete_initial( - self, - resource_group_name: str, - private_cloud_name: str, - script_execution_name: str, - **kwargs: Any + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptExecutions/{scriptExecutionName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, private_cloud_name: str, script_execution_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 = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'scriptExecutionName': self._serialize.url("script_execution_name", script_execution_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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, + private_cloud_name=private_cloud_name, + script_execution_name=script_execution_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 - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -364,149 +498,229 @@ async def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptExecutions/{scriptExecutionName}'} # type: ignore + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptExecutions/{scriptExecutionName}"} # type: ignore + @distributed_trace_async async def begin_delete( - self, - resource_group_name: str, - private_cloud_name: str, - script_execution_name: str, - **kwargs: Any + self, resource_group_name: str, private_cloud_name: str, script_execution_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Cancel a ScriptExecution in a private cloud. Cancel a ScriptExecution in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param script_execution_name: Name of the user-invoked script execution resource. + :param script_execution_name: Name of the user-invoked script execution resource. Required. :type script_execution_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, private_cloud_name=private_cloud_name, script_execution_name=script_execution_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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'scriptExecutionName': self._serialize.url("script_execution_name", script_execution_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.AVS/privateClouds/{privateCloudName}/scriptExecutions/{scriptExecutionName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptExecutions/{scriptExecutionName}"} # type: ignore + @overload async def get_execution_logs( self, resource_group_name: str, private_cloud_name: str, script_execution_name: str, - script_output_stream_type: Optional[List[Union[str, "_models.ScriptOutputStreamType"]]] = None, + script_output_stream_type: Optional[List[Union[str, _models.ScriptOutputStreamType]]] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ScriptExecution": + ) -> _models.ScriptExecution: """Return the logs for a script execution resource. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param script_execution_name: Name of the user-invoked script execution resource. + :param script_execution_name: Name of the user-invoked script execution resource. Required. :type script_execution_name: str :param script_output_stream_type: Name of the desired output stream to return. If not provided, - will return all. An empty array will return nothing. + will return all. An empty array will return nothing. Default value is None. :type script_output_stream_type: list[str or ~azure.mgmt.avs.models.ScriptOutputStreamType] + :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: ScriptExecution, or the result of cls(response) + :return: ScriptExecution or the result of cls(response) :rtype: ~azure.mgmt.avs.models.ScriptExecution - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def get_execution_logs( + self, + resource_group_name: str, + private_cloud_name: str, + script_execution_name: str, + script_output_stream_type: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ScriptExecution: + """Return the logs for a script execution resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param script_execution_name: Name of the user-invoked script execution resource. Required. + :type script_execution_name: str + :param script_output_stream_type: Name of the desired output stream to return. If not provided, + will return all. An empty array will return nothing. Default value is None. + :type script_output_stream_type: 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: ScriptExecution or the result of cls(response) + :rtype: ~azure.mgmt.avs.models.ScriptExecution + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def get_execution_logs( + self, + resource_group_name: str, + private_cloud_name: str, + script_execution_name: str, + script_output_stream_type: Optional[Union[List[Union[str, _models.ScriptOutputStreamType]], IO]] = None, + **kwargs: Any + ) -> _models.ScriptExecution: + """Return the logs for a script execution resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param script_execution_name: Name of the user-invoked script execution resource. Required. + :type script_execution_name: str + :param script_output_stream_type: Name of the desired output stream to return. If not provided, + will return all. An empty array will return nothing. Is either a list type or a IO type. + Default value is None. + :type script_output_stream_type: list[str or ~azure.mgmt.avs.models.ScriptOutputStreamType] 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: ScriptExecution or the result of cls(response) + :rtype: ~azure.mgmt.avs.models.ScriptExecution + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScriptExecution"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.get_execution_logs.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'scriptExecutionName': self._serialize.url("script_execution_name", script_execution_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # 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') + 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.ScriptExecution] - body_content_kwargs = {} # type: Dict[str, Any] - if script_output_stream_type is not None: - body_content = self._serialize.body(script_output_stream_type, '[str]') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(script_output_stream_type, (IO, bytes)): + _content = script_output_stream_type 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 script_output_stream_type is not None: + _json = self._serialize.body(script_output_stream_type, "[str]") + else: + _json = None + + request = build_get_execution_logs_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + script_execution_name=script_execution_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.get_execution_logs.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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ScriptExecution', pipeline_response) + deserialized = self._deserialize("ScriptExecution", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_execution_logs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptExecutions/{scriptExecutionName}/getExecutionLogs'} # type: ignore + + get_execution_logs.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptExecutions/{scriptExecutionName}/getExecutionLogs"} # type: ignore diff --git a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_script_packages_operations.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_script_packages_operations.py index 375eeb676519..663be71b94cc 100644 --- a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_script_packages_operations.py +++ b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_script_packages_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,94 +6,118 @@ # 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 +import urllib.parse 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, + ResourceNotModifiedError, + 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 +from ..._vendor import _convert_request +from ...operations._script_packages_operations import build_get_request, build_list_request -T = TypeVar('T') +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ScriptPackagesOperations: - """ScriptPackagesOperations 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 ScriptPackagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.avs.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.avs.aio.AVSClient`'s + :attr:`script_packages` 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") + @distributed_trace def list( - self, - resource_group_name: str, - private_cloud_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ScriptPackagesList"]: + self, resource_group_name: str, private_cloud_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ScriptPackage"]: """List script packages available to run on the private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ScriptPackagesList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.avs.models.ScriptPackagesList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ScriptPackage or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.avs.models.ScriptPackage] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScriptPackagesList"] + _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.ScriptPackagesList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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('ScriptPackagesList', pipeline_response) + deserialized = self._deserialize("ScriptPackagesList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -101,7 +126,9 @@ 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]: @@ -110,69 +137,70 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptPackages'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptPackages"} # type: ignore + @distributed_trace_async async def get( - self, - resource_group_name: str, - private_cloud_name: str, - script_package_name: str, - **kwargs: Any - ) -> "_models.ScriptPackage": + self, resource_group_name: str, private_cloud_name: str, script_package_name: str, **kwargs: Any + ) -> _models.ScriptPackage: """Get a script package available to run on a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param script_package_name: Name of the script package in the private cloud. + :param script_package_name: Name of the script package in the private cloud. Required. :type script_package_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScriptPackage, or the result of cls(response) + :return: ScriptPackage or the result of cls(response) :rtype: ~azure.mgmt.avs.models.ScriptPackage - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScriptPackage"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'scriptPackageName': self._serialize.url("script_package_name", script_package_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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.ScriptPackage] + + request = build_get_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + script_package_name=script_package_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 - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ScriptPackage', pipeline_response) + deserialized = self._deserialize("ScriptPackage", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptPackages/{scriptPackageName}'} # type: ignore + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptPackages/{scriptPackageName}"} # type: ignore diff --git a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_virtual_machines_operations.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_virtual_machines_operations.py index f61947d9bef8..190c191f0c66 100644 --- a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_virtual_machines_operations.py +++ b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/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,102 +6,129 @@ # 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 +import urllib.parse 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, + ResourceNotModifiedError, + 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_get_request, + build_list_request, + build_restrict_movement_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.avs.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.avs.aio.AVSClient`'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") + @distributed_trace def list( - self, - resource_group_name: str, - private_cloud_name: str, - cluster_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.VirtualMachinesList"]: + self, resource_group_name: str, private_cloud_name: str, cluster_name: str, **kwargs: Any + ) -> AsyncIterable["_models.VirtualMachine"]: """List of virtual machines in a private cloud cluster. List of virtual machines in a private cloud cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param cluster_name: Name of the cluster in the private cloud. + :param cluster_name: Name of the cluster in the private cloud. Required. :type cluster_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.avs.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.avs.models.VirtualMachine] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachinesList"] + _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.VirtualMachinesList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + cluster_name=cluster_name, + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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) @@ -109,7 +137,9 @@ 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]: @@ -118,11 +148,11 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/virtualMachines'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/virtualMachines"} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -130,110 +160,125 @@ async def get( cluster_name: str, virtual_machine_id: str, **kwargs: Any - ) -> "_models.VirtualMachine": + ) -> _models.VirtualMachine: """Get a virtual machine by id in a private cloud cluster. Get a virtual machine by id in a private cloud cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param cluster_name: Name of the cluster in the private cloud. + :param cluster_name: Name of the cluster in the private cloud. Required. :type cluster_name: str - :param virtual_machine_id: Virtual Machine identifier. + :param virtual_machine_id: Virtual Machine identifier. Required. :type virtual_machine_id: 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.avs.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 = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'virtualMachineId': self._serialize.url("virtual_machine_id", virtual_machine_id, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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, + private_cloud_name=private_cloud_name, + cluster_name=cluster_name, + virtual_machine_id=virtual_machine_id, + 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 - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, 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.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/virtualMachines/{virtualMachineId}'} # type: ignore - async def _restrict_movement_initial( + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/virtualMachines/{virtualMachineId}"} # type: ignore + + async def _restrict_movement_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, private_cloud_name: str, cluster_name: str, virtual_machine_id: str, - restrict_movement: "_models.VirtualMachineRestrictMovement", + restrict_movement: Union[_models.VirtualMachineRestrictMovement, IO], **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 = "2021-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._restrict_movement_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'virtualMachineId': self._serialize.url("virtual_machine_id", virtual_machine_id, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(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(restrict_movement, 'VirtualMachineRestrictMovement') - 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) + 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(restrict_movement, (IO, bytes)): + _content = restrict_movement + else: + _json = self._serialize.body(restrict_movement, "VirtualMachineRestrictMovement") + + request = build_restrict_movement_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + cluster_name=cluster_name, + virtual_machine_id=virtual_machine_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._restrict_movement_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 [202]: @@ -243,15 +288,18 @@ async def _restrict_movement_initial( if cls: return cls(pipeline_response, None, {}) - _restrict_movement_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/virtualMachines/{virtualMachineId}/restrictMovement'} # type: ignore + _restrict_movement_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/virtualMachines/{virtualMachineId}/restrictMovement"} # type: ignore + @overload async def begin_restrict_movement( self, resource_group_name: str, private_cloud_name: str, cluster_name: str, virtual_machine_id: str, - restrict_movement: "_models.VirtualMachineRestrictMovement", + restrict_movement: _models.VirtualMachineRestrictMovement, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: """Enable or disable DRS-driven VM movement restriction. @@ -259,69 +307,160 @@ async def begin_restrict_movement( Enable or disable DRS-driven VM movement restriction. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param cluster_name: Name of the cluster in the private cloud. + :param cluster_name: Name of the cluster in the private cloud. Required. :type cluster_name: str - :param virtual_machine_id: Virtual Machine identifier. + :param virtual_machine_id: Virtual Machine identifier. Required. :type virtual_machine_id: str :param restrict_movement: Whether VM DRS-driven movement is restricted (Enabled) or not - (Disabled). + (Disabled). Required. :type restrict_movement: ~azure.mgmt.avs.models.VirtualMachineRestrictMovement + :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_restrict_movement( + self, + resource_group_name: str, + private_cloud_name: str, + cluster_name: str, + virtual_machine_id: str, + restrict_movement: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Enable or disable DRS-driven VM movement restriction. + + Enable or disable DRS-driven VM movement restriction. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param cluster_name: Name of the cluster in the private cloud. Required. + :type cluster_name: str + :param virtual_machine_id: Virtual Machine identifier. Required. + :type virtual_machine_id: str + :param restrict_movement: Whether VM DRS-driven movement is restricted (Enabled) or not + (Disabled). Required. + :type restrict_movement: 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_restrict_movement( + self, + resource_group_name: str, + private_cloud_name: str, + cluster_name: str, + virtual_machine_id: str, + restrict_movement: Union[_models.VirtualMachineRestrictMovement, IO], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Enable or disable DRS-driven VM movement restriction. + + Enable or disable DRS-driven VM movement restriction. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param cluster_name: Name of the cluster in the private cloud. Required. + :type cluster_name: str + :param virtual_machine_id: Virtual Machine identifier. Required. + :type virtual_machine_id: str + :param restrict_movement: Whether VM DRS-driven movement is restricted (Enabled) or not + (Disabled). Is either a model type or a IO type. Required. + :type restrict_movement: ~azure.mgmt.avs.models.VirtualMachineRestrictMovement 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._restrict_movement_initial( + raw_result = await self._restrict_movement_initial( # type: ignore resource_group_name=resource_group_name, private_cloud_name=private_cloud_name, cluster_name=cluster_name, virtual_machine_id=virtual_machine_id, restrict_movement=restrict_movement, - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'virtualMachineId': self._serialize.url("virtual_machine_id", virtual_machine_id, '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_restrict_movement.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/virtualMachines/{virtualMachineId}/restrictMovement'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_restrict_movement.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/virtualMachines/{virtualMachineId}/restrictMovement"} # type: ignore diff --git a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_workload_networks_operations.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_workload_networks_operations.py index 82b59135d38c..ea82c95d34c0 100644 --- a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_workload_networks_operations.py +++ b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/aio/operations/_workload_networks_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,98 +6,325 @@ # 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 +import urllib.parse 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, + ResourceNotModifiedError, + 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._workload_networks_operations import ( + build_create_dhcp_request, + build_create_dns_service_request, + build_create_dns_zone_request, + build_create_port_mirroring_request, + build_create_public_ip_request, + build_create_segments_request, + build_create_vm_group_request, + build_delete_dhcp_request, + build_delete_dns_service_request, + build_delete_dns_zone_request, + build_delete_port_mirroring_request, + build_delete_public_ip_request, + build_delete_segment_request, + build_delete_vm_group_request, + build_get_dhcp_request, + build_get_dns_service_request, + build_get_dns_zone_request, + build_get_gateway_request, + build_get_port_mirroring_request, + build_get_public_ip_request, + build_get_request, + build_get_segment_request, + build_get_virtual_machine_request, + build_get_vm_group_request, + build_list_dhcp_request, + build_list_dns_services_request, + build_list_dns_zones_request, + build_list_gateways_request, + build_list_port_mirroring_request, + build_list_public_i_ps_request, + build_list_request, + build_list_segments_request, + build_list_virtual_machines_request, + build_list_vm_groups_request, + build_update_dhcp_request, + build_update_dns_service_request, + build_update_dns_zone_request, + build_update_port_mirroring_request, + build_update_segments_request, + build_update_vm_group_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class WorkloadNetworksOperations: - """WorkloadNetworksOperations 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 WorkloadNetworksOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.avs.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.avs.aio.AVSClient`'s + :attr:`workload_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") - def list_segments( + @distributed_trace_async + async def get( self, resource_group_name: str, private_cloud_name: str, + workload_network_name: Union[str, _models.WorkloadNetworkName], **kwargs: Any - ) -> AsyncIterable["_models.WorkloadNetworkSegmentsList"]: + ) -> _models.WorkloadNetwork: + """Get a private cloud workload network. + + Get a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param workload_network_name: Name for the workload network in the private cloud. "default" + Required. + :type workload_network_name: str or ~azure.mgmt.avs.models.WorkloadNetworkName + :keyword callable cls: A custom type or function that will be passed the direct response + :return: WorkloadNetwork or the result of cls(response) + :rtype: ~azure.mgmt.avs.models.WorkloadNetwork + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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.WorkloadNetwork] + + request = build_get_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + workload_network_name=workload_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("WorkloadNetwork", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/{workloadNetworkName}"} # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, private_cloud_name: str, **kwargs: Any + ) -> AsyncIterable["_models.WorkloadNetwork"]: + """List of workload networks in a private cloud. + + List of workload networks in a private cloud. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either WorkloadNetwork or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.avs.models.WorkloadNetwork] + :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.WorkloadNetworkList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + 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: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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("WorkloadNetworkList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks"} # type: ignore + + @distributed_trace + def list_segments( + self, resource_group_name: str, private_cloud_name: str, **kwargs: Any + ) -> AsyncIterable["_models.WorkloadNetworkSegment"]: """List of segments in a private cloud workload network. List of segments in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WorkloadNetworkSegmentsList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.avs.models.WorkloadNetworkSegmentsList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either WorkloadNetworkSegment or the result of + cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.avs.models.WorkloadNetworkSegment] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkSegmentsList"] + _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.WorkloadNetworkSegmentsList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_segments.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - } - url = self._client.format_url(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_segments_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_segments.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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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('WorkloadNetworkSegmentsList', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkSegmentsList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -105,7 +333,9 @@ 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]: @@ -114,116 +344,128 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_segments.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/segments'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + list_segments.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/segments"} # type: ignore + + @distributed_trace_async async def get_segment( - self, - resource_group_name: str, - private_cloud_name: str, - segment_id: str, - **kwargs: Any - ) -> "_models.WorkloadNetworkSegment": + self, resource_group_name: str, private_cloud_name: str, segment_id: str, **kwargs: Any + ) -> _models.WorkloadNetworkSegment: """Get a segment by id in a private cloud workload network. Get a segment by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :param segment_id: NSX Segment identifier. Generally the same as the Segment's display name. + Required. :type segment_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: WorkloadNetworkSegment, or the result of cls(response) + :return: WorkloadNetworkSegment or the result of cls(response) :rtype: ~azure.mgmt.avs.models.WorkloadNetworkSegment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkSegment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.get_segment.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'segmentId': self._serialize.url("segment_id", segment_id, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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.WorkloadNetworkSegment] + + request = build_get_segment_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + segment_id=segment_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_segment.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('WorkloadNetworkSegment', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkSegment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_segment.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/segments/{segmentId}'} # type: ignore + + get_segment.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/segments/{segmentId}"} # type: ignore async def _create_segments_initial( self, resource_group_name: str, private_cloud_name: str, segment_id: str, - workload_network_segment: "_models.WorkloadNetworkSegment", + workload_network_segment: Union[_models.WorkloadNetworkSegment, IO], **kwargs: Any - ) -> "_models.WorkloadNetworkSegment": - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkSegment"] + ) -> _models.WorkloadNetworkSegment: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_segments_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'segmentId': self._serialize.url("segment_id", segment_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') - - # 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(workload_network_segment, 'WorkloadNetworkSegment') - 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) + 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.WorkloadNetworkSegment] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(workload_network_segment, (IO, bytes)): + _content = workload_network_segment + else: + _json = self._serialize.body(workload_network_segment, "WorkloadNetworkSegment") + + request = build_create_segments_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + segment_id=segment_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_segments_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]: @@ -231,136 +473,239 @@ async def _create_segments_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('WorkloadNetworkSegment', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkSegment", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('WorkloadNetworkSegment', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkSegment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_segments_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/segments/{segmentId}'} # type: ignore + _create_segments_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/segments/{segmentId}"} # type: ignore + + @overload async def begin_create_segments( self, resource_group_name: str, private_cloud_name: str, segment_id: str, - workload_network_segment: "_models.WorkloadNetworkSegment", + workload_network_segment: _models.WorkloadNetworkSegment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.WorkloadNetworkSegment"]: + ) -> AsyncLROPoller[_models.WorkloadNetworkSegment]: """Create a segment by id in a private cloud workload network. Create a segment by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :param segment_id: NSX Segment identifier. Generally the same as the Segment's display name. + Required. :type segment_id: str - :param workload_network_segment: NSX Segment. + :param workload_network_segment: NSX Segment. Required. :type workload_network_segment: ~azure.mgmt.avs.models.WorkloadNetworkSegment + :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 WorkloadNetworkSegment 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 WorkloadNetworkSegment or the result + of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.WorkloadNetworkSegment] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkSegment"] - 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_segments( + self, + resource_group_name: str, + private_cloud_name: str, + segment_id: str, + workload_network_segment: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WorkloadNetworkSegment]: + """Create a segment by id in a private cloud workload network. + + Create a segment by id in a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param segment_id: NSX Segment identifier. Generally the same as the Segment's display name. + Required. + :type segment_id: str + :param workload_network_segment: NSX Segment. Required. + :type workload_network_segment: 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 WorkloadNetworkSegment or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.WorkloadNetworkSegment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_segments( + self, + resource_group_name: str, + private_cloud_name: str, + segment_id: str, + workload_network_segment: Union[_models.WorkloadNetworkSegment, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.WorkloadNetworkSegment]: + """Create a segment by id in a private cloud workload network. + + Create a segment by id in a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param segment_id: NSX Segment identifier. Generally the same as the Segment's display name. + Required. + :type segment_id: str + :param workload_network_segment: NSX Segment. Is either a model type or a IO type. Required. + :type workload_network_segment: ~azure.mgmt.avs.models.WorkloadNetworkSegment 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 WorkloadNetworkSegment or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.WorkloadNetworkSegment] + :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.WorkloadNetworkSegment] + 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_segments_initial( + raw_result = await self._create_segments_initial( # type: ignore resource_group_name=resource_group_name, private_cloud_name=private_cloud_name, segment_id=segment_id, workload_network_segment=workload_network_segment, - 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('WorkloadNetworkSegment', pipeline_response) - + deserialized = self._deserialize("WorkloadNetworkSegment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'segmentId': self._serialize.url("segment_id", segment_id, '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_create_segments.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/segments/{segmentId}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_segments.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/segments/{segmentId}"} # type: ignore async def _update_segments_initial( self, resource_group_name: str, private_cloud_name: str, segment_id: str, - workload_network_segment: "_models.WorkloadNetworkSegment", + workload_network_segment: Union[_models.WorkloadNetworkSegment, IO], **kwargs: Any - ) -> Optional["_models.WorkloadNetworkSegment"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WorkloadNetworkSegment"]] + ) -> Optional[_models.WorkloadNetworkSegment]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_segments_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'segmentId': self._serialize.url("segment_id", segment_id, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(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(workload_network_segment, 'WorkloadNetworkSegment') - 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) + 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.WorkloadNetworkSegment]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(workload_network_segment, (IO, bytes)): + _content = workload_network_segment + else: + _json = self._serialize.body(workload_network_segment, "WorkloadNetworkSegment") + + request = build_update_segments_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + segment_id=segment_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_segments_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]: @@ -369,127 +714,219 @@ async def _update_segments_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('WorkloadNetworkSegment', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkSegment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_segments_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/segments/{segmentId}'} # type: ignore + _update_segments_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/segments/{segmentId}"} # type: ignore + + @overload async def begin_update_segments( self, resource_group_name: str, private_cloud_name: str, segment_id: str, - workload_network_segment: "_models.WorkloadNetworkSegment", + workload_network_segment: _models.WorkloadNetworkSegment, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.WorkloadNetworkSegment"]: + ) -> AsyncLROPoller[_models.WorkloadNetworkSegment]: """Create or update a segment by id in a private cloud workload network. Create or update a segment by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :param segment_id: NSX Segment identifier. Generally the same as the Segment's display name. + Required. :type segment_id: str - :param workload_network_segment: NSX Segment. + :param workload_network_segment: NSX Segment. Required. :type workload_network_segment: ~azure.mgmt.avs.models.WorkloadNetworkSegment + :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 WorkloadNetworkSegment 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 WorkloadNetworkSegment or the result + of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.WorkloadNetworkSegment] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkSegment"] - 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_segments( + self, + resource_group_name: str, + private_cloud_name: str, + segment_id: str, + workload_network_segment: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WorkloadNetworkSegment]: + """Create or update a segment by id in a private cloud workload network. + + Create or update a segment by id in a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param segment_id: NSX Segment identifier. Generally the same as the Segment's display name. + Required. + :type segment_id: str + :param workload_network_segment: NSX Segment. Required. + :type workload_network_segment: 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 WorkloadNetworkSegment or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.WorkloadNetworkSegment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update_segments( + self, + resource_group_name: str, + private_cloud_name: str, + segment_id: str, + workload_network_segment: Union[_models.WorkloadNetworkSegment, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.WorkloadNetworkSegment]: + """Create or update a segment by id in a private cloud workload network. + + Create or update a segment by id in a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param segment_id: NSX Segment identifier. Generally the same as the Segment's display name. + Required. + :type segment_id: str + :param workload_network_segment: NSX Segment. Is either a model type or a IO type. Required. + :type workload_network_segment: ~azure.mgmt.avs.models.WorkloadNetworkSegment 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 WorkloadNetworkSegment or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.WorkloadNetworkSegment] + :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.WorkloadNetworkSegment] + 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_segments_initial( + raw_result = await self._update_segments_initial( # type: ignore resource_group_name=resource_group_name, private_cloud_name=private_cloud_name, segment_id=segment_id, workload_network_segment=workload_network_segment, - 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('WorkloadNetworkSegment', pipeline_response) - + deserialized = self._deserialize("WorkloadNetworkSegment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'segmentId': self._serialize.url("segment_id", segment_id, '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_segments.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/segments/{segmentId}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - async def _delete_segment_initial( - self, - resource_group_name: str, - private_cloud_name: str, - segment_id: str, - **kwargs: Any + begin_update_segments.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/segments/{segmentId}"} # type: ignore + + async def _delete_segment_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, private_cloud_name: str, segment_id: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_segment_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'segmentId': self._serialize.url("segment_id", segment_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') + 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_segment_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + segment_id=segment_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_segment_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -499,133 +936,145 @@ async def _delete_segment_initial( if cls: return cls(pipeline_response, None, {}) - _delete_segment_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/segments/{segmentId}'} # type: ignore + _delete_segment_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/segments/{segmentId}"} # type: ignore + @distributed_trace_async async def begin_delete_segment( - self, - resource_group_name: str, - private_cloud_name: str, - segment_id: str, - **kwargs: Any + self, resource_group_name: str, private_cloud_name: str, segment_id: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete a segment by id in a private cloud workload network. Delete a segment by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :param segment_id: NSX Segment identifier. Generally the same as the Segment's display name. + Required. :type segment_id: 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_segment_initial( + raw_result = await self._delete_segment_initial( # type: ignore resource_group_name=resource_group_name, private_cloud_name=private_cloud_name, segment_id=segment_id, - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'segmentId': self._serialize.url("segment_id", segment_id, '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_segment.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/segments/{segmentId}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_segment.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/segments/{segmentId}"} # type: ignore + + @distributed_trace def list_dhcp( - self, - resource_group_name: str, - private_cloud_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.WorkloadNetworkDhcpList"]: + self, resource_group_name: str, private_cloud_name: str, **kwargs: Any + ) -> AsyncIterable["_models.WorkloadNetworkDhcp"]: """List dhcp in a private cloud workload network. List dhcp in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WorkloadNetworkDhcpList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.avs.models.WorkloadNetworkDhcpList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either WorkloadNetworkDhcp or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.avs.models.WorkloadNetworkDhcp] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkDhcpList"] + _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.WorkloadNetworkDhcpList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_dhcp.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - } - url = self._client.format_url(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_dhcp_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_dhcp.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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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('WorkloadNetworkDhcpList', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkDhcpList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -634,7 +1083,9 @@ 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]: @@ -643,116 +1094,127 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_dhcp.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dhcpConfigurations'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list_dhcp.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dhcpConfigurations"} # type: ignore + @distributed_trace_async async def get_dhcp( - self, - resource_group_name: str, - dhcp_id: str, - private_cloud_name: str, - **kwargs: Any - ) -> "_models.WorkloadNetworkDhcp": + self, resource_group_name: str, dhcp_id: str, private_cloud_name: str, **kwargs: Any + ) -> _models.WorkloadNetworkDhcp: """Get dhcp by id in a private cloud workload network. Get dhcp by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param dhcp_id: NSX DHCP identifier. Generally the same as the DHCP display name. + :param dhcp_id: NSX DHCP identifier. Generally the same as the DHCP display name. Required. :type dhcp_id: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: WorkloadNetworkDhcp, or the result of cls(response) + :return: WorkloadNetworkDhcp or the result of cls(response) :rtype: ~azure.mgmt.avs.models.WorkloadNetworkDhcp - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkDhcp"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.get_dhcp.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'dhcpId': self._serialize.url("dhcp_id", dhcp_id, 'str'), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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.WorkloadNetworkDhcp] + + request = build_get_dhcp_request( + resource_group_name=resource_group_name, + dhcp_id=dhcp_id, + private_cloud_name=private_cloud_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_dhcp.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('WorkloadNetworkDhcp', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkDhcp", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_dhcp.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dhcpConfigurations/{dhcpId}'} # type: ignore + + get_dhcp.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dhcpConfigurations/{dhcpId}"} # type: ignore async def _create_dhcp_initial( self, resource_group_name: str, private_cloud_name: str, dhcp_id: str, - workload_network_dhcp: "_models.WorkloadNetworkDhcp", + workload_network_dhcp: Union[_models.WorkloadNetworkDhcp, IO], **kwargs: Any - ) -> "_models.WorkloadNetworkDhcp": - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkDhcp"] + ) -> _models.WorkloadNetworkDhcp: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_dhcp_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'dhcpId': self._serialize.url("dhcp_id", dhcp_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') - - # 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(workload_network_dhcp, 'WorkloadNetworkDhcp') - 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) + 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.WorkloadNetworkDhcp] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(workload_network_dhcp, (IO, bytes)): + _content = workload_network_dhcp + else: + _json = self._serialize.body(workload_network_dhcp, "WorkloadNetworkDhcp") + + request = build_create_dhcp_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + dhcp_id=dhcp_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_dhcp_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]: @@ -760,136 +1222,236 @@ async def _create_dhcp_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('WorkloadNetworkDhcp', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkDhcp", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('WorkloadNetworkDhcp', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkDhcp", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_dhcp_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dhcpConfigurations/{dhcpId}'} # type: ignore + _create_dhcp_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dhcpConfigurations/{dhcpId}"} # type: ignore + + @overload async def begin_create_dhcp( self, resource_group_name: str, private_cloud_name: str, dhcp_id: str, - workload_network_dhcp: "_models.WorkloadNetworkDhcp", + workload_network_dhcp: _models.WorkloadNetworkDhcp, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.WorkloadNetworkDhcp"]: + ) -> AsyncLROPoller[_models.WorkloadNetworkDhcp]: """Create dhcp by id in a private cloud workload network. Create dhcp by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param dhcp_id: NSX DHCP identifier. Generally the same as the DHCP display name. + :param dhcp_id: NSX DHCP identifier. Generally the same as the DHCP display name. Required. :type dhcp_id: str - :param workload_network_dhcp: NSX DHCP. + :param workload_network_dhcp: NSX DHCP. Required. :type workload_network_dhcp: ~azure.mgmt.avs.models.WorkloadNetworkDhcp + :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 WorkloadNetworkDhcp 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 WorkloadNetworkDhcp or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.WorkloadNetworkDhcp] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkDhcp"] - 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_dhcp( + self, + resource_group_name: str, + private_cloud_name: str, + dhcp_id: str, + workload_network_dhcp: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WorkloadNetworkDhcp]: + """Create dhcp by id in a private cloud workload network. + + Create dhcp by id in a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param dhcp_id: NSX DHCP identifier. Generally the same as the DHCP display name. Required. + :type dhcp_id: str + :param workload_network_dhcp: NSX DHCP. Required. + :type workload_network_dhcp: 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 WorkloadNetworkDhcp or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.WorkloadNetworkDhcp] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_dhcp( + self, + resource_group_name: str, + private_cloud_name: str, + dhcp_id: str, + workload_network_dhcp: Union[_models.WorkloadNetworkDhcp, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.WorkloadNetworkDhcp]: + """Create dhcp by id in a private cloud workload network. + + Create dhcp by id in a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param dhcp_id: NSX DHCP identifier. Generally the same as the DHCP display name. Required. + :type dhcp_id: str + :param workload_network_dhcp: NSX DHCP. Is either a model type or a IO type. Required. + :type workload_network_dhcp: ~azure.mgmt.avs.models.WorkloadNetworkDhcp 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 WorkloadNetworkDhcp or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.WorkloadNetworkDhcp] + :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.WorkloadNetworkDhcp] + 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_dhcp_initial( + raw_result = await self._create_dhcp_initial( # type: ignore resource_group_name=resource_group_name, private_cloud_name=private_cloud_name, dhcp_id=dhcp_id, workload_network_dhcp=workload_network_dhcp, - 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('WorkloadNetworkDhcp', pipeline_response) - + deserialized = self._deserialize("WorkloadNetworkDhcp", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'dhcpId': self._serialize.url("dhcp_id", dhcp_id, '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_create_dhcp.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dhcpConfigurations/{dhcpId}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_dhcp.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dhcpConfigurations/{dhcpId}"} # type: ignore async def _update_dhcp_initial( self, resource_group_name: str, private_cloud_name: str, dhcp_id: str, - workload_network_dhcp: "_models.WorkloadNetworkDhcp", + workload_network_dhcp: Union[_models.WorkloadNetworkDhcp, IO], **kwargs: Any - ) -> Optional["_models.WorkloadNetworkDhcp"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WorkloadNetworkDhcp"]] + ) -> Optional[_models.WorkloadNetworkDhcp]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_dhcp_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'dhcpId': self._serialize.url("dhcp_id", dhcp_id, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(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(workload_network_dhcp, 'WorkloadNetworkDhcp') - 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) + 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.WorkloadNetworkDhcp]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(workload_network_dhcp, (IO, bytes)): + _content = workload_network_dhcp + else: + _json = self._serialize.body(workload_network_dhcp, "WorkloadNetworkDhcp") + + request = build_update_dhcp_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + dhcp_id=dhcp_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_dhcp_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]: @@ -898,127 +1460,216 @@ async def _update_dhcp_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('WorkloadNetworkDhcp', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkDhcp", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_dhcp_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dhcpConfigurations/{dhcpId}'} # type: ignore + _update_dhcp_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dhcpConfigurations/{dhcpId}"} # type: ignore + + @overload async def begin_update_dhcp( self, resource_group_name: str, private_cloud_name: str, dhcp_id: str, - workload_network_dhcp: "_models.WorkloadNetworkDhcp", + workload_network_dhcp: _models.WorkloadNetworkDhcp, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.WorkloadNetworkDhcp"]: + ) -> AsyncLROPoller[_models.WorkloadNetworkDhcp]: """Create or update dhcp by id in a private cloud workload network. Create or update dhcp by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param dhcp_id: NSX DHCP identifier. Generally the same as the DHCP display name. + :param dhcp_id: NSX DHCP identifier. Generally the same as the DHCP display name. Required. :type dhcp_id: str - :param workload_network_dhcp: NSX DHCP. + :param workload_network_dhcp: NSX DHCP. Required. :type workload_network_dhcp: ~azure.mgmt.avs.models.WorkloadNetworkDhcp + :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 WorkloadNetworkDhcp 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 WorkloadNetworkDhcp or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.WorkloadNetworkDhcp] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkDhcp"] - 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_dhcp( + self, + resource_group_name: str, + private_cloud_name: str, + dhcp_id: str, + workload_network_dhcp: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WorkloadNetworkDhcp]: + """Create or update dhcp by id in a private cloud workload network. + + Create or update dhcp by id in a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param dhcp_id: NSX DHCP identifier. Generally the same as the DHCP display name. Required. + :type dhcp_id: str + :param workload_network_dhcp: NSX DHCP. Required. + :type workload_network_dhcp: 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 WorkloadNetworkDhcp or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.WorkloadNetworkDhcp] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update_dhcp( + self, + resource_group_name: str, + private_cloud_name: str, + dhcp_id: str, + workload_network_dhcp: Union[_models.WorkloadNetworkDhcp, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.WorkloadNetworkDhcp]: + """Create or update dhcp by id in a private cloud workload network. + + Create or update dhcp by id in a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param dhcp_id: NSX DHCP identifier. Generally the same as the DHCP display name. Required. + :type dhcp_id: str + :param workload_network_dhcp: NSX DHCP. Is either a model type or a IO type. Required. + :type workload_network_dhcp: ~azure.mgmt.avs.models.WorkloadNetworkDhcp 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 WorkloadNetworkDhcp or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.WorkloadNetworkDhcp] + :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.WorkloadNetworkDhcp] + 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_dhcp_initial( + raw_result = await self._update_dhcp_initial( # type: ignore resource_group_name=resource_group_name, private_cloud_name=private_cloud_name, dhcp_id=dhcp_id, workload_network_dhcp=workload_network_dhcp, - 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('WorkloadNetworkDhcp', pipeline_response) - + deserialized = self._deserialize("WorkloadNetworkDhcp", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'dhcpId': self._serialize.url("dhcp_id", dhcp_id, '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_dhcp.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dhcpConfigurations/{dhcpId}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - async def _delete_dhcp_initial( - self, - resource_group_name: str, - private_cloud_name: str, - dhcp_id: str, - **kwargs: Any + begin_update_dhcp.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dhcpConfigurations/{dhcpId}"} # type: ignore + + async def _delete_dhcp_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, private_cloud_name: str, dhcp_id: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_dhcp_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'dhcpId': self._serialize.url("dhcp_id", dhcp_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') + 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_dhcp_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + dhcp_id=dhcp_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_dhcp_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -1028,133 +1679,145 @@ async def _delete_dhcp_initial( if cls: return cls(pipeline_response, None, {}) - _delete_dhcp_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dhcpConfigurations/{dhcpId}'} # type: ignore + _delete_dhcp_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dhcpConfigurations/{dhcpId}"} # type: ignore + @distributed_trace_async async def begin_delete_dhcp( - self, - resource_group_name: str, - private_cloud_name: str, - dhcp_id: str, - **kwargs: Any + self, resource_group_name: str, private_cloud_name: str, dhcp_id: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete dhcp by id in a private cloud workload network. Delete dhcp by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param dhcp_id: NSX DHCP identifier. Generally the same as the DHCP display name. + :param dhcp_id: NSX DHCP identifier. Generally the same as the DHCP display name. Required. :type dhcp_id: 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_dhcp_initial( + raw_result = await self._delete_dhcp_initial( # type: ignore resource_group_name=resource_group_name, private_cloud_name=private_cloud_name, dhcp_id=dhcp_id, - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'dhcpId': self._serialize.url("dhcp_id", dhcp_id, '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_dhcp.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dhcpConfigurations/{dhcpId}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_dhcp.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dhcpConfigurations/{dhcpId}"} # type: ignore + + @distributed_trace def list_gateways( - self, - resource_group_name: str, - private_cloud_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.WorkloadNetworkGatewayList"]: + self, resource_group_name: str, private_cloud_name: str, **kwargs: Any + ) -> AsyncIterable["_models.WorkloadNetworkGateway"]: """List of gateways in a private cloud workload network. List of gateways in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WorkloadNetworkGatewayList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.avs.models.WorkloadNetworkGatewayList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either WorkloadNetworkGateway or the result of + cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.avs.models.WorkloadNetworkGateway] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkGatewayList"] + _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.WorkloadNetworkGatewayList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_gateways.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - } - url = self._client.format_url(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_gateways_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_gateways.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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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('WorkloadNetworkGatewayList', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkGatewayList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1163,7 +1826,9 @@ 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]: @@ -1172,129 +1837,146 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_gateways.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/gateways'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list_gateways.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/gateways"} # type: ignore + @distributed_trace_async async def get_gateway( - self, - resource_group_name: str, - private_cloud_name: str, - gateway_id: str, - **kwargs: Any - ) -> "_models.WorkloadNetworkGateway": + self, resource_group_name: str, private_cloud_name: str, gateway_id: str, **kwargs: Any + ) -> _models.WorkloadNetworkGateway: """Get a gateway by id in a private cloud workload network. Get a gateway by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :param gateway_id: NSX Gateway identifier. Generally the same as the Gateway's display name. + Required. :type gateway_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: WorkloadNetworkGateway, or the result of cls(response) + :return: WorkloadNetworkGateway or the result of cls(response) :rtype: ~azure.mgmt.avs.models.WorkloadNetworkGateway - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkGateway"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.get_gateway.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'gatewayId': self._serialize.url("gateway_id", gateway_id, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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.WorkloadNetworkGateway] + + request = build_get_gateway_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + gateway_id=gateway_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_gateway.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('WorkloadNetworkGateway', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkGateway", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_gateway.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/gateways/{gatewayId}'} # type: ignore + get_gateway.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/gateways/{gatewayId}"} # type: ignore + + @distributed_trace def list_port_mirroring( - self, - resource_group_name: str, - private_cloud_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.WorkloadNetworkPortMirroringList"]: + self, resource_group_name: str, private_cloud_name: str, **kwargs: Any + ) -> AsyncIterable["_models.WorkloadNetworkPortMirroring"]: """List of port mirroring profiles in a private cloud workload network. List of port mirroring profiles in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WorkloadNetworkPortMirroringList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.avs.models.WorkloadNetworkPortMirroringList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either WorkloadNetworkPortMirroring or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.avs.models.WorkloadNetworkPortMirroring] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkPortMirroringList"] + _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.WorkloadNetworkPortMirroringList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_port_mirroring.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - } - url = self._client.format_url(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_port_mirroring_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_port_mirroring.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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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('WorkloadNetworkPortMirroringList', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkPortMirroringList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1303,7 +1985,9 @@ 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]: @@ -1312,255 +1996,370 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_port_mirroring.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/portMirroringProfiles'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list_port_mirroring.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/portMirroringProfiles"} # type: ignore + @distributed_trace_async async def get_port_mirroring( - self, - resource_group_name: str, - private_cloud_name: str, - port_mirroring_id: str, - **kwargs: Any - ) -> "_models.WorkloadNetworkPortMirroring": + self, resource_group_name: str, private_cloud_name: str, port_mirroring_id: str, **kwargs: Any + ) -> _models.WorkloadNetworkPortMirroring: """Get a port mirroring profile by id in a private cloud workload network. Get a port mirroring profile by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :param port_mirroring_id: NSX Port Mirroring identifier. Generally the same as the Port - Mirroring display name. + Mirroring display name. Required. :type port_mirroring_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: WorkloadNetworkPortMirroring, or the result of cls(response) + :return: WorkloadNetworkPortMirroring or the result of cls(response) :rtype: ~azure.mgmt.avs.models.WorkloadNetworkPortMirroring - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkPortMirroring"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.get_port_mirroring.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'portMirroringId': self._serialize.url("port_mirroring_id", port_mirroring_id, 'str'), + 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.WorkloadNetworkPortMirroring] + + request = build_get_port_mirroring_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + port_mirroring_id=port_mirroring_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_port_mirroring.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("WorkloadNetworkPortMirroring", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_port_mirroring.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/portMirroringProfiles/{portMirroringId}"} # type: ignore + + async def _create_port_mirroring_initial( + self, + resource_group_name: str, + private_cloud_name: str, + port_mirroring_id: str, + workload_network_port_mirroring: Union[_models.WorkloadNetworkPortMirroring, IO], + **kwargs: Any + ) -> _models.WorkloadNetworkPortMirroring: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + 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.WorkloadNetworkPortMirroring] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(workload_network_port_mirroring, (IO, bytes)): + _content = workload_network_port_mirroring + else: + _json = self._serialize.body(workload_network_port_mirroring, "WorkloadNetworkPortMirroring") + + request = build_create_port_mirroring_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + port_mirroring_id=port_mirroring_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_port_mirroring_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 + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('WorkloadNetworkPortMirroring', pipeline_response) + if response.status_code == 200: + deserialized = self._deserialize("WorkloadNetworkPortMirroring", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("WorkloadNetworkPortMirroring", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_port_mirroring.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/portMirroringProfiles/{portMirroringId}'} # type: ignore - async def _create_port_mirroring_initial( + _create_port_mirroring_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/portMirroringProfiles/{portMirroringId}"} # type: ignore + + @overload + async def begin_create_port_mirroring( + self, + resource_group_name: str, + private_cloud_name: str, + port_mirroring_id: str, + workload_network_port_mirroring: _models.WorkloadNetworkPortMirroring, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WorkloadNetworkPortMirroring]: + """Create a port mirroring profile by id in a private cloud workload network. + + Create a port mirroring profile by id in a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param port_mirroring_id: NSX Port Mirroring identifier. Generally the same as the Port + Mirroring display name. Required. + :type port_mirroring_id: str + :param workload_network_port_mirroring: NSX port mirroring. Required. + :type workload_network_port_mirroring: ~azure.mgmt.avs.models.WorkloadNetworkPortMirroring + :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 WorkloadNetworkPortMirroring or the + result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.WorkloadNetworkPortMirroring] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_port_mirroring( self, resource_group_name: str, private_cloud_name: str, port_mirroring_id: str, - workload_network_port_mirroring: "_models.WorkloadNetworkPortMirroring", + workload_network_port_mirroring: IO, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.WorkloadNetworkPortMirroring": - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkPortMirroring"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_port_mirroring_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'portMirroringId': self._serialize.url("port_mirroring_id", port_mirroring_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') - - # 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(workload_network_port_mirroring, 'WorkloadNetworkPortMirroring') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize('WorkloadNetworkPortMirroring', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('WorkloadNetworkPortMirroring', pipeline_response) + ) -> AsyncLROPoller[_models.WorkloadNetworkPortMirroring]: + """Create a port mirroring profile by id in a private cloud workload network. - if cls: - return cls(pipeline_response, deserialized, {}) + Create a port mirroring profile by id in a private cloud workload network. - return deserialized - _create_port_mirroring_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/portMirroringProfiles/{portMirroringId}'} # type: ignore + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param port_mirroring_id: NSX Port Mirroring identifier. Generally the same as the Port + Mirroring display name. Required. + :type port_mirroring_id: str + :param workload_network_port_mirroring: NSX port mirroring. Required. + :type workload_network_port_mirroring: 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 WorkloadNetworkPortMirroring or the + result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.WorkloadNetworkPortMirroring] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace_async async def begin_create_port_mirroring( self, resource_group_name: str, private_cloud_name: str, port_mirroring_id: str, - workload_network_port_mirroring: "_models.WorkloadNetworkPortMirroring", + workload_network_port_mirroring: Union[_models.WorkloadNetworkPortMirroring, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.WorkloadNetworkPortMirroring"]: + ) -> AsyncLROPoller[_models.WorkloadNetworkPortMirroring]: """Create a port mirroring profile by id in a private cloud workload network. Create a port mirroring profile by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :param port_mirroring_id: NSX Port Mirroring identifier. Generally the same as the Port - Mirroring display name. + Mirroring display name. Required. :type port_mirroring_id: str - :param workload_network_port_mirroring: NSX port mirroring. - :type workload_network_port_mirroring: ~azure.mgmt.avs.models.WorkloadNetworkPortMirroring + :param workload_network_port_mirroring: NSX port mirroring. Is either a model type or a IO + type. Required. + :type workload_network_port_mirroring: ~azure.mgmt.avs.models.WorkloadNetworkPortMirroring 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. + :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 WorkloadNetworkPortMirroring 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 WorkloadNetworkPortMirroring or the + result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.WorkloadNetworkPortMirroring] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkPortMirroring"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _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.WorkloadNetworkPortMirroring] + 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_port_mirroring_initial( + raw_result = await self._create_port_mirroring_initial( # type: ignore resource_group_name=resource_group_name, private_cloud_name=private_cloud_name, port_mirroring_id=port_mirroring_id, workload_network_port_mirroring=workload_network_port_mirroring, - 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('WorkloadNetworkPortMirroring', pipeline_response) - + deserialized = self._deserialize("WorkloadNetworkPortMirroring", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'portMirroringId': self._serialize.url("port_mirroring_id", port_mirroring_id, '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_create_port_mirroring.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/portMirroringProfiles/{portMirroringId}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_port_mirroring.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/portMirroringProfiles/{portMirroringId}"} # type: ignore async def _update_port_mirroring_initial( self, resource_group_name: str, private_cloud_name: str, port_mirroring_id: str, - workload_network_port_mirroring: "_models.WorkloadNetworkPortMirroring", + workload_network_port_mirroring: Union[_models.WorkloadNetworkPortMirroring, IO], **kwargs: Any - ) -> Optional["_models.WorkloadNetworkPortMirroring"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WorkloadNetworkPortMirroring"]] + ) -> Optional[_models.WorkloadNetworkPortMirroring]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_port_mirroring_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'portMirroringId': self._serialize.url("port_mirroring_id", port_mirroring_id, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(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(workload_network_port_mirroring, 'WorkloadNetworkPortMirroring') - 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) + 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.WorkloadNetworkPortMirroring]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(workload_network_port_mirroring, (IO, bytes)): + _content = workload_network_port_mirroring + else: + _json = self._serialize.body(workload_network_port_mirroring, "WorkloadNetworkPortMirroring") + + request = build_update_port_mirroring_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + port_mirroring_id=port_mirroring_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_port_mirroring_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]: @@ -1569,128 +2368,221 @@ async def _update_port_mirroring_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('WorkloadNetworkPortMirroring', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkPortMirroring", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_port_mirroring_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/portMirroringProfiles/{portMirroringId}'} # type: ignore + _update_port_mirroring_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/portMirroringProfiles/{portMirroringId}"} # type: ignore + + @overload async def begin_update_port_mirroring( self, resource_group_name: str, private_cloud_name: str, port_mirroring_id: str, - workload_network_port_mirroring: "_models.WorkloadNetworkPortMirroring", + workload_network_port_mirroring: _models.WorkloadNetworkPortMirroring, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.WorkloadNetworkPortMirroring"]: + ) -> AsyncLROPoller[_models.WorkloadNetworkPortMirroring]: """Create or update a port mirroring profile by id in a private cloud workload network. Create or update a port mirroring profile by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :param port_mirroring_id: NSX Port Mirroring identifier. Generally the same as the Port - Mirroring display name. + Mirroring display name. Required. :type port_mirroring_id: str - :param workload_network_port_mirroring: NSX port mirroring. + :param workload_network_port_mirroring: NSX port mirroring. Required. :type workload_network_port_mirroring: ~azure.mgmt.avs.models.WorkloadNetworkPortMirroring + :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 WorkloadNetworkPortMirroring 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 WorkloadNetworkPortMirroring or the + result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.WorkloadNetworkPortMirroring] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkPortMirroring"] - 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_port_mirroring( + self, + resource_group_name: str, + private_cloud_name: str, + port_mirroring_id: str, + workload_network_port_mirroring: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WorkloadNetworkPortMirroring]: + """Create or update a port mirroring profile by id in a private cloud workload network. + + Create or update a port mirroring profile by id in a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param port_mirroring_id: NSX Port Mirroring identifier. Generally the same as the Port + Mirroring display name. Required. + :type port_mirroring_id: str + :param workload_network_port_mirroring: NSX port mirroring. Required. + :type workload_network_port_mirroring: 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 WorkloadNetworkPortMirroring or the + result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.WorkloadNetworkPortMirroring] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update_port_mirroring( + self, + resource_group_name: str, + private_cloud_name: str, + port_mirroring_id: str, + workload_network_port_mirroring: Union[_models.WorkloadNetworkPortMirroring, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.WorkloadNetworkPortMirroring]: + """Create or update a port mirroring profile by id in a private cloud workload network. + + Create or update a port mirroring profile by id in a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param port_mirroring_id: NSX Port Mirroring identifier. Generally the same as the Port + Mirroring display name. Required. + :type port_mirroring_id: str + :param workload_network_port_mirroring: NSX port mirroring. Is either a model type or a IO + type. Required. + :type workload_network_port_mirroring: ~azure.mgmt.avs.models.WorkloadNetworkPortMirroring 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 WorkloadNetworkPortMirroring or the + result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.WorkloadNetworkPortMirroring] + :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.WorkloadNetworkPortMirroring] + 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_port_mirroring_initial( + raw_result = await self._update_port_mirroring_initial( # type: ignore resource_group_name=resource_group_name, private_cloud_name=private_cloud_name, port_mirroring_id=port_mirroring_id, workload_network_port_mirroring=workload_network_port_mirroring, - 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('WorkloadNetworkPortMirroring', pipeline_response) - + deserialized = self._deserialize("WorkloadNetworkPortMirroring", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'portMirroringId': self._serialize.url("port_mirroring_id", port_mirroring_id, '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_port_mirroring.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/portMirroringProfiles/{portMirroringId}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - async def _delete_port_mirroring_initial( - self, - resource_group_name: str, - port_mirroring_id: str, - private_cloud_name: str, - **kwargs: Any + begin_update_port_mirroring.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/portMirroringProfiles/{portMirroringId}"} # type: ignore + + async def _delete_port_mirroring_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, port_mirroring_id: str, private_cloud_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_port_mirroring_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'portMirroringId': self._serialize.url("port_mirroring_id", port_mirroring_id, 'str'), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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_port_mirroring_request( + resource_group_name=resource_group_name, + port_mirroring_id=port_mirroring_id, + private_cloud_name=private_cloud_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_port_mirroring_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -1700,134 +2592,146 @@ async def _delete_port_mirroring_initial( if cls: return cls(pipeline_response, None, {}) - _delete_port_mirroring_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/portMirroringProfiles/{portMirroringId}'} # type: ignore + _delete_port_mirroring_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/portMirroringProfiles/{portMirroringId}"} # type: ignore + @distributed_trace_async async def begin_delete_port_mirroring( - self, - resource_group_name: str, - port_mirroring_id: str, - private_cloud_name: str, - **kwargs: Any + self, resource_group_name: str, port_mirroring_id: str, private_cloud_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete a port mirroring profile by id in a private cloud workload network. Delete a port mirroring profile by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param port_mirroring_id: NSX Port Mirroring identifier. Generally the same as the Port - Mirroring display name. + Mirroring display name. Required. :type port_mirroring_id: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_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_port_mirroring_initial( + raw_result = await self._delete_port_mirroring_initial( # type: ignore resource_group_name=resource_group_name, port_mirroring_id=port_mirroring_id, private_cloud_name=private_cloud_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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'portMirroringId': self._serialize.url("port_mirroring_id", port_mirroring_id, 'str'), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_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_port_mirroring.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/portMirroringProfiles/{portMirroringId}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_port_mirroring.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/portMirroringProfiles/{portMirroringId}"} # type: ignore + + @distributed_trace def list_vm_groups( - self, - resource_group_name: str, - private_cloud_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.WorkloadNetworkVMGroupsList"]: + self, resource_group_name: str, private_cloud_name: str, **kwargs: Any + ) -> AsyncIterable["_models.WorkloadNetworkVMGroup"]: """List of vm groups in a private cloud workload network. List of vm groups in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WorkloadNetworkVMGroupsList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.avs.models.WorkloadNetworkVMGroupsList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either WorkloadNetworkVMGroup or the result of + cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.avs.models.WorkloadNetworkVMGroup] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkVMGroupsList"] + _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.WorkloadNetworkVMGroupsList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_vm_groups.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - } - url = self._client.format_url(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_vm_groups_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_vm_groups.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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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('WorkloadNetworkVMGroupsList', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkVMGroupsList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1836,7 +2740,9 @@ 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]: @@ -1845,116 +2751,128 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_vm_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/vmGroups'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list_vm_groups.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/vmGroups"} # type: ignore + @distributed_trace_async async def get_vm_group( - self, - resource_group_name: str, - private_cloud_name: str, - vm_group_id: str, - **kwargs: Any - ) -> "_models.WorkloadNetworkVMGroup": + self, resource_group_name: str, private_cloud_name: str, vm_group_id: str, **kwargs: Any + ) -> _models.WorkloadNetworkVMGroup: """Get a vm group by id in a private cloud workload network. Get a vm group by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :param vm_group_id: NSX VM Group identifier. Generally the same as the VM Group's display name. + Required. :type vm_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: WorkloadNetworkVMGroup, or the result of cls(response) + :return: WorkloadNetworkVMGroup or the result of cls(response) :rtype: ~azure.mgmt.avs.models.WorkloadNetworkVMGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkVMGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.get_vm_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'vmGroupId': self._serialize.url("vm_group_id", vm_group_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') + 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.WorkloadNetworkVMGroup] + + request = build_get_vm_group_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + vm_group_id=vm_group_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_vm_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('WorkloadNetworkVMGroup', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkVMGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_vm_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/vmGroups/{vmGroupId}'} # type: ignore + + get_vm_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/vmGroups/{vmGroupId}"} # type: ignore async def _create_vm_group_initial( self, resource_group_name: str, private_cloud_name: str, vm_group_id: str, - workload_network_vm_group: "_models.WorkloadNetworkVMGroup", + workload_network_vm_group: Union[_models.WorkloadNetworkVMGroup, IO], **kwargs: Any - ) -> "_models.WorkloadNetworkVMGroup": - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkVMGroup"] + ) -> _models.WorkloadNetworkVMGroup: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_vm_group_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'vmGroupId': self._serialize.url("vm_group_id", vm_group_id, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(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(workload_network_vm_group, 'WorkloadNetworkVMGroup') - 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) + 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.WorkloadNetworkVMGroup] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(workload_network_vm_group, (IO, bytes)): + _content = workload_network_vm_group + else: + _json = self._serialize.body(workload_network_vm_group, "WorkloadNetworkVMGroup") + + request = build_create_vm_group_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + vm_group_id=vm_group_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_vm_group_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]: @@ -1962,136 +2880,239 @@ async def _create_vm_group_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('WorkloadNetworkVMGroup', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkVMGroup", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('WorkloadNetworkVMGroup', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkVMGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_vm_group_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/vmGroups/{vmGroupId}'} # type: ignore + _create_vm_group_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/vmGroups/{vmGroupId}"} # type: ignore + + @overload async def begin_create_vm_group( self, resource_group_name: str, private_cloud_name: str, vm_group_id: str, - workload_network_vm_group: "_models.WorkloadNetworkVMGroup", + workload_network_vm_group: _models.WorkloadNetworkVMGroup, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.WorkloadNetworkVMGroup"]: + ) -> AsyncLROPoller[_models.WorkloadNetworkVMGroup]: """Create a vm group by id in a private cloud workload network. Create a vm group by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :param vm_group_id: NSX VM Group identifier. Generally the same as the VM Group's display name. + Required. :type vm_group_id: str - :param workload_network_vm_group: NSX VM Group. + :param workload_network_vm_group: NSX VM Group. Required. :type workload_network_vm_group: ~azure.mgmt.avs.models.WorkloadNetworkVMGroup + :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 WorkloadNetworkVMGroup 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 WorkloadNetworkVMGroup or the result + of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.WorkloadNetworkVMGroup] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkVMGroup"] - 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_vm_group( + self, + resource_group_name: str, + private_cloud_name: str, + vm_group_id: str, + workload_network_vm_group: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WorkloadNetworkVMGroup]: + """Create a vm group by id in a private cloud workload network. + + Create a vm group by id in a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param vm_group_id: NSX VM Group identifier. Generally the same as the VM Group's display name. + Required. + :type vm_group_id: str + :param workload_network_vm_group: NSX VM Group. Required. + :type workload_network_vm_group: 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 WorkloadNetworkVMGroup or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.WorkloadNetworkVMGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_vm_group( + self, + resource_group_name: str, + private_cloud_name: str, + vm_group_id: str, + workload_network_vm_group: Union[_models.WorkloadNetworkVMGroup, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.WorkloadNetworkVMGroup]: + """Create a vm group by id in a private cloud workload network. + + Create a vm group by id in a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param vm_group_id: NSX VM Group identifier. Generally the same as the VM Group's display name. + Required. + :type vm_group_id: str + :param workload_network_vm_group: NSX VM Group. Is either a model type or a IO type. Required. + :type workload_network_vm_group: ~azure.mgmt.avs.models.WorkloadNetworkVMGroup 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 WorkloadNetworkVMGroup or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.WorkloadNetworkVMGroup] + :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.WorkloadNetworkVMGroup] + 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_vm_group_initial( + raw_result = await self._create_vm_group_initial( # type: ignore resource_group_name=resource_group_name, private_cloud_name=private_cloud_name, vm_group_id=vm_group_id, workload_network_vm_group=workload_network_vm_group, - 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('WorkloadNetworkVMGroup', pipeline_response) - + deserialized = self._deserialize("WorkloadNetworkVMGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'vmGroupId': self._serialize.url("vm_group_id", vm_group_id, '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_create_vm_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/vmGroups/{vmGroupId}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_vm_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/vmGroups/{vmGroupId}"} # type: ignore async def _update_vm_group_initial( self, resource_group_name: str, private_cloud_name: str, vm_group_id: str, - workload_network_vm_group: "_models.WorkloadNetworkVMGroup", + workload_network_vm_group: Union[_models.WorkloadNetworkVMGroup, IO], **kwargs: Any - ) -> Optional["_models.WorkloadNetworkVMGroup"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WorkloadNetworkVMGroup"]] + ) -> Optional[_models.WorkloadNetworkVMGroup]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_vm_group_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'vmGroupId': self._serialize.url("vm_group_id", vm_group_id, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(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(workload_network_vm_group, 'WorkloadNetworkVMGroup') - 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) + 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.WorkloadNetworkVMGroup]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(workload_network_vm_group, (IO, bytes)): + _content = workload_network_vm_group + else: + _json = self._serialize.body(workload_network_vm_group, "WorkloadNetworkVMGroup") + + request = build_update_vm_group_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + vm_group_id=vm_group_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_vm_group_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]: @@ -2100,127 +3121,219 @@ async def _update_vm_group_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('WorkloadNetworkVMGroup', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkVMGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_vm_group_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/vmGroups/{vmGroupId}'} # type: ignore + _update_vm_group_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/vmGroups/{vmGroupId}"} # type: ignore + + @overload + async def begin_update_vm_group( + self, + resource_group_name: str, + private_cloud_name: str, + vm_group_id: str, + workload_network_vm_group: _models.WorkloadNetworkVMGroup, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WorkloadNetworkVMGroup]: + """Create or update a vm group by id in a private cloud workload network. + + Create or update a vm group by id in a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param vm_group_id: NSX VM Group identifier. Generally the same as the VM Group's display name. + Required. + :type vm_group_id: str + :param workload_network_vm_group: NSX VM Group. Required. + :type workload_network_vm_group: ~azure.mgmt.avs.models.WorkloadNetworkVMGroup + :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 WorkloadNetworkVMGroup or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.WorkloadNetworkVMGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update_vm_group( + self, + resource_group_name: str, + private_cloud_name: str, + vm_group_id: str, + workload_network_vm_group: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WorkloadNetworkVMGroup]: + """Create or update a vm group by id in a private cloud workload network. + + Create or update a vm group by id in a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param vm_group_id: NSX VM Group identifier. Generally the same as the VM Group's display name. + Required. + :type vm_group_id: str + :param workload_network_vm_group: NSX VM Group. Required. + :type workload_network_vm_group: 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 WorkloadNetworkVMGroup or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.WorkloadNetworkVMGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async async def begin_update_vm_group( self, resource_group_name: str, private_cloud_name: str, vm_group_id: str, - workload_network_vm_group: "_models.WorkloadNetworkVMGroup", + workload_network_vm_group: Union[_models.WorkloadNetworkVMGroup, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.WorkloadNetworkVMGroup"]: + ) -> AsyncLROPoller[_models.WorkloadNetworkVMGroup]: """Create or update a vm group by id in a private cloud workload network. Create or update a vm group by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :param vm_group_id: NSX VM Group identifier. Generally the same as the VM Group's display name. + Required. :type vm_group_id: str - :param workload_network_vm_group: NSX VM Group. - :type workload_network_vm_group: ~azure.mgmt.avs.models.WorkloadNetworkVMGroup + :param workload_network_vm_group: NSX VM Group. Is either a model type or a IO type. Required. + :type workload_network_vm_group: ~azure.mgmt.avs.models.WorkloadNetworkVMGroup 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. + :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 WorkloadNetworkVMGroup 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 WorkloadNetworkVMGroup or the result + of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.WorkloadNetworkVMGroup] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkVMGroup"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _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.WorkloadNetworkVMGroup] + 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_vm_group_initial( + raw_result = await self._update_vm_group_initial( # type: ignore resource_group_name=resource_group_name, private_cloud_name=private_cloud_name, vm_group_id=vm_group_id, workload_network_vm_group=workload_network_vm_group, - 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('WorkloadNetworkVMGroup', pipeline_response) - + deserialized = self._deserialize("WorkloadNetworkVMGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'vmGroupId': self._serialize.url("vm_group_id", vm_group_id, '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_vm_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/vmGroups/{vmGroupId}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - async def _delete_vm_group_initial( - self, - resource_group_name: str, - vm_group_id: str, - private_cloud_name: str, - **kwargs: Any + begin_update_vm_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/vmGroups/{vmGroupId}"} # type: ignore + + async def _delete_vm_group_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, vm_group_id: str, private_cloud_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_vm_group_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'vmGroupId': self._serialize.url("vm_group_id", vm_group_id, 'str'), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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_vm_group_request( + resource_group_name=resource_group_name, + vm_group_id=vm_group_id, + private_cloud_name=private_cloud_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_vm_group_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -2230,133 +3343,147 @@ async def _delete_vm_group_initial( if cls: return cls(pipeline_response, None, {}) - _delete_vm_group_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/vmGroups/{vmGroupId}'} # type: ignore + _delete_vm_group_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/vmGroups/{vmGroupId}"} # type: ignore + @distributed_trace_async async def begin_delete_vm_group( - self, - resource_group_name: str, - vm_group_id: str, - private_cloud_name: str, - **kwargs: Any + self, resource_group_name: str, vm_group_id: str, private_cloud_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete a vm group by id in a private cloud workload network. Delete a vm group by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_group_id: NSX VM Group identifier. Generally the same as the VM Group's display name. + Required. :type vm_group_id: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_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_vm_group_initial( + raw_result = await self._delete_vm_group_initial( # type: ignore resource_group_name=resource_group_name, vm_group_id=vm_group_id, private_cloud_name=private_cloud_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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'vmGroupId': self._serialize.url("vm_group_id", vm_group_id, 'str'), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_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_vm_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/vmGroups/{vmGroupId}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_vm_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/vmGroups/{vmGroupId}"} # type: ignore + + @distributed_trace def list_virtual_machines( - self, - resource_group_name: str, - private_cloud_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.WorkloadNetworkVirtualMachinesList"]: + self, resource_group_name: str, private_cloud_name: str, **kwargs: Any + ) -> AsyncIterable["_models.WorkloadNetworkVirtualMachine"]: """List of virtual machines in a private cloud workload network. List of virtual machines in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WorkloadNetworkVirtualMachinesList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.avs.models.WorkloadNetworkVirtualMachinesList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either WorkloadNetworkVirtualMachine or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.avs.models.WorkloadNetworkVirtualMachine] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkVirtualMachinesList"] + _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.WorkloadNetworkVirtualMachinesList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_virtual_machines.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - } - url = self._client.format_url(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_virtual_machines_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_virtual_machines.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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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('WorkloadNetworkVirtualMachinesList', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkVirtualMachinesList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -2365,7 +3492,9 @@ 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]: @@ -2374,129 +3503,145 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_virtual_machines.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/virtualMachines'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list_virtual_machines.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/virtualMachines"} # type: ignore + @distributed_trace_async async def get_virtual_machine( - self, - resource_group_name: str, - private_cloud_name: str, - virtual_machine_id: str, - **kwargs: Any - ) -> "_models.WorkloadNetworkVirtualMachine": + self, resource_group_name: str, private_cloud_name: str, virtual_machine_id: str, **kwargs: Any + ) -> _models.WorkloadNetworkVirtualMachine: """Get a virtual machine by id in a private cloud workload network. Get a virtual machine by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param virtual_machine_id: Virtual Machine identifier. + :param virtual_machine_id: Virtual Machine identifier. Required. :type virtual_machine_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: WorkloadNetworkVirtualMachine, or the result of cls(response) + :return: WorkloadNetworkVirtualMachine or the result of cls(response) :rtype: ~azure.mgmt.avs.models.WorkloadNetworkVirtualMachine - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkVirtualMachine"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.get_virtual_machine.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'virtualMachineId': self._serialize.url("virtual_machine_id", virtual_machine_id, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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.WorkloadNetworkVirtualMachine] + + request = build_get_virtual_machine_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + virtual_machine_id=virtual_machine_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_virtual_machine.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('WorkloadNetworkVirtualMachine', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkVirtualMachine", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_virtual_machine.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/virtualMachines/{virtualMachineId}'} # type: ignore + get_virtual_machine.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/virtualMachines/{virtualMachineId}"} # type: ignore + + @distributed_trace def list_dns_services( - self, - resource_group_name: str, - private_cloud_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.WorkloadNetworkDnsServicesList"]: + self, resource_group_name: str, private_cloud_name: str, **kwargs: Any + ) -> AsyncIterable["_models.WorkloadNetworkDnsService"]: """List of DNS services in a private cloud workload network. List of DNS services in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WorkloadNetworkDnsServicesList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.avs.models.WorkloadNetworkDnsServicesList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either WorkloadNetworkDnsService or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.avs.models.WorkloadNetworkDnsService] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkDnsServicesList"] + _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.WorkloadNetworkDnsServicesList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_dns_services.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - } - url = self._client.format_url(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_dns_services_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_dns_services.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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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('WorkloadNetworkDnsServicesList', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkDnsServicesList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -2505,7 +3650,9 @@ 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]: @@ -2514,117 +3661,128 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_dns_services.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsServices'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + list_dns_services.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsServices"} # type: ignore + + @distributed_trace_async async def get_dns_service( - self, - resource_group_name: str, - private_cloud_name: str, - dns_service_id: str, - **kwargs: Any - ) -> "_models.WorkloadNetworkDnsService": + self, resource_group_name: str, private_cloud_name: str, dns_service_id: str, **kwargs: Any + ) -> _models.WorkloadNetworkDnsService: """Get a DNS service by id in a private cloud workload network. Get a DNS service by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :param dns_service_id: NSX DNS Service identifier. Generally the same as the DNS Service's - display name. + display name. Required. :type dns_service_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: WorkloadNetworkDnsService, or the result of cls(response) + :return: WorkloadNetworkDnsService or the result of cls(response) :rtype: ~azure.mgmt.avs.models.WorkloadNetworkDnsService - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkDnsService"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.get_dns_service.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'dnsServiceId': self._serialize.url("dns_service_id", dns_service_id, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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.WorkloadNetworkDnsService] + + request = build_get_dns_service_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + dns_service_id=dns_service_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_dns_service.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('WorkloadNetworkDnsService', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkDnsService", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_dns_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsServices/{dnsServiceId}'} # type: ignore + + get_dns_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsServices/{dnsServiceId}"} # type: ignore async def _create_dns_service_initial( self, resource_group_name: str, private_cloud_name: str, dns_service_id: str, - workload_network_dns_service: "_models.WorkloadNetworkDnsService", + workload_network_dns_service: Union[_models.WorkloadNetworkDnsService, IO], **kwargs: Any - ) -> "_models.WorkloadNetworkDnsService": - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkDnsService"] + ) -> _models.WorkloadNetworkDnsService: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_dns_service_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'dnsServiceId': self._serialize.url("dns_service_id", dns_service_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') - - # 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(workload_network_dns_service, 'WorkloadNetworkDnsService') - 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) + 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.WorkloadNetworkDnsService] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(workload_network_dns_service, (IO, bytes)): + _content = workload_network_dns_service + else: + _json = self._serialize.body(workload_network_dns_service, "WorkloadNetworkDnsService") + + request = build_create_dns_service_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + dns_service_id=dns_service_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_dns_service_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]: @@ -2632,137 +3790,240 @@ async def _create_dns_service_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('WorkloadNetworkDnsService', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkDnsService", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('WorkloadNetworkDnsService', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkDnsService", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_dns_service_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsServices/{dnsServiceId}'} # type: ignore + _create_dns_service_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsServices/{dnsServiceId}"} # type: ignore + + @overload async def begin_create_dns_service( self, resource_group_name: str, private_cloud_name: str, dns_service_id: str, - workload_network_dns_service: "_models.WorkloadNetworkDnsService", + workload_network_dns_service: _models.WorkloadNetworkDnsService, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.WorkloadNetworkDnsService"]: + ) -> AsyncLROPoller[_models.WorkloadNetworkDnsService]: """Create a DNS service by id in a private cloud workload network. Create a DNS service by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :param dns_service_id: NSX DNS Service identifier. Generally the same as the DNS Service's - display name. + display name. Required. :type dns_service_id: str - :param workload_network_dns_service: NSX DNS Service. + :param workload_network_dns_service: NSX DNS Service. Required. :type workload_network_dns_service: ~azure.mgmt.avs.models.WorkloadNetworkDnsService + :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 WorkloadNetworkDnsService 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 WorkloadNetworkDnsService or the + result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.WorkloadNetworkDnsService] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkDnsService"] - 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_dns_service( + self, + resource_group_name: str, + private_cloud_name: str, + dns_service_id: str, + workload_network_dns_service: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WorkloadNetworkDnsService]: + """Create a DNS service by id in a private cloud workload network. + + Create a DNS service by id in a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param dns_service_id: NSX DNS Service identifier. Generally the same as the DNS Service's + display name. Required. + :type dns_service_id: str + :param workload_network_dns_service: NSX DNS Service. Required. + :type workload_network_dns_service: 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 WorkloadNetworkDnsService or the + result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.WorkloadNetworkDnsService] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_dns_service( + self, + resource_group_name: str, + private_cloud_name: str, + dns_service_id: str, + workload_network_dns_service: Union[_models.WorkloadNetworkDnsService, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.WorkloadNetworkDnsService]: + """Create a DNS service by id in a private cloud workload network. + + Create a DNS service by id in a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param dns_service_id: NSX DNS Service identifier. Generally the same as the DNS Service's + display name. Required. + :type dns_service_id: str + :param workload_network_dns_service: NSX DNS Service. Is either a model type or a IO type. + Required. + :type workload_network_dns_service: ~azure.mgmt.avs.models.WorkloadNetworkDnsService 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 WorkloadNetworkDnsService or the + result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.WorkloadNetworkDnsService] + :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.WorkloadNetworkDnsService] + 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_dns_service_initial( + raw_result = await self._create_dns_service_initial( # type: ignore resource_group_name=resource_group_name, private_cloud_name=private_cloud_name, dns_service_id=dns_service_id, workload_network_dns_service=workload_network_dns_service, - 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('WorkloadNetworkDnsService', pipeline_response) - + deserialized = self._deserialize("WorkloadNetworkDnsService", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'dnsServiceId': self._serialize.url("dns_service_id", dns_service_id, '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_create_dns_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsServices/{dnsServiceId}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_dns_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsServices/{dnsServiceId}"} # type: ignore async def _update_dns_service_initial( self, resource_group_name: str, private_cloud_name: str, dns_service_id: str, - workload_network_dns_service: "_models.WorkloadNetworkDnsService", + workload_network_dns_service: Union[_models.WorkloadNetworkDnsService, IO], **kwargs: Any - ) -> Optional["_models.WorkloadNetworkDnsService"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WorkloadNetworkDnsService"]] + ) -> Optional[_models.WorkloadNetworkDnsService]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_dns_service_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'dnsServiceId': self._serialize.url("dns_service_id", dns_service_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') - - # 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(workload_network_dns_service, 'WorkloadNetworkDnsService') - 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) + 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.WorkloadNetworkDnsService]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(workload_network_dns_service, (IO, bytes)): + _content = workload_network_dns_service + else: + _json = self._serialize.body(workload_network_dns_service, "WorkloadNetworkDnsService") + + request = build_update_dns_service_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + dns_service_id=dns_service_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_dns_service_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]: @@ -2771,128 +4032,220 @@ async def _update_dns_service_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('WorkloadNetworkDnsService', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkDnsService", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_dns_service_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsServices/{dnsServiceId}'} # type: ignore + _update_dns_service_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsServices/{dnsServiceId}"} # type: ignore + + @overload async def begin_update_dns_service( self, resource_group_name: str, private_cloud_name: str, dns_service_id: str, - workload_network_dns_service: "_models.WorkloadNetworkDnsService", + workload_network_dns_service: _models.WorkloadNetworkDnsService, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.WorkloadNetworkDnsService"]: + ) -> AsyncLROPoller[_models.WorkloadNetworkDnsService]: """Create or update a DNS service by id in a private cloud workload network. Create or update a DNS service by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :param dns_service_id: NSX DNS Service identifier. Generally the same as the DNS Service's - display name. + display name. Required. :type dns_service_id: str - :param workload_network_dns_service: NSX DNS Service. + :param workload_network_dns_service: NSX DNS Service. Required. :type workload_network_dns_service: ~azure.mgmt.avs.models.WorkloadNetworkDnsService + :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 WorkloadNetworkDnsService 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 WorkloadNetworkDnsService or the + result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.WorkloadNetworkDnsService] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkDnsService"] - 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_dns_service( + self, + resource_group_name: str, + private_cloud_name: str, + dns_service_id: str, + workload_network_dns_service: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WorkloadNetworkDnsService]: + """Create or update a DNS service by id in a private cloud workload network. + + Create or update a DNS service by id in a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param dns_service_id: NSX DNS Service identifier. Generally the same as the DNS Service's + display name. Required. + :type dns_service_id: str + :param workload_network_dns_service: NSX DNS Service. Required. + :type workload_network_dns_service: 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 WorkloadNetworkDnsService or the + result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.WorkloadNetworkDnsService] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update_dns_service( + self, + resource_group_name: str, + private_cloud_name: str, + dns_service_id: str, + workload_network_dns_service: Union[_models.WorkloadNetworkDnsService, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.WorkloadNetworkDnsService]: + """Create or update a DNS service by id in a private cloud workload network. + + Create or update a DNS service by id in a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param dns_service_id: NSX DNS Service identifier. Generally the same as the DNS Service's + display name. Required. + :type dns_service_id: str + :param workload_network_dns_service: NSX DNS Service. Is either a model type or a IO type. + Required. + :type workload_network_dns_service: ~azure.mgmt.avs.models.WorkloadNetworkDnsService 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 WorkloadNetworkDnsService or the + result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.WorkloadNetworkDnsService] + :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.WorkloadNetworkDnsService] + 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_dns_service_initial( + raw_result = await self._update_dns_service_initial( # type: ignore resource_group_name=resource_group_name, private_cloud_name=private_cloud_name, dns_service_id=dns_service_id, workload_network_dns_service=workload_network_dns_service, - 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('WorkloadNetworkDnsService', pipeline_response) - + deserialized = self._deserialize("WorkloadNetworkDnsService", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'dnsServiceId': self._serialize.url("dns_service_id", dns_service_id, '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_dns_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsServices/{dnsServiceId}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - async def _delete_dns_service_initial( - self, - resource_group_name: str, - dns_service_id: str, - private_cloud_name: str, - **kwargs: Any + begin_update_dns_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsServices/{dnsServiceId}"} # type: ignore + + async def _delete_dns_service_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, dns_service_id: str, private_cloud_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 = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_dns_service_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'dnsServiceId': self._serialize.url("dns_service_id", dns_service_id, 'str'), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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_dns_service_request( + resource_group_name=resource_group_name, + dns_service_id=dns_service_id, + private_cloud_name=private_cloud_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_dns_service_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -2902,134 +4255,146 @@ async def _delete_dns_service_initial( if cls: return cls(pipeline_response, None, {}) - _delete_dns_service_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsServices/{dnsServiceId}'} # type: ignore + _delete_dns_service_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsServices/{dnsServiceId}"} # type: ignore + @distributed_trace_async async def begin_delete_dns_service( - self, - resource_group_name: str, - dns_service_id: str, - private_cloud_name: str, - **kwargs: Any + self, resource_group_name: str, dns_service_id: str, private_cloud_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete a DNS service by id in a private cloud workload network. Delete a DNS service by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dns_service_id: NSX DNS Service identifier. Generally the same as the DNS Service's - display name. + display name. Required. :type dns_service_id: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_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_dns_service_initial( + raw_result = await self._delete_dns_service_initial( # type: ignore resource_group_name=resource_group_name, dns_service_id=dns_service_id, private_cloud_name=private_cloud_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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'dnsServiceId': self._serialize.url("dns_service_id", dns_service_id, 'str'), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_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_dns_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsServices/{dnsServiceId}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_dns_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsServices/{dnsServiceId}"} # type: ignore + @distributed_trace def list_dns_zones( - self, - resource_group_name: str, - private_cloud_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.WorkloadNetworkDnsZonesList"]: + self, resource_group_name: str, private_cloud_name: str, **kwargs: Any + ) -> AsyncIterable["_models.WorkloadNetworkDnsZone"]: """List of DNS zones in a private cloud workload network. List of DNS zones in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WorkloadNetworkDnsZonesList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.avs.models.WorkloadNetworkDnsZonesList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either WorkloadNetworkDnsZone or the result of + cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.avs.models.WorkloadNetworkDnsZone] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkDnsZonesList"] + _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.WorkloadNetworkDnsZonesList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_dns_zones.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - } - url = self._client.format_url(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_dns_zones_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_dns_zones.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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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('WorkloadNetworkDnsZonesList', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkDnsZonesList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -3038,7 +4403,9 @@ 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]: @@ -3047,116 +4414,128 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_dns_zones.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsZones'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + list_dns_zones.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsZones"} # type: ignore + + @distributed_trace_async async def get_dns_zone( - self, - resource_group_name: str, - private_cloud_name: str, - dns_zone_id: str, - **kwargs: Any - ) -> "_models.WorkloadNetworkDnsZone": + self, resource_group_name: str, private_cloud_name: str, dns_zone_id: str, **kwargs: Any + ) -> _models.WorkloadNetworkDnsZone: """Get a DNS zone by id in a private cloud workload network. Get a DNS zone by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :param dns_zone_id: NSX DNS Zone identifier. Generally the same as the DNS Zone's display name. + Required. :type dns_zone_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: WorkloadNetworkDnsZone, or the result of cls(response) + :return: WorkloadNetworkDnsZone or the result of cls(response) :rtype: ~azure.mgmt.avs.models.WorkloadNetworkDnsZone - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkDnsZone"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.get_dns_zone.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'dnsZoneId': self._serialize.url("dns_zone_id", dns_zone_id, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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.WorkloadNetworkDnsZone] + + request = build_get_dns_zone_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + dns_zone_id=dns_zone_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_dns_zone.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('WorkloadNetworkDnsZone', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkDnsZone", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_dns_zone.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsZones/{dnsZoneId}'} # type: ignore + + get_dns_zone.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsZones/{dnsZoneId}"} # type: ignore async def _create_dns_zone_initial( self, resource_group_name: str, private_cloud_name: str, dns_zone_id: str, - workload_network_dns_zone: "_models.WorkloadNetworkDnsZone", + workload_network_dns_zone: Union[_models.WorkloadNetworkDnsZone, IO], **kwargs: Any - ) -> "_models.WorkloadNetworkDnsZone": - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkDnsZone"] + ) -> _models.WorkloadNetworkDnsZone: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_dns_zone_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'dnsZoneId': self._serialize.url("dns_zone_id", dns_zone_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') - - # 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(workload_network_dns_zone, 'WorkloadNetworkDnsZone') - 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) + 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.WorkloadNetworkDnsZone] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(workload_network_dns_zone, (IO, bytes)): + _content = workload_network_dns_zone + else: + _json = self._serialize.body(workload_network_dns_zone, "WorkloadNetworkDnsZone") + + request = build_create_dns_zone_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + dns_zone_id=dns_zone_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_dns_zone_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]: @@ -3164,136 +4543,239 @@ async def _create_dns_zone_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('WorkloadNetworkDnsZone', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkDnsZone", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('WorkloadNetworkDnsZone', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkDnsZone", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_dns_zone_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsZones/{dnsZoneId}'} # type: ignore + _create_dns_zone_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsZones/{dnsZoneId}"} # type: ignore + + @overload async def begin_create_dns_zone( self, resource_group_name: str, private_cloud_name: str, dns_zone_id: str, - workload_network_dns_zone: "_models.WorkloadNetworkDnsZone", + workload_network_dns_zone: _models.WorkloadNetworkDnsZone, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.WorkloadNetworkDnsZone"]: + ) -> AsyncLROPoller[_models.WorkloadNetworkDnsZone]: """Create a DNS zone by id in a private cloud workload network. Create a DNS zone by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :param dns_zone_id: NSX DNS Zone identifier. Generally the same as the DNS Zone's display name. + Required. :type dns_zone_id: str - :param workload_network_dns_zone: NSX DNS Zone. + :param workload_network_dns_zone: NSX DNS Zone. Required. :type workload_network_dns_zone: ~azure.mgmt.avs.models.WorkloadNetworkDnsZone + :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 WorkloadNetworkDnsZone 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 WorkloadNetworkDnsZone or the result + of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.WorkloadNetworkDnsZone] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkDnsZone"] - 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_dns_zone( + self, + resource_group_name: str, + private_cloud_name: str, + dns_zone_id: str, + workload_network_dns_zone: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WorkloadNetworkDnsZone]: + """Create a DNS zone by id in a private cloud workload network. + + Create a DNS zone by id in a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param dns_zone_id: NSX DNS Zone identifier. Generally the same as the DNS Zone's display name. + Required. + :type dns_zone_id: str + :param workload_network_dns_zone: NSX DNS Zone. Required. + :type workload_network_dns_zone: 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 WorkloadNetworkDnsZone or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.WorkloadNetworkDnsZone] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_dns_zone( + self, + resource_group_name: str, + private_cloud_name: str, + dns_zone_id: str, + workload_network_dns_zone: Union[_models.WorkloadNetworkDnsZone, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.WorkloadNetworkDnsZone]: + """Create a DNS zone by id in a private cloud workload network. + + Create a DNS zone by id in a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param dns_zone_id: NSX DNS Zone identifier. Generally the same as the DNS Zone's display name. + Required. + :type dns_zone_id: str + :param workload_network_dns_zone: NSX DNS Zone. Is either a model type or a IO type. Required. + :type workload_network_dns_zone: ~azure.mgmt.avs.models.WorkloadNetworkDnsZone 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 WorkloadNetworkDnsZone or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.WorkloadNetworkDnsZone] + :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.WorkloadNetworkDnsZone] + 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_dns_zone_initial( + raw_result = await self._create_dns_zone_initial( # type: ignore resource_group_name=resource_group_name, private_cloud_name=private_cloud_name, dns_zone_id=dns_zone_id, workload_network_dns_zone=workload_network_dns_zone, - 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('WorkloadNetworkDnsZone', pipeline_response) - + deserialized = self._deserialize("WorkloadNetworkDnsZone", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'dnsZoneId': self._serialize.url("dns_zone_id", dns_zone_id, '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_create_dns_zone.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsZones/{dnsZoneId}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_dns_zone.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsZones/{dnsZoneId}"} # type: ignore async def _update_dns_zone_initial( self, resource_group_name: str, private_cloud_name: str, dns_zone_id: str, - workload_network_dns_zone: "_models.WorkloadNetworkDnsZone", + workload_network_dns_zone: Union[_models.WorkloadNetworkDnsZone, IO], **kwargs: Any - ) -> Optional["_models.WorkloadNetworkDnsZone"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WorkloadNetworkDnsZone"]] + ) -> Optional[_models.WorkloadNetworkDnsZone]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_dns_zone_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'dnsZoneId': self._serialize.url("dns_zone_id", dns_zone_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') - - # 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(workload_network_dns_zone, 'WorkloadNetworkDnsZone') - 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) + 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.WorkloadNetworkDnsZone]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(workload_network_dns_zone, (IO, bytes)): + _content = workload_network_dns_zone + else: + _json = self._serialize.body(workload_network_dns_zone, "WorkloadNetworkDnsZone") + + request = build_update_dns_zone_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + dns_zone_id=dns_zone_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_dns_zone_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]: @@ -3302,127 +4784,219 @@ async def _update_dns_zone_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('WorkloadNetworkDnsZone', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkDnsZone", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_dns_zone_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsZones/{dnsZoneId}'} # type: ignore + _update_dns_zone_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsZones/{dnsZoneId}"} # type: ignore + + @overload async def begin_update_dns_zone( self, resource_group_name: str, private_cloud_name: str, dns_zone_id: str, - workload_network_dns_zone: "_models.WorkloadNetworkDnsZone", + workload_network_dns_zone: _models.WorkloadNetworkDnsZone, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.WorkloadNetworkDnsZone"]: + ) -> AsyncLROPoller[_models.WorkloadNetworkDnsZone]: """Create or update a DNS zone by id in a private cloud workload network. Create or update a DNS zone by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :param dns_zone_id: NSX DNS Zone identifier. Generally the same as the DNS Zone's display name. + Required. :type dns_zone_id: str - :param workload_network_dns_zone: NSX DNS Zone. + :param workload_network_dns_zone: NSX DNS Zone. Required. :type workload_network_dns_zone: ~azure.mgmt.avs.models.WorkloadNetworkDnsZone + :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 WorkloadNetworkDnsZone 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 WorkloadNetworkDnsZone or the result + of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.WorkloadNetworkDnsZone] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkDnsZone"] - 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_dns_zone( + self, + resource_group_name: str, + private_cloud_name: str, + dns_zone_id: str, + workload_network_dns_zone: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WorkloadNetworkDnsZone]: + """Create or update a DNS zone by id in a private cloud workload network. + + Create or update a DNS zone by id in a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param dns_zone_id: NSX DNS Zone identifier. Generally the same as the DNS Zone's display name. + Required. + :type dns_zone_id: str + :param workload_network_dns_zone: NSX DNS Zone. Required. + :type workload_network_dns_zone: 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 WorkloadNetworkDnsZone or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.WorkloadNetworkDnsZone] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update_dns_zone( + self, + resource_group_name: str, + private_cloud_name: str, + dns_zone_id: str, + workload_network_dns_zone: Union[_models.WorkloadNetworkDnsZone, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.WorkloadNetworkDnsZone]: + """Create or update a DNS zone by id in a private cloud workload network. + + Create or update a DNS zone by id in a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param dns_zone_id: NSX DNS Zone identifier. Generally the same as the DNS Zone's display name. + Required. + :type dns_zone_id: str + :param workload_network_dns_zone: NSX DNS Zone. Is either a model type or a IO type. Required. + :type workload_network_dns_zone: ~azure.mgmt.avs.models.WorkloadNetworkDnsZone 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 WorkloadNetworkDnsZone or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.WorkloadNetworkDnsZone] + :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.WorkloadNetworkDnsZone] + 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_dns_zone_initial( + raw_result = await self._update_dns_zone_initial( # type: ignore resource_group_name=resource_group_name, private_cloud_name=private_cloud_name, dns_zone_id=dns_zone_id, workload_network_dns_zone=workload_network_dns_zone, - 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('WorkloadNetworkDnsZone', pipeline_response) - + deserialized = self._deserialize("WorkloadNetworkDnsZone", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'dnsZoneId': self._serialize.url("dns_zone_id", dns_zone_id, '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_dns_zone.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsZones/{dnsZoneId}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - async def _delete_dns_zone_initial( - self, - resource_group_name: str, - dns_zone_id: str, - private_cloud_name: str, - **kwargs: Any + begin_update_dns_zone.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsZones/{dnsZoneId}"} # type: ignore + + async def _delete_dns_zone_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, dns_zone_id: str, private_cloud_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 = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_dns_zone_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'dnsZoneId': self._serialize.url("dns_zone_id", dns_zone_id, 'str'), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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_dns_zone_request( + resource_group_name=resource_group_name, + dns_zone_id=dns_zone_id, + private_cloud_name=private_cloud_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_dns_zone_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -3432,133 +5006,146 @@ async def _delete_dns_zone_initial( if cls: return cls(pipeline_response, None, {}) - _delete_dns_zone_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsZones/{dnsZoneId}'} # type: ignore + _delete_dns_zone_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsZones/{dnsZoneId}"} # type: ignore + @distributed_trace_async async def begin_delete_dns_zone( - self, - resource_group_name: str, - dns_zone_id: str, - private_cloud_name: str, - **kwargs: Any + self, resource_group_name: str, dns_zone_id: str, private_cloud_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete a DNS zone by id in a private cloud workload network. Delete a DNS zone by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dns_zone_id: NSX DNS Zone identifier. Generally the same as the DNS Zone's display name. + Required. :type dns_zone_id: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_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_dns_zone_initial( + raw_result = await self._delete_dns_zone_initial( # type: ignore resource_group_name=resource_group_name, dns_zone_id=dns_zone_id, private_cloud_name=private_cloud_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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'dnsZoneId': self._serialize.url("dns_zone_id", dns_zone_id, 'str'), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_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_dns_zone.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsZones/{dnsZoneId}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_dns_zone.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsZones/{dnsZoneId}"} # type: ignore + @distributed_trace def list_public_i_ps( - self, - resource_group_name: str, - private_cloud_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.WorkloadNetworkPublicIPsList"]: + self, resource_group_name: str, private_cloud_name: str, **kwargs: Any + ) -> AsyncIterable["_models.WorkloadNetworkPublicIP"]: """List of Public IP Blocks in a private cloud workload network. List of Public IP Blocks in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WorkloadNetworkPublicIPsList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.avs.models.WorkloadNetworkPublicIPsList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either WorkloadNetworkPublicIP or the result of + cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.avs.models.WorkloadNetworkPublicIP] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkPublicIPsList"] + _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.WorkloadNetworkPublicIPsList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_public_i_ps.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - } - url = self._client.format_url(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_public_i_ps_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_public_i_ps.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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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('WorkloadNetworkPublicIPsList', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkPublicIPsList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -3567,7 +5154,9 @@ 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]: @@ -3576,117 +5165,128 @@ async def get_next(next_link=None): return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_public_i_ps.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/publicIPs'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + list_public_i_ps.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/publicIPs"} # type: ignore + + @distributed_trace_async async def get_public_ip( - self, - resource_group_name: str, - private_cloud_name: str, - public_ip_id: str, - **kwargs: Any - ) -> "_models.WorkloadNetworkPublicIP": + self, resource_group_name: str, private_cloud_name: str, public_ip_id: str, **kwargs: Any + ) -> _models.WorkloadNetworkPublicIP: """Get a Public IP Block by id in a private cloud workload network. Get a Public IP Block by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :param public_ip_id: NSX Public IP Block identifier. Generally the same as the Public IP - Block's display name. + Block's display name. Required. :type public_ip_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: WorkloadNetworkPublicIP, or the result of cls(response) + :return: WorkloadNetworkPublicIP or the result of cls(response) :rtype: ~azure.mgmt.avs.models.WorkloadNetworkPublicIP - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkPublicIP"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.get_public_ip.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'publicIPId': self._serialize.url("public_ip_id", public_ip_id, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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.WorkloadNetworkPublicIP] + + request = build_get_public_ip_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + public_ip_id=public_ip_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_public_ip.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('WorkloadNetworkPublicIP', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkPublicIP", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_public_ip.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/publicIPs/{publicIPId}'} # type: ignore + + get_public_ip.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/publicIPs/{publicIPId}"} # type: ignore async def _create_public_ip_initial( self, resource_group_name: str, private_cloud_name: str, public_ip_id: str, - workload_network_public_ip: "_models.WorkloadNetworkPublicIP", + workload_network_public_ip: Union[_models.WorkloadNetworkPublicIP, IO], **kwargs: Any - ) -> "_models.WorkloadNetworkPublicIP": - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkPublicIP"] + ) -> _models.WorkloadNetworkPublicIP: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_public_ip_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'publicIPId': self._serialize.url("public_ip_id", public_ip_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') - - # 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(workload_network_public_ip, 'WorkloadNetworkPublicIP') - 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) + 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.WorkloadNetworkPublicIP] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(workload_network_public_ip, (IO, bytes)): + _content = workload_network_public_ip + else: + _json = self._serialize.body(workload_network_public_ip, "WorkloadNetworkPublicIP") + + request = build_create_public_ip_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + public_ip_id=public_ip_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_public_ip_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]: @@ -3694,131 +5294,223 @@ async def _create_public_ip_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('WorkloadNetworkPublicIP', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkPublicIP", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('WorkloadNetworkPublicIP', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkPublicIP", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_public_ip_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/publicIPs/{publicIPId}'} # type: ignore + _create_public_ip_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/publicIPs/{publicIPId}"} # type: ignore + + @overload async def begin_create_public_ip( self, resource_group_name: str, private_cloud_name: str, public_ip_id: str, - workload_network_public_ip: "_models.WorkloadNetworkPublicIP", + workload_network_public_ip: _models.WorkloadNetworkPublicIP, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.WorkloadNetworkPublicIP"]: + ) -> AsyncLROPoller[_models.WorkloadNetworkPublicIP]: """Create a Public IP Block by id in a private cloud workload network. Create a Public IP Block by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :param public_ip_id: NSX Public IP Block identifier. Generally the same as the Public IP - Block's display name. + Block's display name. Required. :type public_ip_id: str - :param workload_network_public_ip: NSX Public IP Block. + :param workload_network_public_ip: NSX Public IP Block. Required. :type workload_network_public_ip: ~azure.mgmt.avs.models.WorkloadNetworkPublicIP + :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 WorkloadNetworkPublicIP 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 WorkloadNetworkPublicIP or the + result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.WorkloadNetworkPublicIP] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkPublicIP"] - 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_public_ip( + self, + resource_group_name: str, + private_cloud_name: str, + public_ip_id: str, + workload_network_public_ip: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.WorkloadNetworkPublicIP]: + """Create a Public IP Block by id in a private cloud workload network. + + Create a Public IP Block by id in a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param public_ip_id: NSX Public IP Block identifier. Generally the same as the Public IP + Block's display name. Required. + :type public_ip_id: str + :param workload_network_public_ip: NSX Public IP Block. Required. + :type workload_network_public_ip: 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 WorkloadNetworkPublicIP or the + result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.WorkloadNetworkPublicIP] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_public_ip( + self, + resource_group_name: str, + private_cloud_name: str, + public_ip_id: str, + workload_network_public_ip: Union[_models.WorkloadNetworkPublicIP, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.WorkloadNetworkPublicIP]: + """Create a Public IP Block by id in a private cloud workload network. + + Create a Public IP Block by id in a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param public_ip_id: NSX Public IP Block identifier. Generally the same as the Public IP + Block's display name. Required. + :type public_ip_id: str + :param workload_network_public_ip: NSX Public IP Block. Is either a model type or a IO type. + Required. + :type workload_network_public_ip: ~azure.mgmt.avs.models.WorkloadNetworkPublicIP 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 WorkloadNetworkPublicIP or the + result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.avs.models.WorkloadNetworkPublicIP] + :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.WorkloadNetworkPublicIP] + 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_public_ip_initial( + raw_result = await self._create_public_ip_initial( # type: ignore resource_group_name=resource_group_name, private_cloud_name=private_cloud_name, public_ip_id=public_ip_id, workload_network_public_ip=workload_network_public_ip, - 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('WorkloadNetworkPublicIP', pipeline_response) - + deserialized = self._deserialize("WorkloadNetworkPublicIP", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'publicIPId': self._serialize.url("public_ip_id", public_ip_id, '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_create_public_ip.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/publicIPs/{publicIPId}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - async def _delete_public_ip_initial( - self, - resource_group_name: str, - public_ip_id: str, - private_cloud_name: str, - **kwargs: Any + begin_create_public_ip.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/publicIPs/{publicIPId}"} # type: ignore + + async def _delete_public_ip_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, public_ip_id: str, private_cloud_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 = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_public_ip_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'publicIPId': self._serialize.url("public_ip_id", public_ip_id, 'str'), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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_public_ip_request( + resource_group_name=resource_group_name, + public_ip_id=public_ip_id, + private_cloud_name=private_cloud_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_public_ip_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -3828,76 +5520,74 @@ async def _delete_public_ip_initial( if cls: return cls(pipeline_response, None, {}) - _delete_public_ip_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/publicIPs/{publicIPId}'} # type: ignore + _delete_public_ip_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/publicIPs/{publicIPId}"} # type: ignore + @distributed_trace_async async def begin_delete_public_ip( - self, - resource_group_name: str, - public_ip_id: str, - private_cloud_name: str, - **kwargs: Any + self, resource_group_name: str, public_ip_id: str, private_cloud_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete a Public IP Block by id in a private cloud workload network. Delete a Public IP Block by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param public_ip_id: NSX Public IP Block identifier. Generally the same as the Public IP - Block's display name. + Block's display name. Required. :type public_ip_id: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_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_public_ip_initial( + raw_result = await self._delete_public_ip_initial( # type: ignore resource_group_name=resource_group_name, public_ip_id=public_ip_id, private_cloud_name=private_cloud_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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'publicIPId': self._serialize.url("public_ip_id", public_ip_id, 'str'), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_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_public_ip.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/publicIPs/{publicIPId}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_public_ip.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/publicIPs/{publicIPId}"} # type: ignore diff --git a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/models/__init__.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/models/__init__.py index 7ec2a63b7e5b..f8d6c3f39f35 100644 --- a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/models/__init__.py +++ b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/models/__init__.py @@ -6,393 +6,316 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import Addon - from ._models_py3 import AddonHcxProperties - from ._models_py3 import AddonList - from ._models_py3 import AddonProperties - from ._models_py3 import AddonSrmProperties - from ._models_py3 import AddonVrProperties - from ._models_py3 import AdminCredentials - from ._models_py3 import AvailabilityProperties - from ._models_py3 import Circuit - from ._models_py3 import CloudLink - from ._models_py3 import CloudLinkList - from ._models_py3 import Cluster - from ._models_py3 import ClusterList - from ._models_py3 import ClusterProperties - from ._models_py3 import ClusterUpdate - from ._models_py3 import CommonClusterProperties - from ._models_py3 import Datastore - from ._models_py3 import DatastoreList - from ._models_py3 import DiskPoolVolume - from ._models_py3 import Encryption - from ._models_py3 import EncryptionKeyVaultProperties - from ._models_py3 import Endpoints - from ._models_py3 import ErrorAdditionalInfo - from ._models_py3 import ErrorResponse - from ._models_py3 import ExpressRouteAuthorization - from ._models_py3 import ExpressRouteAuthorizationList - from ._models_py3 import GlobalReachConnection - from ._models_py3 import GlobalReachConnectionList - from ._models_py3 import HcxEnterpriseSite - from ._models_py3 import HcxEnterpriseSiteList - from ._models_py3 import IdentitySource - from ._models_py3 import LogSpecification - from ._models_py3 import ManagementCluster - from ._models_py3 import MetricDimension - from ._models_py3 import MetricSpecification - from ._models_py3 import NetAppVolume - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationList - from ._models_py3 import OperationProperties - from ._models_py3 import PSCredentialExecutionParameter - from ._models_py3 import PlacementPoliciesList - from ._models_py3 import PlacementPolicy - from ._models_py3 import PlacementPolicyProperties - from ._models_py3 import PlacementPolicyUpdate - from ._models_py3 import PrivateCloud - from ._models_py3 import PrivateCloudIdentity - from ._models_py3 import PrivateCloudList - from ._models_py3 import PrivateCloudProperties - from ._models_py3 import PrivateCloudUpdate - from ._models_py3 import PrivateCloudUpdateProperties - from ._models_py3 import ProxyResource - from ._models_py3 import Quota - from ._models_py3 import Resource - from ._models_py3 import ScriptCmdlet - from ._models_py3 import ScriptCmdletsList - from ._models_py3 import ScriptExecution - from ._models_py3 import ScriptExecutionParameter - from ._models_py3 import ScriptExecutionsList - from ._models_py3 import ScriptPackage - from ._models_py3 import ScriptPackagesList - from ._models_py3 import ScriptParameter - from ._models_py3 import ScriptSecureStringExecutionParameter - from ._models_py3 import ScriptStringExecutionParameter - from ._models_py3 import ServiceSpecification - from ._models_py3 import Sku - from ._models_py3 import TrackedResource - from ._models_py3 import Trial - from ._models_py3 import VirtualMachine - from ._models_py3 import VirtualMachineRestrictMovement - from ._models_py3 import VirtualMachinesList - from ._models_py3 import VmHostPlacementPolicyProperties - from ._models_py3 import VmPlacementPolicyProperties - from ._models_py3 import WorkloadNetworkDhcp - from ._models_py3 import WorkloadNetworkDhcpEntity - from ._models_py3 import WorkloadNetworkDhcpList - from ._models_py3 import WorkloadNetworkDhcpRelay - from ._models_py3 import WorkloadNetworkDhcpServer - from ._models_py3 import WorkloadNetworkDnsService - from ._models_py3 import WorkloadNetworkDnsServicesList - from ._models_py3 import WorkloadNetworkDnsZone - from ._models_py3 import WorkloadNetworkDnsZonesList - from ._models_py3 import WorkloadNetworkGateway - from ._models_py3 import WorkloadNetworkGatewayList - from ._models_py3 import WorkloadNetworkPortMirroring - from ._models_py3 import WorkloadNetworkPortMirroringList - from ._models_py3 import WorkloadNetworkPublicIP - from ._models_py3 import WorkloadNetworkPublicIPsList - from ._models_py3 import WorkloadNetworkSegment - from ._models_py3 import WorkloadNetworkSegmentPortVif - from ._models_py3 import WorkloadNetworkSegmentSubnet - from ._models_py3 import WorkloadNetworkSegmentsList - from ._models_py3 import WorkloadNetworkVMGroup - from ._models_py3 import WorkloadNetworkVMGroupsList - from ._models_py3 import WorkloadNetworkVirtualMachine - from ._models_py3 import WorkloadNetworkVirtualMachinesList -except (SyntaxError, ImportError): - from ._models import Addon # type: ignore - from ._models import AddonHcxProperties # type: ignore - from ._models import AddonList # type: ignore - from ._models import AddonProperties # type: ignore - from ._models import AddonSrmProperties # type: ignore - from ._models import AddonVrProperties # type: ignore - from ._models import AdminCredentials # type: ignore - from ._models import AvailabilityProperties # type: ignore - from ._models import Circuit # type: ignore - from ._models import CloudLink # type: ignore - from ._models import CloudLinkList # type: ignore - from ._models import Cluster # type: ignore - from ._models import ClusterList # type: ignore - from ._models import ClusterProperties # type: ignore - from ._models import ClusterUpdate # type: ignore - from ._models import CommonClusterProperties # type: ignore - from ._models import Datastore # type: ignore - from ._models import DatastoreList # type: ignore - from ._models import DiskPoolVolume # type: ignore - from ._models import Encryption # type: ignore - from ._models import EncryptionKeyVaultProperties # type: ignore - from ._models import Endpoints # type: ignore - from ._models import ErrorAdditionalInfo # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import ExpressRouteAuthorization # type: ignore - from ._models import ExpressRouteAuthorizationList # type: ignore - from ._models import GlobalReachConnection # type: ignore - from ._models import GlobalReachConnectionList # type: ignore - from ._models import HcxEnterpriseSite # type: ignore - from ._models import HcxEnterpriseSiteList # type: ignore - from ._models import IdentitySource # type: ignore - from ._models import LogSpecification # type: ignore - from ._models import ManagementCluster # type: ignore - from ._models import MetricDimension # type: ignore - from ._models import MetricSpecification # type: ignore - from ._models import NetAppVolume # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationList # type: ignore - from ._models import OperationProperties # type: ignore - from ._models import PSCredentialExecutionParameter # type: ignore - from ._models import PlacementPoliciesList # type: ignore - from ._models import PlacementPolicy # type: ignore - from ._models import PlacementPolicyProperties # type: ignore - from ._models import PlacementPolicyUpdate # type: ignore - from ._models import PrivateCloud # type: ignore - from ._models import PrivateCloudIdentity # type: ignore - from ._models import PrivateCloudList # type: ignore - from ._models import PrivateCloudProperties # type: ignore - from ._models import PrivateCloudUpdate # type: ignore - from ._models import PrivateCloudUpdateProperties # type: ignore - from ._models import ProxyResource # type: ignore - from ._models import Quota # type: ignore - from ._models import Resource # type: ignore - from ._models import ScriptCmdlet # type: ignore - from ._models import ScriptCmdletsList # type: ignore - from ._models import ScriptExecution # type: ignore - from ._models import ScriptExecutionParameter # type: ignore - from ._models import ScriptExecutionsList # type: ignore - from ._models import ScriptPackage # type: ignore - from ._models import ScriptPackagesList # type: ignore - from ._models import ScriptParameter # type: ignore - from ._models import ScriptSecureStringExecutionParameter # type: ignore - from ._models import ScriptStringExecutionParameter # type: ignore - from ._models import ServiceSpecification # type: ignore - from ._models import Sku # type: ignore - from ._models import TrackedResource # type: ignore - from ._models import Trial # type: ignore - from ._models import VirtualMachine # type: ignore - from ._models import VirtualMachineRestrictMovement # type: ignore - from ._models import VirtualMachinesList # type: ignore - from ._models import VmHostPlacementPolicyProperties # type: ignore - from ._models import VmPlacementPolicyProperties # type: ignore - from ._models import WorkloadNetworkDhcp # type: ignore - from ._models import WorkloadNetworkDhcpEntity # type: ignore - from ._models import WorkloadNetworkDhcpList # type: ignore - from ._models import WorkloadNetworkDhcpRelay # type: ignore - from ._models import WorkloadNetworkDhcpServer # type: ignore - from ._models import WorkloadNetworkDnsService # type: ignore - from ._models import WorkloadNetworkDnsServicesList # type: ignore - from ._models import WorkloadNetworkDnsZone # type: ignore - from ._models import WorkloadNetworkDnsZonesList # type: ignore - from ._models import WorkloadNetworkGateway # type: ignore - from ._models import WorkloadNetworkGatewayList # type: ignore - from ._models import WorkloadNetworkPortMirroring # type: ignore - from ._models import WorkloadNetworkPortMirroringList # type: ignore - from ._models import WorkloadNetworkPublicIP # type: ignore - from ._models import WorkloadNetworkPublicIPsList # type: ignore - from ._models import WorkloadNetworkSegment # type: ignore - from ._models import WorkloadNetworkSegmentPortVif # type: ignore - from ._models import WorkloadNetworkSegmentSubnet # type: ignore - from ._models import WorkloadNetworkSegmentsList # type: ignore - from ._models import WorkloadNetworkVMGroup # type: ignore - from ._models import WorkloadNetworkVMGroupsList # type: ignore - from ._models import WorkloadNetworkVirtualMachine # type: ignore - from ._models import WorkloadNetworkVirtualMachinesList # type: ignore +from ._models_py3 import Addon +from ._models_py3 import AddonArcProperties +from ._models_py3 import AddonHcxProperties +from ._models_py3 import AddonList +from ._models_py3 import AddonProperties +from ._models_py3 import AddonSrmProperties +from ._models_py3 import AddonVrProperties +from ._models_py3 import AdminCredentials +from ._models_py3 import AvailabilityProperties +from ._models_py3 import Circuit +from ._models_py3 import CloudLink +from ._models_py3 import CloudLinkList +from ._models_py3 import Cluster +from ._models_py3 import ClusterList +from ._models_py3 import ClusterProperties +from ._models_py3 import ClusterUpdate +from ._models_py3 import ClusterZone +from ._models_py3 import ClusterZoneList +from ._models_py3 import CommonClusterProperties +from ._models_py3 import Datastore +from ._models_py3 import DatastoreList +from ._models_py3 import DiskPoolVolume +from ._models_py3 import Encryption +from ._models_py3 import EncryptionKeyVaultProperties +from ._models_py3 import Endpoints +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorResponse +from ._models_py3 import ExpressRouteAuthorization +from ._models_py3 import ExpressRouteAuthorizationList +from ._models_py3 import GlobalReachConnection +from ._models_py3 import GlobalReachConnectionList +from ._models_py3 import HcxEnterpriseSite +from ._models_py3 import HcxEnterpriseSiteList +from ._models_py3 import IdentitySource +from ._models_py3 import LogSpecification +from ._models_py3 import ManagementCluster +from ._models_py3 import MetricDimension +from ._models_py3 import MetricSpecification +from ._models_py3 import NetAppVolume +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationList +from ._models_py3 import OperationProperties +from ._models_py3 import PSCredentialExecutionParameter +from ._models_py3 import PlacementPoliciesList +from ._models_py3 import PlacementPolicy +from ._models_py3 import PlacementPolicyProperties +from ._models_py3 import PlacementPolicyUpdate +from ._models_py3 import PrivateCloud +from ._models_py3 import PrivateCloudIdentity +from ._models_py3 import PrivateCloudList +from ._models_py3 import PrivateCloudProperties +from ._models_py3 import PrivateCloudUpdate +from ._models_py3 import PrivateCloudUpdateProperties +from ._models_py3 import ProxyResource +from ._models_py3 import Quota +from ._models_py3 import Resource +from ._models_py3 import ScriptCmdlet +from ._models_py3 import ScriptCmdletsList +from ._models_py3 import ScriptExecution +from ._models_py3 import ScriptExecutionParameter +from ._models_py3 import ScriptExecutionsList +from ._models_py3 import ScriptPackage +from ._models_py3 import ScriptPackagesList +from ._models_py3 import ScriptParameter +from ._models_py3 import ScriptSecureStringExecutionParameter +from ._models_py3 import ScriptStringExecutionParameter +from ._models_py3 import ServiceSpecification +from ._models_py3 import Sku +from ._models_py3 import TrackedResource +from ._models_py3 import Trial +from ._models_py3 import VirtualMachine +from ._models_py3 import VirtualMachineRestrictMovement +from ._models_py3 import VirtualMachinesList +from ._models_py3 import VmHostPlacementPolicyProperties +from ._models_py3 import VmPlacementPolicyProperties +from ._models_py3 import WorkloadNetwork +from ._models_py3 import WorkloadNetworkDhcp +from ._models_py3 import WorkloadNetworkDhcpEntity +from ._models_py3 import WorkloadNetworkDhcpList +from ._models_py3 import WorkloadNetworkDhcpRelay +from ._models_py3 import WorkloadNetworkDhcpServer +from ._models_py3 import WorkloadNetworkDnsService +from ._models_py3 import WorkloadNetworkDnsServicesList +from ._models_py3 import WorkloadNetworkDnsZone +from ._models_py3 import WorkloadNetworkDnsZonesList +from ._models_py3 import WorkloadNetworkGateway +from ._models_py3 import WorkloadNetworkGatewayList +from ._models_py3 import WorkloadNetworkList +from ._models_py3 import WorkloadNetworkPortMirroring +from ._models_py3 import WorkloadNetworkPortMirroringList +from ._models_py3 import WorkloadNetworkPublicIP +from ._models_py3 import WorkloadNetworkPublicIPsList +from ._models_py3 import WorkloadNetworkSegment +from ._models_py3 import WorkloadNetworkSegmentPortVif +from ._models_py3 import WorkloadNetworkSegmentSubnet +from ._models_py3 import WorkloadNetworkSegmentsList +from ._models_py3 import WorkloadNetworkVMGroup +from ._models_py3 import WorkloadNetworkVMGroupsList +from ._models_py3 import WorkloadNetworkVirtualMachine +from ._models_py3 import WorkloadNetworkVirtualMachinesList -from ._avs_client_enums import ( - AddonProvisioningState, - AddonType, - AffinityType, - AvailabilityStrategy, - CloudLinkStatus, - ClusterProvisioningState, - DatastoreProvisioningState, - DatastoreStatus, - DhcpTypeEnum, - DnsServiceLogLevelEnum, - DnsServiceStatusEnum, - EncryptionKeyStatus, - EncryptionState, - EncryptionVersionType, - ExpressRouteAuthorizationProvisioningState, - GlobalReachConnectionProvisioningState, - GlobalReachConnectionStatus, - HcxEnterpriseSiteStatus, - InternetEnum, - MountOptionEnum, - OptionalParamEnum, - PlacementPolicyProvisioningState, - PlacementPolicyState, - PlacementPolicyType, - PortMirroringDirectionEnum, - PortMirroringStatusEnum, - PrivateCloudProvisioningState, - QuotaEnabled, - ResourceIdentityType, - ScriptExecutionParameterType, - ScriptExecutionProvisioningState, - ScriptOutputStreamType, - ScriptParameterTypes, - SegmentStatusEnum, - SslEnum, - TrialStatus, - VMGroupStatusEnum, - VMTypeEnum, - VirtualMachineRestrictMovementState, - VisibilityParameterEnum, - WorkloadNetworkDhcpProvisioningState, - WorkloadNetworkDnsServiceProvisioningState, - WorkloadNetworkDnsZoneProvisioningState, - WorkloadNetworkPortMirroringProvisioningState, - WorkloadNetworkPublicIPProvisioningState, - WorkloadNetworkSegmentProvisioningState, - WorkloadNetworkVMGroupProvisioningState, -) +from ._avs_client_enums import AddonProvisioningState +from ._avs_client_enums import AddonType +from ._avs_client_enums import AffinityStrength +from ._avs_client_enums import AffinityType +from ._avs_client_enums import AvailabilityStrategy +from ._avs_client_enums import AzureHybridBenefitType +from ._avs_client_enums import CloudLinkStatus +from ._avs_client_enums import ClusterProvisioningState +from ._avs_client_enums import DatastoreProvisioningState +from ._avs_client_enums import DatastoreStatus +from ._avs_client_enums import DhcpTypeEnum +from ._avs_client_enums import DnsServiceLogLevelEnum +from ._avs_client_enums import DnsServiceStatusEnum +from ._avs_client_enums import EncryptionKeyStatus +from ._avs_client_enums import EncryptionState +from ._avs_client_enums import EncryptionVersionType +from ._avs_client_enums import ExpressRouteAuthorizationProvisioningState +from ._avs_client_enums import GlobalReachConnectionProvisioningState +from ._avs_client_enums import GlobalReachConnectionStatus +from ._avs_client_enums import HcxEnterpriseSiteStatus +from ._avs_client_enums import InternetEnum +from ._avs_client_enums import MountOptionEnum +from ._avs_client_enums import NsxPublicIpQuotaRaisedEnum +from ._avs_client_enums import OptionalParamEnum +from ._avs_client_enums import PlacementPolicyProvisioningState +from ._avs_client_enums import PlacementPolicyState +from ._avs_client_enums import PlacementPolicyType +from ._avs_client_enums import PortMirroringDirectionEnum +from ._avs_client_enums import PortMirroringStatusEnum +from ._avs_client_enums import PrivateCloudProvisioningState +from ._avs_client_enums import QuotaEnabled +from ._avs_client_enums import ResourceIdentityType +from ._avs_client_enums import ScriptExecutionParameterType +from ._avs_client_enums import ScriptExecutionProvisioningState +from ._avs_client_enums import ScriptOutputStreamType +from ._avs_client_enums import ScriptParameterTypes +from ._avs_client_enums import SegmentStatusEnum +from ._avs_client_enums import SslEnum +from ._avs_client_enums import TrialStatus +from ._avs_client_enums import VMGroupStatusEnum +from ._avs_client_enums import VMTypeEnum +from ._avs_client_enums import VirtualMachineRestrictMovementState +from ._avs_client_enums import VisibilityParameterEnum +from ._avs_client_enums import WorkloadNetworkDhcpProvisioningState +from ._avs_client_enums import WorkloadNetworkDnsServiceProvisioningState +from ._avs_client_enums import WorkloadNetworkDnsZoneProvisioningState +from ._avs_client_enums import WorkloadNetworkName +from ._avs_client_enums import WorkloadNetworkPortMirroringProvisioningState +from ._avs_client_enums import WorkloadNetworkPublicIPProvisioningState +from ._avs_client_enums import WorkloadNetworkSegmentProvisioningState +from ._avs_client_enums import WorkloadNetworkVMGroupProvisioningState +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__ = [ - 'Addon', - 'AddonHcxProperties', - 'AddonList', - 'AddonProperties', - 'AddonSrmProperties', - 'AddonVrProperties', - 'AdminCredentials', - 'AvailabilityProperties', - 'Circuit', - 'CloudLink', - 'CloudLinkList', - 'Cluster', - 'ClusterList', - 'ClusterProperties', - 'ClusterUpdate', - 'CommonClusterProperties', - 'Datastore', - 'DatastoreList', - 'DiskPoolVolume', - 'Encryption', - 'EncryptionKeyVaultProperties', - 'Endpoints', - 'ErrorAdditionalInfo', - 'ErrorResponse', - 'ExpressRouteAuthorization', - 'ExpressRouteAuthorizationList', - 'GlobalReachConnection', - 'GlobalReachConnectionList', - 'HcxEnterpriseSite', - 'HcxEnterpriseSiteList', - 'IdentitySource', - 'LogSpecification', - 'ManagementCluster', - 'MetricDimension', - 'MetricSpecification', - 'NetAppVolume', - 'Operation', - 'OperationDisplay', - 'OperationList', - 'OperationProperties', - 'PSCredentialExecutionParameter', - 'PlacementPoliciesList', - 'PlacementPolicy', - 'PlacementPolicyProperties', - 'PlacementPolicyUpdate', - 'PrivateCloud', - 'PrivateCloudIdentity', - 'PrivateCloudList', - 'PrivateCloudProperties', - 'PrivateCloudUpdate', - 'PrivateCloudUpdateProperties', - 'ProxyResource', - 'Quota', - 'Resource', - 'ScriptCmdlet', - 'ScriptCmdletsList', - 'ScriptExecution', - 'ScriptExecutionParameter', - 'ScriptExecutionsList', - 'ScriptPackage', - 'ScriptPackagesList', - 'ScriptParameter', - 'ScriptSecureStringExecutionParameter', - 'ScriptStringExecutionParameter', - 'ServiceSpecification', - 'Sku', - 'TrackedResource', - 'Trial', - 'VirtualMachine', - 'VirtualMachineRestrictMovement', - 'VirtualMachinesList', - 'VmHostPlacementPolicyProperties', - 'VmPlacementPolicyProperties', - 'WorkloadNetworkDhcp', - 'WorkloadNetworkDhcpEntity', - 'WorkloadNetworkDhcpList', - 'WorkloadNetworkDhcpRelay', - 'WorkloadNetworkDhcpServer', - 'WorkloadNetworkDnsService', - 'WorkloadNetworkDnsServicesList', - 'WorkloadNetworkDnsZone', - 'WorkloadNetworkDnsZonesList', - 'WorkloadNetworkGateway', - 'WorkloadNetworkGatewayList', - 'WorkloadNetworkPortMirroring', - 'WorkloadNetworkPortMirroringList', - 'WorkloadNetworkPublicIP', - 'WorkloadNetworkPublicIPsList', - 'WorkloadNetworkSegment', - 'WorkloadNetworkSegmentPortVif', - 'WorkloadNetworkSegmentSubnet', - 'WorkloadNetworkSegmentsList', - 'WorkloadNetworkVMGroup', - 'WorkloadNetworkVMGroupsList', - 'WorkloadNetworkVirtualMachine', - 'WorkloadNetworkVirtualMachinesList', - 'AddonProvisioningState', - 'AddonType', - 'AffinityType', - 'AvailabilityStrategy', - 'CloudLinkStatus', - 'ClusterProvisioningState', - 'DatastoreProvisioningState', - 'DatastoreStatus', - 'DhcpTypeEnum', - 'DnsServiceLogLevelEnum', - 'DnsServiceStatusEnum', - 'EncryptionKeyStatus', - 'EncryptionState', - 'EncryptionVersionType', - 'ExpressRouteAuthorizationProvisioningState', - 'GlobalReachConnectionProvisioningState', - 'GlobalReachConnectionStatus', - 'HcxEnterpriseSiteStatus', - 'InternetEnum', - 'MountOptionEnum', - 'OptionalParamEnum', - 'PlacementPolicyProvisioningState', - 'PlacementPolicyState', - 'PlacementPolicyType', - 'PortMirroringDirectionEnum', - 'PortMirroringStatusEnum', - 'PrivateCloudProvisioningState', - 'QuotaEnabled', - 'ResourceIdentityType', - 'ScriptExecutionParameterType', - 'ScriptExecutionProvisioningState', - 'ScriptOutputStreamType', - 'ScriptParameterTypes', - 'SegmentStatusEnum', - 'SslEnum', - 'TrialStatus', - 'VMGroupStatusEnum', - 'VMTypeEnum', - 'VirtualMachineRestrictMovementState', - 'VisibilityParameterEnum', - 'WorkloadNetworkDhcpProvisioningState', - 'WorkloadNetworkDnsServiceProvisioningState', - 'WorkloadNetworkDnsZoneProvisioningState', - 'WorkloadNetworkPortMirroringProvisioningState', - 'WorkloadNetworkPublicIPProvisioningState', - 'WorkloadNetworkSegmentProvisioningState', - 'WorkloadNetworkVMGroupProvisioningState', + "Addon", + "AddonArcProperties", + "AddonHcxProperties", + "AddonList", + "AddonProperties", + "AddonSrmProperties", + "AddonVrProperties", + "AdminCredentials", + "AvailabilityProperties", + "Circuit", + "CloudLink", + "CloudLinkList", + "Cluster", + "ClusterList", + "ClusterProperties", + "ClusterUpdate", + "ClusterZone", + "ClusterZoneList", + "CommonClusterProperties", + "Datastore", + "DatastoreList", + "DiskPoolVolume", + "Encryption", + "EncryptionKeyVaultProperties", + "Endpoints", + "ErrorAdditionalInfo", + "ErrorResponse", + "ExpressRouteAuthorization", + "ExpressRouteAuthorizationList", + "GlobalReachConnection", + "GlobalReachConnectionList", + "HcxEnterpriseSite", + "HcxEnterpriseSiteList", + "IdentitySource", + "LogSpecification", + "ManagementCluster", + "MetricDimension", + "MetricSpecification", + "NetAppVolume", + "Operation", + "OperationDisplay", + "OperationList", + "OperationProperties", + "PSCredentialExecutionParameter", + "PlacementPoliciesList", + "PlacementPolicy", + "PlacementPolicyProperties", + "PlacementPolicyUpdate", + "PrivateCloud", + "PrivateCloudIdentity", + "PrivateCloudList", + "PrivateCloudProperties", + "PrivateCloudUpdate", + "PrivateCloudUpdateProperties", + "ProxyResource", + "Quota", + "Resource", + "ScriptCmdlet", + "ScriptCmdletsList", + "ScriptExecution", + "ScriptExecutionParameter", + "ScriptExecutionsList", + "ScriptPackage", + "ScriptPackagesList", + "ScriptParameter", + "ScriptSecureStringExecutionParameter", + "ScriptStringExecutionParameter", + "ServiceSpecification", + "Sku", + "TrackedResource", + "Trial", + "VirtualMachine", + "VirtualMachineRestrictMovement", + "VirtualMachinesList", + "VmHostPlacementPolicyProperties", + "VmPlacementPolicyProperties", + "WorkloadNetwork", + "WorkloadNetworkDhcp", + "WorkloadNetworkDhcpEntity", + "WorkloadNetworkDhcpList", + "WorkloadNetworkDhcpRelay", + "WorkloadNetworkDhcpServer", + "WorkloadNetworkDnsService", + "WorkloadNetworkDnsServicesList", + "WorkloadNetworkDnsZone", + "WorkloadNetworkDnsZonesList", + "WorkloadNetworkGateway", + "WorkloadNetworkGatewayList", + "WorkloadNetworkList", + "WorkloadNetworkPortMirroring", + "WorkloadNetworkPortMirroringList", + "WorkloadNetworkPublicIP", + "WorkloadNetworkPublicIPsList", + "WorkloadNetworkSegment", + "WorkloadNetworkSegmentPortVif", + "WorkloadNetworkSegmentSubnet", + "WorkloadNetworkSegmentsList", + "WorkloadNetworkVMGroup", + "WorkloadNetworkVMGroupsList", + "WorkloadNetworkVirtualMachine", + "WorkloadNetworkVirtualMachinesList", + "AddonProvisioningState", + "AddonType", + "AffinityStrength", + "AffinityType", + "AvailabilityStrategy", + "AzureHybridBenefitType", + "CloudLinkStatus", + "ClusterProvisioningState", + "DatastoreProvisioningState", + "DatastoreStatus", + "DhcpTypeEnum", + "DnsServiceLogLevelEnum", + "DnsServiceStatusEnum", + "EncryptionKeyStatus", + "EncryptionState", + "EncryptionVersionType", + "ExpressRouteAuthorizationProvisioningState", + "GlobalReachConnectionProvisioningState", + "GlobalReachConnectionStatus", + "HcxEnterpriseSiteStatus", + "InternetEnum", + "MountOptionEnum", + "NsxPublicIpQuotaRaisedEnum", + "OptionalParamEnum", + "PlacementPolicyProvisioningState", + "PlacementPolicyState", + "PlacementPolicyType", + "PortMirroringDirectionEnum", + "PortMirroringStatusEnum", + "PrivateCloudProvisioningState", + "QuotaEnabled", + "ResourceIdentityType", + "ScriptExecutionParameterType", + "ScriptExecutionProvisioningState", + "ScriptOutputStreamType", + "ScriptParameterTypes", + "SegmentStatusEnum", + "SslEnum", + "TrialStatus", + "VMGroupStatusEnum", + "VMTypeEnum", + "VirtualMachineRestrictMovementState", + "VisibilityParameterEnum", + "WorkloadNetworkDhcpProvisioningState", + "WorkloadNetworkDnsServiceProvisioningState", + "WorkloadNetworkDnsZoneProvisioningState", + "WorkloadNetworkName", + "WorkloadNetworkPortMirroringProvisioningState", + "WorkloadNetworkPublicIPProvisioningState", + "WorkloadNetworkSegmentProvisioningState", + "WorkloadNetworkVMGroupProvisioningState", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/models/_avs_client_enums.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/models/_avs_client_enums.py index 8ce01af77eca..d0d1e671127a 100644 --- a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/models/_avs_client_enums.py +++ b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/models/_avs_client_enums.py @@ -6,29 +6,12 @@ # 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 AddonProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The state of the addon provisioning - """ +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class AddonProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The state of the addon provisioning.""" SUCCEEDED = "Succeeded" FAILED = "Failed" @@ -36,32 +19,48 @@ class AddonProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum) BUILDING = "Building" DELETING = "Deleting" UPDATING = "Updating" + CANCELED = "Canceled" -class AddonType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The type of private cloud addon - """ + +class AddonType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of private cloud addon.""" SRM = "SRM" VR = "VR" HCX = "HCX" + ARC = "Arc" -class AffinityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Placement policy affinity type - """ + +class AffinityStrength(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """VM-Host placement policy affinity strength (should/must).""" + + SHOULD = "Should" + MUST = "Must" + + +class AffinityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Placement policy affinity type.""" AFFINITY = "Affinity" ANTI_AFFINITY = "AntiAffinity" -class AvailabilityStrategy(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The availability strategy for the private cloud - """ + +class AvailabilityStrategy(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The availability strategy for the private cloud.""" SINGLE_ZONE = "SingleZone" DUAL_ZONE = "DualZone" -class CloudLinkStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The state of the cloud link. - """ + +class AzureHybridBenefitType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Placement policy hosts opt-in Azure Hybrid Benefit type.""" + + SQL_HOST = "SqlHost" + NONE = "None" + + +class CloudLinkStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The state of the cloud link.""" ACTIVE = "Active" BUILDING = "Building" @@ -69,19 +68,20 @@ class CloudLinkStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FAILED = "Failed" DISCONNECTED = "Disconnected" -class ClusterProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The state of the cluster provisioning - """ + +class ClusterProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The state of the cluster provisioning.""" SUCCEEDED = "Succeeded" FAILED = "Failed" CANCELLED = "Cancelled" DELETING = "Deleting" UPDATING = "Updating" + CANCELED = "Canceled" -class DatastoreProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The state of the datastore provisioning - """ + +class DatastoreProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The state of the datastore provisioning.""" SUCCEEDED = "Succeeded" FAILED = "Failed" @@ -90,10 +90,11 @@ class DatastoreProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, E CREATING = "Creating" UPDATING = "Updating" DELETING = "Deleting" + CANCELED = "Canceled" -class DatastoreStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The operational status of the datastore - """ + +class DatastoreStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The operational status of the datastore.""" UNKNOWN = "Unknown" ACCESSIBLE = "Accessible" @@ -103,16 +104,16 @@ class DatastoreStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): LOST_COMMUNICATION = "LostCommunication" DEAD_OR_ERROR = "DeadOrError" -class DhcpTypeEnum(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Type of DHCP: SERVER or RELAY. - """ + +class DhcpTypeEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of DHCP: SERVER or RELAY.""" SERVER = "SERVER" RELAY = "RELAY" -class DnsServiceLogLevelEnum(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """DNS Service log level. - """ + +class DnsServiceLogLevelEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """DNS Service log level.""" DEBUG = "DEBUG" INFO = "INFO" @@ -120,130 +121,142 @@ class DnsServiceLogLevelEnum(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum) ERROR = "ERROR" FATAL = "FATAL" -class DnsServiceStatusEnum(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """DNS Service status. - """ + +class DnsServiceStatusEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """DNS Service status.""" SUCCESS = "SUCCESS" FAILURE = "FAILURE" -class EncryptionKeyStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The state of key provided - """ + +class EncryptionKeyStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The state of key provided.""" CONNECTED = "Connected" ACCESS_DENIED = "AccessDenied" -class EncryptionState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Status of customer managed encryption key - """ + +class EncryptionState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Status of customer managed encryption key.""" ENABLED = "Enabled" DISABLED = "Disabled" -class EncryptionVersionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Property of the key if user provided or auto detected - """ + +class EncryptionVersionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Property of the key if user provided or auto detected.""" FIXED = "Fixed" AUTO_DETECTED = "AutoDetected" -class ExpressRouteAuthorizationProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The state of the ExpressRoute Circuit Authorization provisioning - """ + +class ExpressRouteAuthorizationProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The state of the ExpressRoute Circuit Authorization provisioning.""" SUCCEEDED = "Succeeded" FAILED = "Failed" UPDATING = "Updating" + CANCELED = "Canceled" -class GlobalReachConnectionProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The state of the ExpressRoute Circuit Authorization provisioning - """ + +class GlobalReachConnectionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The state of the ExpressRoute Circuit Authorization provisioning.""" SUCCEEDED = "Succeeded" FAILED = "Failed" UPDATING = "Updating" + CANCELED = "Canceled" -class GlobalReachConnectionStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The connection status of the global reach connection - """ + +class GlobalReachConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The connection status of the global reach connection.""" CONNECTED = "Connected" CONNECTING = "Connecting" DISCONNECTED = "Disconnected" -class HcxEnterpriseSiteStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The status of the HCX Enterprise Site - """ + +class HcxEnterpriseSiteStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the HCX Enterprise Site.""" AVAILABLE = "Available" CONSUMED = "Consumed" DEACTIVATED = "Deactivated" DELETED = "Deleted" -class InternetEnum(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Connectivity to internet is enabled or disabled - """ + +class InternetEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Connectivity to internet is enabled or disabled.""" ENABLED = "Enabled" DISABLED = "Disabled" -class MountOptionEnum(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Mode that describes whether the LUN has to be mounted as a datastore or attached as a LUN - """ + +class MountOptionEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Mode that describes whether the LUN has to be mounted as a datastore or attached as a LUN.""" MOUNT = "MOUNT" ATTACH = "ATTACH" -class OptionalParamEnum(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Is this parameter required or optional + +class NsxPublicIpQuotaRaisedEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Flag to indicate whether the private cloud has the quota for provisioned NSX Public IP count + raised from 64 to 1024. """ + ENABLED = "Enabled" + DISABLED = "Disabled" + + +class OptionalParamEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Is this parameter required or optional.""" + OPTIONAL = "Optional" REQUIRED = "Required" -class PlacementPolicyProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The provisioning state - """ + +class PlacementPolicyProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state.""" SUCCEEDED = "Succeeded" FAILED = "Failed" BUILDING = "Building" DELETING = "Deleting" UPDATING = "Updating" + CANCELED = "Canceled" -class PlacementPolicyState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Whether the placement policy is enabled or disabled - """ + +class PlacementPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Whether the placement policy is enabled or disabled.""" ENABLED = "Enabled" DISABLED = "Disabled" -class PlacementPolicyType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """placement policy type - """ + +class PlacementPolicyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """placement policy type.""" VM_VM = "VmVm" VM_HOST = "VmHost" -class PortMirroringDirectionEnum(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Direction of port mirroring profile. - """ + +class PortMirroringDirectionEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Direction of port mirroring profile.""" INGRESS = "INGRESS" EGRESS = "EGRESS" BIDIRECTIONAL = "BIDIRECTIONAL" -class PortMirroringStatusEnum(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Port Mirroring Status. - """ + +class PortMirroringStatusEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Port Mirroring Status.""" SUCCESS = "SUCCESS" FAILURE = "FAILURE" -class PrivateCloudProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The provisioning state - """ + +class PrivateCloudProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state.""" SUCCEEDED = "Succeeded" FAILED = "Failed" @@ -252,15 +265,17 @@ class PrivateCloudProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str BUILDING = "Building" DELETING = "Deleting" UPDATING = "Updating" + CANCELED = "Canceled" -class QuotaEnabled(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Host quota is active for current subscription - """ + +class QuotaEnabled(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Host quota is active for current subscription.""" ENABLED = "Enabled" DISABLED = "Disabled" -class ResourceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity used for the private cloud. The type 'SystemAssigned' refers to an implicitly created identity. The type 'None' will remove any identities from the Private Cloud. """ @@ -268,17 +283,17 @@ class ResourceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SYSTEM_ASSIGNED = "SystemAssigned" NONE = "None" -class ScriptExecutionParameterType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The type of execution parameter - """ + +class ScriptExecutionParameterType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of execution parameter.""" VALUE = "Value" SECURE_VALUE = "SecureValue" CREDENTIAL = "Credential" -class ScriptExecutionProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The state of the script execution resource - """ + +class ScriptExecutionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The state of the script execution resource.""" PENDING = "Pending" RUNNING = "Running" @@ -287,17 +302,20 @@ class ScriptExecutionProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, CANCELLING = "Cancelling" CANCELLED = "Cancelled" DELETING = "Deleting" + CANCELED = "Canceled" + -class ScriptOutputStreamType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ScriptOutputStreamType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ScriptOutputStreamType.""" INFORMATION = "Information" WARNING = "Warning" OUTPUT = "Output" ERROR = "Error" -class ScriptParameterTypes(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The type of parameter the script is expecting. psCredential is a PSCredentialObject - """ + +class ScriptParameterTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of parameter the script is expecting. psCredential is a PSCredentialObject.""" STRING = "String" SECURE_STRING = "SecureString" @@ -306,123 +324,136 @@ class ScriptParameterTypes(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): BOOL = "Bool" FLOAT = "Float" -class SegmentStatusEnum(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Segment status. - """ + +class SegmentStatusEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Segment status.""" SUCCESS = "SUCCESS" FAILURE = "FAILURE" -class SslEnum(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Protect LDAP communication using SSL certificate (LDAPS) - """ + +class SslEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Protect LDAP communication using SSL certificate (LDAPS).""" ENABLED = "Enabled" DISABLED = "Disabled" -class TrialStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Trial status - """ + +class TrialStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Trial status.""" TRIAL_AVAILABLE = "TrialAvailable" TRIAL_USED = "TrialUsed" TRIAL_DISABLED = "TrialDisabled" -class VirtualMachineRestrictMovementState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Whether VM DRS-driven movement is restricted (enabled) or not (disabled) - """ + +class VirtualMachineRestrictMovementState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Whether VM DRS-driven movement is restricted (enabled) or not (disabled).""" ENABLED = "Enabled" DISABLED = "Disabled" -class VisibilityParameterEnum(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Should this parameter be visible to arm and passed in the parameters argument when executing - """ + +class VisibilityParameterEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Should this parameter be visible to arm and passed in the parameters argument when executing.""" VISIBLE = "Visible" HIDDEN = "Hidden" -class VMGroupStatusEnum(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """VM Group status. - """ + +class VMGroupStatusEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """VM Group status.""" SUCCESS = "SUCCESS" FAILURE = "FAILURE" -class VMTypeEnum(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Virtual machine type. - """ + +class VMTypeEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Virtual machine type.""" REGULAR = "REGULAR" EDGE = "EDGE" SERVICE = "SERVICE" -class WorkloadNetworkDhcpProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The provisioning state - """ + +class WorkloadNetworkDhcpProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state.""" SUCCEEDED = "Succeeded" FAILED = "Failed" BUILDING = "Building" DELETING = "Deleting" UPDATING = "Updating" + CANCELED = "Canceled" -class WorkloadNetworkDnsServiceProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The provisioning state - """ + +class WorkloadNetworkDnsServiceProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state.""" SUCCEEDED = "Succeeded" FAILED = "Failed" BUILDING = "Building" DELETING = "Deleting" UPDATING = "Updating" + CANCELED = "Canceled" -class WorkloadNetworkDnsZoneProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The provisioning state - """ + +class WorkloadNetworkDnsZoneProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state.""" SUCCEEDED = "Succeeded" FAILED = "Failed" BUILDING = "Building" DELETING = "Deleting" UPDATING = "Updating" + CANCELED = "Canceled" -class WorkloadNetworkPortMirroringProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The provisioning state - """ + +class WorkloadNetworkName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """WorkloadNetworkName.""" + + DEFAULT = "default" + + +class WorkloadNetworkPortMirroringProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state.""" SUCCEEDED = "Succeeded" FAILED = "Failed" BUILDING = "Building" DELETING = "Deleting" UPDATING = "Updating" + CANCELED = "Canceled" -class WorkloadNetworkPublicIPProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The provisioning state - """ + +class WorkloadNetworkPublicIPProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state.""" SUCCEEDED = "Succeeded" FAILED = "Failed" BUILDING = "Building" DELETING = "Deleting" UPDATING = "Updating" + CANCELED = "Canceled" -class WorkloadNetworkSegmentProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The provisioning state - """ + +class WorkloadNetworkSegmentProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state.""" SUCCEEDED = "Succeeded" FAILED = "Failed" BUILDING = "Building" DELETING = "Deleting" UPDATING = "Updating" + CANCELED = "Canceled" -class WorkloadNetworkVMGroupProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The provisioning state - """ + +class WorkloadNetworkVMGroupProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state.""" SUCCEEDED = "Succeeded" FAILED = "Failed" BUILDING = "Building" DELETING = "Deleting" UPDATING = "Updating" + CANCELED = "Canceled" diff --git a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/models/_models.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/models/_models.py deleted file mode 100644 index d5a57dcf7e33..000000000000 --- a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/models/_models.py +++ /dev/null @@ -1,3922 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -import msrest.serialization - - -class Resource(msrest.serialization.Model): - """The core properties of ARM resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class Addon(Resource): - """An addon resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param properties: The properties of an addon resource. - :type properties: ~azure.mgmt.avs.models.AddonProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'AddonProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(Addon, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - - -class AddonProperties(msrest.serialization.Model): - """The properties of an addon. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: AddonHcxProperties, AddonSrmProperties, AddonVrProperties. - - 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 addon_type: Required. The type of private cloud addon.Constant filled by server. - Possible values include: "SRM", "VR", "HCX". - :type addon_type: str or ~azure.mgmt.avs.models.AddonType - :ivar provisioning_state: The state of the addon provisioning. Possible values include: - "Succeeded", "Failed", "Cancelled", "Building", "Deleting", "Updating". - :vartype provisioning_state: str or ~azure.mgmt.avs.models.AddonProvisioningState - """ - - _validation = { - 'addon_type': {'required': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'addon_type': {'key': 'addonType', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - } - - _subtype_map = { - 'addon_type': {'HCX': 'AddonHcxProperties', 'SRM': 'AddonSrmProperties', 'VR': 'AddonVrProperties'} - } - - def __init__( - self, - **kwargs - ): - super(AddonProperties, self).__init__(**kwargs) - self.addon_type = None # type: Optional[str] - self.provisioning_state = None - - -class AddonHcxProperties(AddonProperties): - """The properties of an HCX addon. - - 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 addon_type: Required. The type of private cloud addon.Constant filled by server. - Possible values include: "SRM", "VR", "HCX". - :type addon_type: str or ~azure.mgmt.avs.models.AddonType - :ivar provisioning_state: The state of the addon provisioning. Possible values include: - "Succeeded", "Failed", "Cancelled", "Building", "Deleting", "Updating". - :vartype provisioning_state: str or ~azure.mgmt.avs.models.AddonProvisioningState - :param offer: Required. The HCX offer, example VMware MaaS Cloud Provider (Enterprise). - :type offer: str - """ - - _validation = { - 'addon_type': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'offer': {'required': True}, - } - - _attribute_map = { - 'addon_type': {'key': 'addonType', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'offer': {'key': 'offer', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AddonHcxProperties, self).__init__(**kwargs) - self.addon_type = 'HCX' # type: str - self.offer = kwargs['offer'] - - -class AddonList(msrest.serialization.Model): - """A paged list of addons. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The items on a page. - :vartype value: list[~azure.mgmt.avs.models.Addon] - :ivar next_link: URL to get the next page if any. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Addon]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AddonList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class AddonSrmProperties(AddonProperties): - """The properties of a Site Recovery Manager (SRM) addon. - - 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 addon_type: Required. The type of private cloud addon.Constant filled by server. - Possible values include: "SRM", "VR", "HCX". - :type addon_type: str or ~azure.mgmt.avs.models.AddonType - :ivar provisioning_state: The state of the addon provisioning. Possible values include: - "Succeeded", "Failed", "Cancelled", "Building", "Deleting", "Updating". - :vartype provisioning_state: str or ~azure.mgmt.avs.models.AddonProvisioningState - :param license_key: The Site Recovery Manager (SRM) license. - :type license_key: str - """ - - _validation = { - 'addon_type': {'required': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'addon_type': {'key': 'addonType', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'license_key': {'key': 'licenseKey', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AddonSrmProperties, self).__init__(**kwargs) - self.addon_type = 'SRM' # type: str - self.license_key = kwargs.get('license_key', None) - - -class AddonVrProperties(AddonProperties): - """The properties of a vSphere Replication (VR) addon. - - 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 addon_type: Required. The type of private cloud addon.Constant filled by server. - Possible values include: "SRM", "VR", "HCX". - :type addon_type: str or ~azure.mgmt.avs.models.AddonType - :ivar provisioning_state: The state of the addon provisioning. Possible values include: - "Succeeded", "Failed", "Cancelled", "Building", "Deleting", "Updating". - :vartype provisioning_state: str or ~azure.mgmt.avs.models.AddonProvisioningState - :param vrs_count: Required. The vSphere Replication Server (VRS) count. - :type vrs_count: int - """ - - _validation = { - 'addon_type': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'vrs_count': {'required': True}, - } - - _attribute_map = { - 'addon_type': {'key': 'addonType', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'vrs_count': {'key': 'vrsCount', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(AddonVrProperties, self).__init__(**kwargs) - self.addon_type = 'VR' # type: str - self.vrs_count = kwargs['vrs_count'] - - -class AdminCredentials(msrest.serialization.Model): - """Administrative credentials for accessing vCenter and NSX-T. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar nsxt_username: NSX-T Manager username. - :vartype nsxt_username: str - :ivar nsxt_password: NSX-T Manager password. - :vartype nsxt_password: str - :ivar vcenter_username: vCenter admin username. - :vartype vcenter_username: str - :ivar vcenter_password: vCenter admin password. - :vartype vcenter_password: str - """ - - _validation = { - 'nsxt_username': {'readonly': True}, - 'nsxt_password': {'readonly': True}, - 'vcenter_username': {'readonly': True}, - 'vcenter_password': {'readonly': True}, - } - - _attribute_map = { - 'nsxt_username': {'key': 'nsxtUsername', 'type': 'str'}, - 'nsxt_password': {'key': 'nsxtPassword', 'type': 'str'}, - 'vcenter_username': {'key': 'vcenterUsername', 'type': 'str'}, - 'vcenter_password': {'key': 'vcenterPassword', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AdminCredentials, self).__init__(**kwargs) - self.nsxt_username = None - self.nsxt_password = None - self.vcenter_username = None - self.vcenter_password = None - - -class AvailabilityProperties(msrest.serialization.Model): - """The properties describing private cloud availability zone distribution. - - :param strategy: The availability strategy for the private cloud. Possible values include: - "SingleZone", "DualZone". - :type strategy: str or ~azure.mgmt.avs.models.AvailabilityStrategy - :param zone: The primary availability zone for the private cloud. - :type zone: int - :param secondary_zone: The secondary availability zone for the private cloud. - :type secondary_zone: int - """ - - _attribute_map = { - 'strategy': {'key': 'strategy', 'type': 'str'}, - 'zone': {'key': 'zone', 'type': 'int'}, - 'secondary_zone': {'key': 'secondaryZone', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(AvailabilityProperties, self).__init__(**kwargs) - self.strategy = kwargs.get('strategy', None) - self.zone = kwargs.get('zone', None) - self.secondary_zone = kwargs.get('secondary_zone', None) - - -class Circuit(msrest.serialization.Model): - """An ExpressRoute Circuit. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar primary_subnet: CIDR of primary subnet. - :vartype primary_subnet: str - :ivar secondary_subnet: CIDR of secondary subnet. - :vartype secondary_subnet: str - :ivar express_route_id: Identifier of the ExpressRoute Circuit (Microsoft Colo only). - :vartype express_route_id: str - :ivar express_route_private_peering_id: ExpressRoute Circuit private peering identifier. - :vartype express_route_private_peering_id: str - """ - - _validation = { - 'primary_subnet': {'readonly': True}, - 'secondary_subnet': {'readonly': True}, - 'express_route_id': {'readonly': True}, - 'express_route_private_peering_id': {'readonly': True}, - } - - _attribute_map = { - 'primary_subnet': {'key': 'primarySubnet', 'type': 'str'}, - 'secondary_subnet': {'key': 'secondarySubnet', 'type': 'str'}, - 'express_route_id': {'key': 'expressRouteID', 'type': 'str'}, - 'express_route_private_peering_id': {'key': 'expressRoutePrivatePeeringID', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Circuit, self).__init__(**kwargs) - self.primary_subnet = None - self.secondary_subnet = None - self.express_route_id = None - self.express_route_private_peering_id = None - - -class CloudLink(Resource): - """A cloud link resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar status: The state of the cloud link. Possible values include: "Active", "Building", - "Deleting", "Failed", "Disconnected". - :vartype status: str or ~azure.mgmt.avs.models.CloudLinkStatus - :param linked_cloud: Identifier of the other private cloud participating in the link. - :type linked_cloud: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'status': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'linked_cloud': {'key': 'properties.linkedCloud', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CloudLink, self).__init__(**kwargs) - self.status = None - self.linked_cloud = kwargs.get('linked_cloud', None) - - -class CloudLinkList(msrest.serialization.Model): - """A paged list of cloud links. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The items on a page. - :vartype value: list[~azure.mgmt.avs.models.CloudLink] - :ivar next_link: URL to get the next page if any. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[CloudLink]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CloudLinkList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class Cluster(Resource): - """A cluster resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param sku: Required. The cluster SKU. - :type sku: ~azure.mgmt.avs.models.Sku - :param cluster_size: The cluster size. - :type cluster_size: int - :ivar provisioning_state: The state of the cluster provisioning. Possible values include: - "Succeeded", "Failed", "Cancelled", "Deleting", "Updating". - :vartype provisioning_state: str or ~azure.mgmt.avs.models.ClusterProvisioningState - :ivar cluster_id: The identity. - :vartype cluster_id: int - :param hosts: The hosts. - :type hosts: list[str] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'sku': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'cluster_id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'cluster_size': {'key': 'properties.clusterSize', 'type': 'int'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'cluster_id': {'key': 'properties.clusterId', 'type': 'int'}, - 'hosts': {'key': 'properties.hosts', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(Cluster, self).__init__(**kwargs) - self.sku = kwargs['sku'] - self.cluster_size = kwargs.get('cluster_size', None) - self.provisioning_state = None - self.cluster_id = None - self.hosts = kwargs.get('hosts', None) - - -class ClusterList(msrest.serialization.Model): - """A paged list of clusters. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The items on a page. - :vartype value: list[~azure.mgmt.avs.models.Cluster] - :ivar next_link: URL to get the next page if any. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Cluster]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ClusterList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class CommonClusterProperties(msrest.serialization.Model): - """The common properties of a cluster. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param cluster_size: The cluster size. - :type cluster_size: int - :ivar provisioning_state: The state of the cluster provisioning. Possible values include: - "Succeeded", "Failed", "Cancelled", "Deleting", "Updating". - :vartype provisioning_state: str or ~azure.mgmt.avs.models.ClusterProvisioningState - :ivar cluster_id: The identity. - :vartype cluster_id: int - :param hosts: The hosts. - :type hosts: list[str] - """ - - _validation = { - 'provisioning_state': {'readonly': True}, - 'cluster_id': {'readonly': True}, - } - - _attribute_map = { - 'cluster_size': {'key': 'clusterSize', 'type': 'int'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'cluster_id': {'key': 'clusterId', 'type': 'int'}, - 'hosts': {'key': 'hosts', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(CommonClusterProperties, self).__init__(**kwargs) - self.cluster_size = kwargs.get('cluster_size', None) - self.provisioning_state = None - self.cluster_id = None - self.hosts = kwargs.get('hosts', None) - - -class ClusterProperties(CommonClusterProperties): - """The properties of a cluster. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param cluster_size: The cluster size. - :type cluster_size: int - :ivar provisioning_state: The state of the cluster provisioning. Possible values include: - "Succeeded", "Failed", "Cancelled", "Deleting", "Updating". - :vartype provisioning_state: str or ~azure.mgmt.avs.models.ClusterProvisioningState - :ivar cluster_id: The identity. - :vartype cluster_id: int - :param hosts: The hosts. - :type hosts: list[str] - """ - - _validation = { - 'provisioning_state': {'readonly': True}, - 'cluster_id': {'readonly': True}, - } - - _attribute_map = { - 'cluster_size': {'key': 'clusterSize', 'type': 'int'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'cluster_id': {'key': 'clusterId', 'type': 'int'}, - 'hosts': {'key': 'hosts', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(ClusterProperties, self).__init__(**kwargs) - - -class ClusterUpdate(msrest.serialization.Model): - """An update of a cluster resource. - - :param cluster_size: The cluster size. - :type cluster_size: int - :param hosts: The hosts. - :type hosts: list[str] - """ - - _attribute_map = { - 'cluster_size': {'key': 'properties.clusterSize', 'type': 'int'}, - 'hosts': {'key': 'properties.hosts', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(ClusterUpdate, self).__init__(**kwargs) - self.cluster_size = kwargs.get('cluster_size', None) - self.hosts = kwargs.get('hosts', None) - - -class Datastore(Resource): - """A datastore resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar provisioning_state: The state of the datastore provisioning. Possible values include: - "Succeeded", "Failed", "Cancelled", "Pending", "Creating", "Updating", "Deleting". - :vartype provisioning_state: str or ~azure.mgmt.avs.models.DatastoreProvisioningState - :param net_app_volume: An Azure NetApp Files volume. - :type net_app_volume: ~azure.mgmt.avs.models.NetAppVolume - :param disk_pool_volume: An iSCSI volume. - :type disk_pool_volume: ~azure.mgmt.avs.models.DiskPoolVolume - :ivar status: The operational status of the datastore. Possible values include: "Unknown", - "Accessible", "Inaccessible", "Attached", "Detached", "LostCommunication", "DeadOrError". - :vartype status: str or ~azure.mgmt.avs.models.DatastoreStatus - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'net_app_volume': {'key': 'properties.netAppVolume', 'type': 'NetAppVolume'}, - 'disk_pool_volume': {'key': 'properties.diskPoolVolume', 'type': 'DiskPoolVolume'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Datastore, self).__init__(**kwargs) - self.provisioning_state = None - self.net_app_volume = kwargs.get('net_app_volume', None) - self.disk_pool_volume = kwargs.get('disk_pool_volume', None) - self.status = None - - -class DatastoreList(msrest.serialization.Model): - """A paged list of datastores. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The items on a page. - :vartype value: list[~azure.mgmt.avs.models.Datastore] - :ivar next_link: URL to get the next page if any. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Datastore]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DatastoreList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class DiskPoolVolume(msrest.serialization.Model): - """An iSCSI volume from Microsoft.StoragePool provider. - - 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 target_id: Required. Azure resource ID of the iSCSI target. - :type target_id: str - :param lun_name: Required. Name of the LUN to be used for datastore. - :type lun_name: str - :param mount_option: Mode that describes whether the LUN has to be mounted as a datastore or - attached as a LUN. Possible values include: "MOUNT", "ATTACH". Default value: "MOUNT". - :type mount_option: str or ~azure.mgmt.avs.models.MountOptionEnum - :ivar path: Device path. - :vartype path: str - """ - - _validation = { - 'target_id': {'required': True}, - 'lun_name': {'required': True}, - 'path': {'readonly': True}, - } - - _attribute_map = { - 'target_id': {'key': 'targetId', 'type': 'str'}, - 'lun_name': {'key': 'lunName', 'type': 'str'}, - 'mount_option': {'key': 'mountOption', 'type': 'str'}, - 'path': {'key': 'path', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DiskPoolVolume, self).__init__(**kwargs) - self.target_id = kwargs['target_id'] - self.lun_name = kwargs['lun_name'] - self.mount_option = kwargs.get('mount_option', "MOUNT") - self.path = None - - -class Encryption(msrest.serialization.Model): - """The properties of customer managed encryption key. - - :param status: Status of customer managed encryption key. Possible values include: "Enabled", - "Disabled". - :type status: str or ~azure.mgmt.avs.models.EncryptionState - :param key_vault_properties: The key vault where the encryption key is stored. - :type key_vault_properties: ~azure.mgmt.avs.models.EncryptionKeyVaultProperties - """ - - _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'key_vault_properties': {'key': 'keyVaultProperties', 'type': 'EncryptionKeyVaultProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(Encryption, self).__init__(**kwargs) - self.status = kwargs.get('status', None) - self.key_vault_properties = kwargs.get('key_vault_properties', None) - - -class EncryptionKeyVaultProperties(msrest.serialization.Model): - """An Encryption Key. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param key_name: The name of the key. - :type key_name: str - :param key_version: The version of the key. - :type key_version: str - :param key_vault_url: The URL of the vault. - :type key_vault_url: str - :ivar key_state: The state of key provided. Possible values include: "Connected", - "AccessDenied". - :vartype key_state: str or ~azure.mgmt.avs.models.EncryptionKeyStatus - :ivar version_type: Property of the key if user provided or auto detected. Possible values - include: "Fixed", "AutoDetected". - :vartype version_type: str or ~azure.mgmt.avs.models.EncryptionVersionType - """ - - _validation = { - 'key_state': {'readonly': True}, - 'version_type': {'readonly': True}, - } - - _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, - 'key_version': {'key': 'keyVersion', 'type': 'str'}, - 'key_vault_url': {'key': 'keyVaultUrl', 'type': 'str'}, - 'key_state': {'key': 'keyState', 'type': 'str'}, - 'version_type': {'key': 'versionType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EncryptionKeyVaultProperties, self).__init__(**kwargs) - self.key_name = kwargs.get('key_name', None) - self.key_version = kwargs.get('key_version', None) - self.key_vault_url = kwargs.get('key_vault_url', None) - self.key_state = None - self.version_type = None - - -class Endpoints(msrest.serialization.Model): - """Endpoint addresses. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar nsxt_manager: Endpoint for the NSX-T Data Center manager. - :vartype nsxt_manager: str - :ivar vcsa: Endpoint for Virtual Center Server Appliance. - :vartype vcsa: str - :ivar hcx_cloud_manager: Endpoint for the HCX Cloud Manager. - :vartype hcx_cloud_manager: str - """ - - _validation = { - 'nsxt_manager': {'readonly': True}, - 'vcsa': {'readonly': True}, - 'hcx_cloud_manager': {'readonly': True}, - } - - _attribute_map = { - 'nsxt_manager': {'key': 'nsxtManager', 'type': 'str'}, - 'vcsa': {'key': 'vcsa', 'type': 'str'}, - 'hcx_cloud_manager': {'key': 'hcxCloudManager', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Endpoints, self).__init__(**kwargs) - self.nsxt_manager = None - self.vcsa = None - self.hcx_cloud_manager = None - - -class ErrorAdditionalInfo(msrest.serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: any - """ - - _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorAdditionalInfo, self).__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorResponse(msrest.serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.avs.models.ErrorResponse] - :ivar additional_info: The error additional info. - :vartype additional_info: list[~azure.mgmt.avs.models.ErrorAdditionalInfo] - """ - - _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponse]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ExpressRouteAuthorization(Resource): - """ExpressRoute Circuit Authorization. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar provisioning_state: The state of the ExpressRoute Circuit Authorization provisioning. - Possible values include: "Succeeded", "Failed", "Updating". - :vartype provisioning_state: str or - ~azure.mgmt.avs.models.ExpressRouteAuthorizationProvisioningState - :ivar express_route_authorization_id: The ID of the ExpressRoute Circuit Authorization. - :vartype express_route_authorization_id: str - :ivar express_route_authorization_key: The key of the ExpressRoute Circuit Authorization. - :vartype express_route_authorization_key: str - :param express_route_id: The ID of the ExpressRoute Circuit. - :type express_route_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'express_route_authorization_id': {'readonly': True}, - 'express_route_authorization_key': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'express_route_authorization_id': {'key': 'properties.expressRouteAuthorizationId', 'type': 'str'}, - 'express_route_authorization_key': {'key': 'properties.expressRouteAuthorizationKey', 'type': 'str'}, - 'express_route_id': {'key': 'properties.expressRouteId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ExpressRouteAuthorization, self).__init__(**kwargs) - self.provisioning_state = None - self.express_route_authorization_id = None - self.express_route_authorization_key = None - self.express_route_id = kwargs.get('express_route_id', None) - - -class ExpressRouteAuthorizationList(msrest.serialization.Model): - """A paged list of ExpressRoute Circuit Authorizations. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The items on a page. - :vartype value: list[~azure.mgmt.avs.models.ExpressRouteAuthorization] - :ivar next_link: URL to get the next page if any. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ExpressRouteAuthorization]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ExpressRouteAuthorizationList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class GlobalReachConnection(Resource): - """A global reach connection resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar provisioning_state: The state of the ExpressRoute Circuit Authorization provisioning. - Possible values include: "Succeeded", "Failed", "Updating". - :vartype provisioning_state: str or - ~azure.mgmt.avs.models.GlobalReachConnectionProvisioningState - :ivar address_prefix: The network used for global reach carved out from the original network - block provided for the private cloud. - :vartype address_prefix: str - :param authorization_key: Authorization key from the peer express route used for the global - reach connection. - :type authorization_key: str - :ivar circuit_connection_status: The connection status of the global reach connection. Possible - values include: "Connected", "Connecting", "Disconnected". - :vartype circuit_connection_status: str or ~azure.mgmt.avs.models.GlobalReachConnectionStatus - :param peer_express_route_circuit: Identifier of the ExpressRoute Circuit to peer with in the - global reach connection. - :type peer_express_route_circuit: str - :param express_route_id: The ID of the Private Cloud's ExpressRoute Circuit that is - participating in the global reach connection. - :type express_route_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'address_prefix': {'readonly': True}, - 'circuit_connection_status': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'address_prefix': {'key': 'properties.addressPrefix', 'type': 'str'}, - 'authorization_key': {'key': 'properties.authorizationKey', 'type': 'str'}, - 'circuit_connection_status': {'key': 'properties.circuitConnectionStatus', 'type': 'str'}, - 'peer_express_route_circuit': {'key': 'properties.peerExpressRouteCircuit', 'type': 'str'}, - 'express_route_id': {'key': 'properties.expressRouteId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(GlobalReachConnection, self).__init__(**kwargs) - self.provisioning_state = None - self.address_prefix = None - self.authorization_key = kwargs.get('authorization_key', None) - self.circuit_connection_status = None - self.peer_express_route_circuit = kwargs.get('peer_express_route_circuit', None) - self.express_route_id = kwargs.get('express_route_id', None) - - -class GlobalReachConnectionList(msrest.serialization.Model): - """A paged list of global reach connections. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The items on a page. - :vartype value: list[~azure.mgmt.avs.models.GlobalReachConnection] - :ivar next_link: URL to get the next page if any. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[GlobalReachConnection]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(GlobalReachConnectionList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class HcxEnterpriseSite(Resource): - """An HCX Enterprise Site resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar activation_key: The activation key. - :vartype activation_key: str - :ivar status: The status of the HCX Enterprise Site. Possible values include: "Available", - "Consumed", "Deactivated", "Deleted". - :vartype status: str or ~azure.mgmt.avs.models.HcxEnterpriseSiteStatus - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'activation_key': {'readonly': True}, - 'status': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'activation_key': {'key': 'properties.activationKey', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(HcxEnterpriseSite, self).__init__(**kwargs) - self.activation_key = None - self.status = None - - -class HcxEnterpriseSiteList(msrest.serialization.Model): - """A paged list of HCX Enterprise Sites. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The items on a page. - :vartype value: list[~azure.mgmt.avs.models.HcxEnterpriseSite] - :ivar next_link: URL to get the next page if any. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[HcxEnterpriseSite]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(HcxEnterpriseSiteList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class IdentitySource(msrest.serialization.Model): - """vCenter Single Sign On Identity Source. - - :param name: The name of the identity source. - :type name: str - :param alias: The domain's NetBIOS name. - :type alias: str - :param domain: The domain's dns name. - :type domain: str - :param base_user_dn: The base distinguished name for users. - :type base_user_dn: str - :param base_group_dn: The base distinguished name for groups. - :type base_group_dn: str - :param primary_server: Primary server URL. - :type primary_server: str - :param secondary_server: Secondary server URL. - :type secondary_server: str - :param ssl: Protect LDAP communication using SSL certificate (LDAPS). Possible values include: - "Enabled", "Disabled". - :type ssl: str or ~azure.mgmt.avs.models.SslEnum - :param username: The ID of an Active Directory user with a minimum of read-only access to Base - DN for users and group. - :type username: str - :param password: The password of the Active Directory user with a minimum of read-only access - to Base DN for users and groups. - :type password: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'alias': {'key': 'alias', 'type': 'str'}, - 'domain': {'key': 'domain', 'type': 'str'}, - 'base_user_dn': {'key': 'baseUserDN', 'type': 'str'}, - 'base_group_dn': {'key': 'baseGroupDN', 'type': 'str'}, - 'primary_server': {'key': 'primaryServer', 'type': 'str'}, - 'secondary_server': {'key': 'secondaryServer', 'type': 'str'}, - 'ssl': {'key': 'ssl', 'type': 'str'}, - 'username': {'key': 'username', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IdentitySource, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.alias = kwargs.get('alias', None) - self.domain = kwargs.get('domain', None) - self.base_user_dn = kwargs.get('base_user_dn', None) - self.base_group_dn = kwargs.get('base_group_dn', None) - self.primary_server = kwargs.get('primary_server', None) - self.secondary_server = kwargs.get('secondary_server', None) - self.ssl = kwargs.get('ssl', None) - self.username = kwargs.get('username', None) - self.password = kwargs.get('password', None) - - -class LogSpecification(msrest.serialization.Model): - """Specifications of the Log for Azure Monitoring. - - :param name: Name of the log. - :type name: str - :param display_name: Localized friendly display name of the log. - :type display_name: str - :param blob_duration: Blob duration of the log. - :type blob_duration: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'blob_duration': {'key': 'blobDuration', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LogSpecification, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display_name = kwargs.get('display_name', None) - self.blob_duration = kwargs.get('blob_duration', None) - - -class ManagementCluster(CommonClusterProperties): - """The properties of a management cluster. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param cluster_size: The cluster size. - :type cluster_size: int - :ivar provisioning_state: The state of the cluster provisioning. Possible values include: - "Succeeded", "Failed", "Cancelled", "Deleting", "Updating". - :vartype provisioning_state: str or ~azure.mgmt.avs.models.ClusterProvisioningState - :ivar cluster_id: The identity. - :vartype cluster_id: int - :param hosts: The hosts. - :type hosts: list[str] - """ - - _validation = { - 'provisioning_state': {'readonly': True}, - 'cluster_id': {'readonly': True}, - } - - _attribute_map = { - 'cluster_size': {'key': 'clusterSize', 'type': 'int'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'cluster_id': {'key': 'clusterId', 'type': 'int'}, - 'hosts': {'key': 'hosts', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagementCluster, self).__init__(**kwargs) - - -class MetricDimension(msrest.serialization.Model): - """Specifications of the Dimension of metrics. - - :param name: Name of the dimension. - :type name: str - :param display_name: Localized friendly display name of the dimension. - :type display_name: str - :param internal_name: Name of the dimension as it appears in MDM. - :type internal_name: str - :param to_be_exported_for_shoebox: A boolean flag indicating whether this dimension should be - included for the shoebox export scenario. - :type to_be_exported_for_shoebox: bool - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'internal_name': {'key': 'internalName', 'type': 'str'}, - 'to_be_exported_for_shoebox': {'key': 'toBeExportedForShoebox', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricDimension, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display_name = kwargs.get('display_name', None) - self.internal_name = kwargs.get('internal_name', None) - self.to_be_exported_for_shoebox = kwargs.get('to_be_exported_for_shoebox', None) - - -class MetricSpecification(msrest.serialization.Model): - """Specifications of the Metrics for Azure Monitoring. - - :param name: Name of the metric. - :type name: str - :param display_name: Localized friendly display name of the metric. - :type display_name: str - :param display_description: Localized friendly description of the metric. - :type display_description: str - :param unit: Unit that makes sense for the metric. - :type unit: str - :param category: Name of the metric category that the metric belongs to. A metric can only - belong to a single category. - :type category: str - :param aggregation_type: Only provide one value for this field. Valid values: Average, Minimum, - Maximum, Total, Count. - :type aggregation_type: str - :param supported_aggregation_types: Supported aggregation types. - :type supported_aggregation_types: list[str] - :param supported_time_grain_types: Supported time grain types. - :type supported_time_grain_types: list[str] - :param fill_gap_with_zero: Optional. If set to true, then zero will be returned for time - duration where no metric is emitted/published. - :type fill_gap_with_zero: bool - :param dimensions: Dimensions of the metric. - :type dimensions: list[~azure.mgmt.avs.models.MetricDimension] - :param enable_regional_mdm_account: Whether or not the service is using regional MDM accounts. - :type enable_regional_mdm_account: str - :param source_mdm_account: The name of the MDM account. - :type source_mdm_account: str - :param source_mdm_namespace: The name of the MDM namespace. - :type source_mdm_namespace: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'category': {'key': 'category', 'type': 'str'}, - 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, - 'supported_aggregation_types': {'key': 'supportedAggregationTypes', 'type': '[str]'}, - 'supported_time_grain_types': {'key': 'supportedTimeGrainTypes', 'type': '[str]'}, - 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'bool'}, - 'dimensions': {'key': 'dimensions', 'type': '[MetricDimension]'}, - 'enable_regional_mdm_account': {'key': 'enableRegionalMdmAccount', 'type': 'str'}, - 'source_mdm_account': {'key': 'sourceMdmAccount', 'type': 'str'}, - 'source_mdm_namespace': {'key': 'sourceMdmNamespace', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricSpecification, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display_name = kwargs.get('display_name', None) - self.display_description = kwargs.get('display_description', None) - self.unit = kwargs.get('unit', None) - self.category = kwargs.get('category', None) - self.aggregation_type = kwargs.get('aggregation_type', None) - self.supported_aggregation_types = kwargs.get('supported_aggregation_types', None) - self.supported_time_grain_types = kwargs.get('supported_time_grain_types', None) - self.fill_gap_with_zero = kwargs.get('fill_gap_with_zero', None) - self.dimensions = kwargs.get('dimensions', None) - self.enable_regional_mdm_account = kwargs.get('enable_regional_mdm_account', None) - self.source_mdm_account = kwargs.get('source_mdm_account', None) - self.source_mdm_namespace = kwargs.get('source_mdm_namespace', None) - - -class NetAppVolume(msrest.serialization.Model): - """An Azure NetApp Files volume from Microsoft.NetApp provider. - - All required parameters must be populated in order to send to Azure. - - :param id: Required. Azure resource ID of the NetApp volume. - :type id: str - """ - - _validation = { - 'id': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(NetAppVolume, self).__init__(**kwargs) - self.id = kwargs['id'] - - -class Operation(msrest.serialization.Model): - """A REST API operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Name of the operation being performed on this object. - :vartype name: str - :ivar display: Contains the localized display information for this operation. - :vartype display: ~azure.mgmt.avs.models.OperationDisplay - :param is_data_action: Gets or sets a value indicating whether the operation is a data action - or not. - :type is_data_action: bool - :param origin: Origin of the operation. - :type origin: str - :param properties: Properties of the operation. - :type properties: ~azure.mgmt.avs.models.OperationProperties - """ - - _validation = { - 'name': {'readonly': True}, - 'display': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'OperationProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = None - self.display = None - self.is_data_action = kwargs.get('is_data_action', None) - self.origin = kwargs.get('origin', None) - self.properties = kwargs.get('properties', None) - - -class OperationDisplay(msrest.serialization.Model): - """Contains the localized display information for this operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provider: Localized friendly form of the resource provider name. - :vartype provider: str - :ivar resource: Localized friendly form of the resource type related to this operation. - :vartype resource: str - :ivar operation: Localized friendly name for the operation. - :vartype operation: str - :ivar description: Localized friendly description for the operation. - :vartype description: str - """ - - _validation = { - 'provider': {'readonly': True}, - 'resource': {'readonly': True}, - 'operation': {'readonly': True}, - 'description': {'readonly': True}, - } - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - self.description = None - - -class OperationList(msrest.serialization.Model): - """Pageable list of operations. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of operations. - :vartype value: list[~azure.mgmt.avs.models.Operation] - :ivar next_link: URL to get the next page if any. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class OperationProperties(msrest.serialization.Model): - """Extra Operation properties. - - :param service_specification: Service specifications of the operation. - :type service_specification: ~azure.mgmt.avs.models.ServiceSpecification - """ - - _attribute_map = { - 'service_specification': {'key': 'serviceSpecification', 'type': 'ServiceSpecification'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationProperties, self).__init__(**kwargs) - self.service_specification = kwargs.get('service_specification', None) - - -class PlacementPoliciesList(msrest.serialization.Model): - """Represents list of placement policies. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The items on the page. - :vartype value: list[~azure.mgmt.avs.models.PlacementPolicy] - :ivar next_link: URL to get the next page if any. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[PlacementPolicy]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PlacementPoliciesList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class PlacementPolicy(Resource): - """A vSphere Distributed Resource Scheduler (DRS) placement policy. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param properties: placement policy properties. - :type properties: ~azure.mgmt.avs.models.PlacementPolicyProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'PlacementPolicyProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(PlacementPolicy, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - - -class PlacementPolicyProperties(msrest.serialization.Model): - """Abstract placement policy properties. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: VmHostPlacementPolicyProperties, VmPlacementPolicyProperties. - - 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 type: Required. placement policy type.Constant filled by server. Possible values - include: "VmVm", "VmHost". - :type type: str or ~azure.mgmt.avs.models.PlacementPolicyType - :param state: Whether the placement policy is enabled or disabled. Possible values include: - "Enabled", "Disabled". - :type state: str or ~azure.mgmt.avs.models.PlacementPolicyState - :param display_name: Display name of the placement policy. - :type display_name: str - :ivar provisioning_state: The provisioning state. Possible values include: "Succeeded", - "Failed", "Building", "Deleting", "Updating". - :vartype provisioning_state: str or ~azure.mgmt.avs.models.PlacementPolicyProvisioningState - """ - - _validation = { - 'type': {'required': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - } - - _subtype_map = { - 'type': {'VmHost': 'VmHostPlacementPolicyProperties', 'VmVm': 'VmPlacementPolicyProperties'} - } - - def __init__( - self, - **kwargs - ): - super(PlacementPolicyProperties, self).__init__(**kwargs) - self.type = None # type: Optional[str] - self.state = kwargs.get('state', None) - self.display_name = kwargs.get('display_name', None) - self.provisioning_state = None - - -class PlacementPolicyUpdate(msrest.serialization.Model): - """An update of a DRS placement policy resource. - - :param state: Whether the placement policy is enabled or disabled. Possible values include: - "Enabled", "Disabled". - :type state: str or ~azure.mgmt.avs.models.PlacementPolicyState - :param vm_members: Virtual machine members list. - :type vm_members: list[str] - :param host_members: Host members list. - :type host_members: list[str] - """ - - _attribute_map = { - 'state': {'key': 'properties.state', 'type': 'str'}, - 'vm_members': {'key': 'properties.vmMembers', 'type': '[str]'}, - 'host_members': {'key': 'properties.hostMembers', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(PlacementPolicyUpdate, self).__init__(**kwargs) - self.state = kwargs.get('state', None) - self.vm_members = kwargs.get('vm_members', None) - self.host_members = kwargs.get('host_members', None) - - -class TrackedResource(Resource): - """The resource model definition for a ARM tracked top level resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(TrackedResource, self).__init__(**kwargs) - self.location = kwargs.get('location', None) - self.tags = kwargs.get('tags', None) - - -class PrivateCloud(TrackedResource): - """A private cloud resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param sku: Required. The private cloud SKU. - :type sku: ~azure.mgmt.avs.models.Sku - :param identity: The identity of the private cloud, if configured. - :type identity: ~azure.mgmt.avs.models.PrivateCloudIdentity - :param management_cluster: The default cluster used for management. - :type management_cluster: ~azure.mgmt.avs.models.ManagementCluster - :param internet: Connectivity to internet is enabled or disabled. Possible values include: - "Enabled", "Disabled". Default value: "Disabled". - :type internet: str or ~azure.mgmt.avs.models.InternetEnum - :param identity_sources: vCenter Single Sign On Identity Sources. - :type identity_sources: list[~azure.mgmt.avs.models.IdentitySource] - :param availability: Properties describing how the cloud is distributed across availability - zones. - :type availability: ~azure.mgmt.avs.models.AvailabilityProperties - :param encryption: Customer managed key encryption, can be enabled or disabled. - :type encryption: ~azure.mgmt.avs.models.Encryption - :ivar provisioning_state: The provisioning state. Possible values include: "Succeeded", - "Failed", "Cancelled", "Pending", "Building", "Deleting", "Updating". - :vartype provisioning_state: str or ~azure.mgmt.avs.models.PrivateCloudProvisioningState - :param circuit: An ExpressRoute Circuit. - :type circuit: ~azure.mgmt.avs.models.Circuit - :ivar endpoints: The endpoints. - :vartype endpoints: ~azure.mgmt.avs.models.Endpoints - :param network_block: The block of addresses should be unique across VNet in your subscription - as well as on-premise. Make sure the CIDR format is conformed to (A.B.C.D/X) where A,B,C,D are - between 0 and 255, and X is between 0 and 22. - :type network_block: str - :ivar management_network: Network used to access vCenter Server and NSX-T Manager. - :vartype management_network: str - :ivar provisioning_network: Used for virtual machine cold migration, cloning, and snapshot - migration. - :vartype provisioning_network: str - :ivar vmotion_network: Used for live migration of virtual machines. - :vartype vmotion_network: str - :param vcenter_password: Optionally, set the vCenter admin password when the private cloud is - created. - :type vcenter_password: str - :param nsxt_password: Optionally, set the NSX-T Manager password when the private cloud is - created. - :type nsxt_password: str - :ivar vcenter_certificate_thumbprint: Thumbprint of the vCenter Server SSL certificate. - :vartype vcenter_certificate_thumbprint: str - :ivar nsxt_certificate_thumbprint: Thumbprint of the NSX-T Manager SSL certificate. - :vartype nsxt_certificate_thumbprint: str - :ivar external_cloud_links: Array of cloud link IDs from other clouds that connect to this one. - :vartype external_cloud_links: list[str] - :param secondary_circuit: A secondary expressRoute circuit from a separate AZ. Only present in - a stretched private cloud. - :type secondary_circuit: ~azure.mgmt.avs.models.Circuit - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'sku': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'endpoints': {'readonly': True}, - 'management_network': {'readonly': True}, - 'provisioning_network': {'readonly': True}, - 'vmotion_network': {'readonly': True}, - 'vcenter_certificate_thumbprint': {'readonly': True}, - 'nsxt_certificate_thumbprint': {'readonly': True}, - 'external_cloud_links': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'identity': {'key': 'identity', 'type': 'PrivateCloudIdentity'}, - 'management_cluster': {'key': 'properties.managementCluster', 'type': 'ManagementCluster'}, - 'internet': {'key': 'properties.internet', 'type': 'str'}, - 'identity_sources': {'key': 'properties.identitySources', 'type': '[IdentitySource]'}, - 'availability': {'key': 'properties.availability', 'type': 'AvailabilityProperties'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'circuit': {'key': 'properties.circuit', 'type': 'Circuit'}, - 'endpoints': {'key': 'properties.endpoints', 'type': 'Endpoints'}, - 'network_block': {'key': 'properties.networkBlock', 'type': 'str'}, - 'management_network': {'key': 'properties.managementNetwork', 'type': 'str'}, - 'provisioning_network': {'key': 'properties.provisioningNetwork', 'type': 'str'}, - 'vmotion_network': {'key': 'properties.vmotionNetwork', 'type': 'str'}, - 'vcenter_password': {'key': 'properties.vcenterPassword', 'type': 'str'}, - 'nsxt_password': {'key': 'properties.nsxtPassword', 'type': 'str'}, - 'vcenter_certificate_thumbprint': {'key': 'properties.vcenterCertificateThumbprint', 'type': 'str'}, - 'nsxt_certificate_thumbprint': {'key': 'properties.nsxtCertificateThumbprint', 'type': 'str'}, - 'external_cloud_links': {'key': 'properties.externalCloudLinks', 'type': '[str]'}, - 'secondary_circuit': {'key': 'properties.secondaryCircuit', 'type': 'Circuit'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateCloud, self).__init__(**kwargs) - self.sku = kwargs['sku'] - self.identity = kwargs.get('identity', None) - self.management_cluster = kwargs.get('management_cluster', None) - self.internet = kwargs.get('internet', "Disabled") - self.identity_sources = kwargs.get('identity_sources', None) - self.availability = kwargs.get('availability', None) - self.encryption = kwargs.get('encryption', None) - self.provisioning_state = None - self.circuit = kwargs.get('circuit', None) - self.endpoints = None - self.network_block = kwargs.get('network_block', None) - self.management_network = None - self.provisioning_network = None - self.vmotion_network = None - self.vcenter_password = kwargs.get('vcenter_password', None) - self.nsxt_password = kwargs.get('nsxt_password', None) - self.vcenter_certificate_thumbprint = None - self.nsxt_certificate_thumbprint = None - self.external_cloud_links = None - self.secondary_circuit = kwargs.get('secondary_circuit', None) - - -class PrivateCloudIdentity(msrest.serialization.Model): - """Identity for the virtual machine. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: The principal ID of private cloud identity. This property will only be - provided for a system assigned identity. - :vartype principal_id: str - :ivar tenant_id: The tenant ID associated with the private cloud. This property will only be - provided for a system assigned identity. - :vartype tenant_id: str - :param type: The type of identity used for the private cloud. The type 'SystemAssigned' refers - to an implicitly created identity. The type 'None' will remove any identities from the Private - Cloud. Possible values include: "SystemAssigned", "None". - :type type: str or ~azure.mgmt.avs.models.ResourceIdentityType - """ - - _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - } - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateCloudIdentity, self).__init__(**kwargs) - self.principal_id = None - self.tenant_id = None - self.type = kwargs.get('type', None) - - -class PrivateCloudList(msrest.serialization.Model): - """A paged list of private clouds. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The items on the page. - :vartype value: list[~azure.mgmt.avs.models.PrivateCloud] - :ivar next_link: URL to get the next page if any. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateCloud]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateCloudList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class PrivateCloudUpdateProperties(msrest.serialization.Model): - """The properties of a private cloud resource that may be updated. - - :param management_cluster: The default cluster used for management. - :type management_cluster: ~azure.mgmt.avs.models.ManagementCluster - :param internet: Connectivity to internet is enabled or disabled. Possible values include: - "Enabled", "Disabled". Default value: "Disabled". - :type internet: str or ~azure.mgmt.avs.models.InternetEnum - :param identity_sources: vCenter Single Sign On Identity Sources. - :type identity_sources: list[~azure.mgmt.avs.models.IdentitySource] - :param availability: Properties describing how the cloud is distributed across availability - zones. - :type availability: ~azure.mgmt.avs.models.AvailabilityProperties - :param encryption: Customer managed key encryption, can be enabled or disabled. - :type encryption: ~azure.mgmt.avs.models.Encryption - """ - - _attribute_map = { - 'management_cluster': {'key': 'managementCluster', 'type': 'ManagementCluster'}, - 'internet': {'key': 'internet', 'type': 'str'}, - 'identity_sources': {'key': 'identitySources', 'type': '[IdentitySource]'}, - 'availability': {'key': 'availability', 'type': 'AvailabilityProperties'}, - 'encryption': {'key': 'encryption', 'type': 'Encryption'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateCloudUpdateProperties, self).__init__(**kwargs) - self.management_cluster = kwargs.get('management_cluster', None) - self.internet = kwargs.get('internet', "Disabled") - self.identity_sources = kwargs.get('identity_sources', None) - self.availability = kwargs.get('availability', None) - self.encryption = kwargs.get('encryption', None) - - -class PrivateCloudProperties(PrivateCloudUpdateProperties): - """The properties of a private cloud resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param management_cluster: The default cluster used for management. - :type management_cluster: ~azure.mgmt.avs.models.ManagementCluster - :param internet: Connectivity to internet is enabled or disabled. Possible values include: - "Enabled", "Disabled". Default value: "Disabled". - :type internet: str or ~azure.mgmt.avs.models.InternetEnum - :param identity_sources: vCenter Single Sign On Identity Sources. - :type identity_sources: list[~azure.mgmt.avs.models.IdentitySource] - :param availability: Properties describing how the cloud is distributed across availability - zones. - :type availability: ~azure.mgmt.avs.models.AvailabilityProperties - :param encryption: Customer managed key encryption, can be enabled or disabled. - :type encryption: ~azure.mgmt.avs.models.Encryption - :ivar provisioning_state: The provisioning state. Possible values include: "Succeeded", - "Failed", "Cancelled", "Pending", "Building", "Deleting", "Updating". - :vartype provisioning_state: str or ~azure.mgmt.avs.models.PrivateCloudProvisioningState - :param circuit: An ExpressRoute Circuit. - :type circuit: ~azure.mgmt.avs.models.Circuit - :ivar endpoints: The endpoints. - :vartype endpoints: ~azure.mgmt.avs.models.Endpoints - :param network_block: Required. The block of addresses should be unique across VNet in your - subscription as well as on-premise. Make sure the CIDR format is conformed to (A.B.C.D/X) where - A,B,C,D are between 0 and 255, and X is between 0 and 22. - :type network_block: str - :ivar management_network: Network used to access vCenter Server and NSX-T Manager. - :vartype management_network: str - :ivar provisioning_network: Used for virtual machine cold migration, cloning, and snapshot - migration. - :vartype provisioning_network: str - :ivar vmotion_network: Used for live migration of virtual machines. - :vartype vmotion_network: str - :param vcenter_password: Optionally, set the vCenter admin password when the private cloud is - created. - :type vcenter_password: str - :param nsxt_password: Optionally, set the NSX-T Manager password when the private cloud is - created. - :type nsxt_password: str - :ivar vcenter_certificate_thumbprint: Thumbprint of the vCenter Server SSL certificate. - :vartype vcenter_certificate_thumbprint: str - :ivar nsxt_certificate_thumbprint: Thumbprint of the NSX-T Manager SSL certificate. - :vartype nsxt_certificate_thumbprint: str - :ivar external_cloud_links: Array of cloud link IDs from other clouds that connect to this one. - :vartype external_cloud_links: list[str] - :param secondary_circuit: A secondary expressRoute circuit from a separate AZ. Only present in - a stretched private cloud. - :type secondary_circuit: ~azure.mgmt.avs.models.Circuit - """ - - _validation = { - 'provisioning_state': {'readonly': True}, - 'endpoints': {'readonly': True}, - 'network_block': {'required': True}, - 'management_network': {'readonly': True}, - 'provisioning_network': {'readonly': True}, - 'vmotion_network': {'readonly': True}, - 'vcenter_certificate_thumbprint': {'readonly': True}, - 'nsxt_certificate_thumbprint': {'readonly': True}, - 'external_cloud_links': {'readonly': True}, - } - - _attribute_map = { - 'management_cluster': {'key': 'managementCluster', 'type': 'ManagementCluster'}, - 'internet': {'key': 'internet', 'type': 'str'}, - 'identity_sources': {'key': 'identitySources', 'type': '[IdentitySource]'}, - 'availability': {'key': 'availability', 'type': 'AvailabilityProperties'}, - 'encryption': {'key': 'encryption', 'type': 'Encryption'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'circuit': {'key': 'circuit', 'type': 'Circuit'}, - 'endpoints': {'key': 'endpoints', 'type': 'Endpoints'}, - 'network_block': {'key': 'networkBlock', 'type': 'str'}, - 'management_network': {'key': 'managementNetwork', 'type': 'str'}, - 'provisioning_network': {'key': 'provisioningNetwork', 'type': 'str'}, - 'vmotion_network': {'key': 'vmotionNetwork', 'type': 'str'}, - 'vcenter_password': {'key': 'vcenterPassword', 'type': 'str'}, - 'nsxt_password': {'key': 'nsxtPassword', 'type': 'str'}, - 'vcenter_certificate_thumbprint': {'key': 'vcenterCertificateThumbprint', 'type': 'str'}, - 'nsxt_certificate_thumbprint': {'key': 'nsxtCertificateThumbprint', 'type': 'str'}, - 'external_cloud_links': {'key': 'externalCloudLinks', 'type': '[str]'}, - 'secondary_circuit': {'key': 'secondaryCircuit', 'type': 'Circuit'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateCloudProperties, self).__init__(**kwargs) - self.provisioning_state = None - self.circuit = kwargs.get('circuit', None) - self.endpoints = None - self.network_block = kwargs['network_block'] - self.management_network = None - self.provisioning_network = None - self.vmotion_network = None - self.vcenter_password = kwargs.get('vcenter_password', None) - self.nsxt_password = kwargs.get('nsxt_password', None) - self.vcenter_certificate_thumbprint = None - self.nsxt_certificate_thumbprint = None - self.external_cloud_links = None - self.secondary_circuit = kwargs.get('secondary_circuit', None) - - -class PrivateCloudUpdate(msrest.serialization.Model): - """An update to a private cloud resource. - - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param identity: The identity of the private cloud, if configured. - :type identity: ~azure.mgmt.avs.models.PrivateCloudIdentity - :param management_cluster: The default cluster used for management. - :type management_cluster: ~azure.mgmt.avs.models.ManagementCluster - :param internet: Connectivity to internet is enabled or disabled. Possible values include: - "Enabled", "Disabled". Default value: "Disabled". - :type internet: str or ~azure.mgmt.avs.models.InternetEnum - :param identity_sources: vCenter Single Sign On Identity Sources. - :type identity_sources: list[~azure.mgmt.avs.models.IdentitySource] - :param availability: Properties describing how the cloud is distributed across availability - zones. - :type availability: ~azure.mgmt.avs.models.AvailabilityProperties - :param encryption: Customer managed key encryption, can be enabled or disabled. - :type encryption: ~azure.mgmt.avs.models.Encryption - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'PrivateCloudIdentity'}, - 'management_cluster': {'key': 'properties.managementCluster', 'type': 'ManagementCluster'}, - 'internet': {'key': 'properties.internet', 'type': 'str'}, - 'identity_sources': {'key': 'properties.identitySources', 'type': '[IdentitySource]'}, - 'availability': {'key': 'properties.availability', 'type': 'AvailabilityProperties'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateCloudUpdate, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.identity = kwargs.get('identity', None) - self.management_cluster = kwargs.get('management_cluster', None) - self.internet = kwargs.get('internet', "Disabled") - self.identity_sources = kwargs.get('identity_sources', None) - self.availability = kwargs.get('availability', None) - self.encryption = kwargs.get('encryption', None) - - -class ProxyResource(Resource): - """The resource model definition for a ARM proxy resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ProxyResource, self).__init__(**kwargs) - - -class ScriptExecutionParameter(msrest.serialization.Model): - """The arguments passed in to the execution. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: PSCredentialExecutionParameter, ScriptSecureStringExecutionParameter, ScriptStringExecutionParameter. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The parameter name. - :type name: str - :param type: Required. The type of execution parameter.Constant filled by server. Possible - values include: "Value", "SecureValue", "Credential". - :type type: str or ~azure.mgmt.avs.models.ScriptExecutionParameterType - """ - - _validation = { - 'name': {'required': True}, - 'type': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - _subtype_map = { - 'type': {'Credential': 'PSCredentialExecutionParameter', 'SecureValue': 'ScriptSecureStringExecutionParameter', 'Value': 'ScriptStringExecutionParameter'} - } - - def __init__( - self, - **kwargs - ): - super(ScriptExecutionParameter, self).__init__(**kwargs) - self.name = kwargs['name'] - self.type = None # type: Optional[str] - - -class PSCredentialExecutionParameter(ScriptExecutionParameter): - """a powershell credential object. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The parameter name. - :type name: str - :param type: Required. The type of execution parameter.Constant filled by server. Possible - values include: "Value", "SecureValue", "Credential". - :type type: str or ~azure.mgmt.avs.models.ScriptExecutionParameterType - :param username: username for login. - :type username: str - :param password: password for login. - :type password: str - """ - - _validation = { - 'name': {'required': True}, - 'type': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'username': {'key': 'username', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PSCredentialExecutionParameter, self).__init__(**kwargs) - self.type = 'Credential' # type: str - self.username = kwargs.get('username', None) - self.password = kwargs.get('password', None) - - -class Quota(msrest.serialization.Model): - """Subscription quotas. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar hosts_remaining: Remaining hosts quota by sku type. - :vartype hosts_remaining: dict[str, int] - :ivar quota_enabled: Host quota is active for current subscription. Possible values include: - "Enabled", "Disabled". - :vartype quota_enabled: str or ~azure.mgmt.avs.models.QuotaEnabled - """ - - _validation = { - 'hosts_remaining': {'readonly': True}, - 'quota_enabled': {'readonly': True}, - } - - _attribute_map = { - 'hosts_remaining': {'key': 'hostsRemaining', 'type': '{int}'}, - 'quota_enabled': {'key': 'quotaEnabled', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Quota, self).__init__(**kwargs) - self.hosts_remaining = None - self.quota_enabled = None - - -class ScriptCmdlet(ProxyResource): - """A cmdlet available for script execution. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar description: Description of the scripts functionality. - :vartype description: str - :ivar timeout: Recommended time limit for execution. - :vartype timeout: str - :ivar parameters: Parameters the script will accept. - :vartype parameters: list[~azure.mgmt.avs.models.ScriptParameter] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'description': {'readonly': True}, - 'timeout': {'readonly': True}, - 'parameters': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'timeout': {'key': 'properties.timeout', 'type': 'str'}, - 'parameters': {'key': 'properties.parameters', 'type': '[ScriptParameter]'}, - } - - def __init__( - self, - **kwargs - ): - super(ScriptCmdlet, self).__init__(**kwargs) - self.description = None - self.timeout = None - self.parameters = None - - -class ScriptCmdletsList(msrest.serialization.Model): - """Pageable list of scripts/cmdlets. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of scripts. - :vartype value: list[~azure.mgmt.avs.models.ScriptCmdlet] - :ivar next_link: URL to get the next page if any. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ScriptCmdlet]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ScriptCmdletsList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ScriptExecution(ProxyResource): - """An instance of a script executed by a user - custom or AVS. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param script_cmdlet_id: A reference to the script cmdlet resource if user is running a AVS - script. - :type script_cmdlet_id: str - :param parameters: Parameters the script will accept. - :type parameters: list[~azure.mgmt.avs.models.ScriptExecutionParameter] - :param hidden_parameters: Parameters that will be hidden/not visible to ARM, such as passwords - and credentials. - :type hidden_parameters: list[~azure.mgmt.avs.models.ScriptExecutionParameter] - :param failure_reason: Error message if the script was able to run, but if the script itself - had errors or powershell threw an exception. - :type failure_reason: str - :param timeout: Time limit for execution. - :type timeout: str - :param retention: Time to live for the resource. If not provided, will be available for 60 - days. - :type retention: str - :ivar submitted_at: Time the script execution was submitted. - :vartype submitted_at: ~datetime.datetime - :ivar started_at: Time the script execution was started. - :vartype started_at: ~datetime.datetime - :ivar finished_at: Time the script execution was finished. - :vartype finished_at: ~datetime.datetime - :ivar provisioning_state: The state of the script execution resource. Possible values include: - "Pending", "Running", "Succeeded", "Failed", "Cancelling", "Cancelled", "Deleting". - :vartype provisioning_state: str or ~azure.mgmt.avs.models.ScriptExecutionProvisioningState - :param output: Standard output stream from the powershell execution. - :type output: list[str] - :param named_outputs: User-defined dictionary. - :type named_outputs: dict[str, any] - :ivar information: Standard information out stream from the powershell execution. - :vartype information: list[str] - :ivar warnings: Standard warning out stream from the powershell execution. - :vartype warnings: list[str] - :ivar errors: Standard error output stream from the powershell execution. - :vartype errors: list[str] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'submitted_at': {'readonly': True}, - 'started_at': {'readonly': True}, - 'finished_at': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'information': {'readonly': True}, - 'warnings': {'readonly': True}, - 'errors': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'script_cmdlet_id': {'key': 'properties.scriptCmdletId', 'type': 'str'}, - 'parameters': {'key': 'properties.parameters', 'type': '[ScriptExecutionParameter]'}, - 'hidden_parameters': {'key': 'properties.hiddenParameters', 'type': '[ScriptExecutionParameter]'}, - 'failure_reason': {'key': 'properties.failureReason', 'type': 'str'}, - 'timeout': {'key': 'properties.timeout', 'type': 'str'}, - 'retention': {'key': 'properties.retention', 'type': 'str'}, - 'submitted_at': {'key': 'properties.submittedAt', 'type': 'iso-8601'}, - 'started_at': {'key': 'properties.startedAt', 'type': 'iso-8601'}, - 'finished_at': {'key': 'properties.finishedAt', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'output': {'key': 'properties.output', 'type': '[str]'}, - 'named_outputs': {'key': 'properties.namedOutputs', 'type': '{object}'}, - 'information': {'key': 'properties.information', 'type': '[str]'}, - 'warnings': {'key': 'properties.warnings', 'type': '[str]'}, - 'errors': {'key': 'properties.errors', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(ScriptExecution, self).__init__(**kwargs) - self.script_cmdlet_id = kwargs.get('script_cmdlet_id', None) - self.parameters = kwargs.get('parameters', None) - self.hidden_parameters = kwargs.get('hidden_parameters', None) - self.failure_reason = kwargs.get('failure_reason', None) - self.timeout = kwargs.get('timeout', None) - self.retention = kwargs.get('retention', None) - self.submitted_at = None - self.started_at = None - self.finished_at = None - self.provisioning_state = None - self.output = kwargs.get('output', None) - self.named_outputs = kwargs.get('named_outputs', None) - self.information = None - self.warnings = None - self.errors = None - - -class ScriptExecutionsList(msrest.serialization.Model): - """Pageable list of script executions. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of scripts. - :vartype value: list[~azure.mgmt.avs.models.ScriptExecution] - :ivar next_link: URL to get the next page if any. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ScriptExecution]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ScriptExecutionsList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ScriptPackage(ProxyResource): - """Script Package resources available for execution. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar description: User friendly description of the package. - :vartype description: str - :ivar version: Module version. - :vartype version: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'description': {'readonly': True}, - 'version': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ScriptPackage, self).__init__(**kwargs) - self.description = None - self.version = None - - -class ScriptPackagesList(msrest.serialization.Model): - """A list of the available script packages. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of script package resources. - :vartype value: list[~azure.mgmt.avs.models.ScriptPackage] - :ivar next_link: URL to get the next page if any. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ScriptPackage]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ScriptPackagesList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ScriptParameter(msrest.serialization.Model): - """An parameter that the script will accept. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The type of parameter the script is expecting. psCredential is a - PSCredentialObject. Possible values include: "String", "SecureString", "Credential", "Int", - "Bool", "Float". - :vartype type: str or ~azure.mgmt.avs.models.ScriptParameterTypes - :param name: The parameter name that the script will expect a parameter value for. - :type name: str - :ivar description: User friendly description of the parameter. - :vartype description: str - :ivar visibility: Should this parameter be visible to arm and passed in the parameters argument - when executing. Possible values include: "Visible", "Hidden". - :vartype visibility: str or ~azure.mgmt.avs.models.VisibilityParameterEnum - :ivar optional: Is this parameter required or optional. Possible values include: "Optional", - "Required". - :vartype optional: str or ~azure.mgmt.avs.models.OptionalParamEnum - """ - - _validation = { - 'type': {'readonly': True}, - 'description': {'readonly': True}, - 'visibility': {'readonly': True}, - 'optional': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'visibility': {'key': 'visibility', 'type': 'str'}, - 'optional': {'key': 'optional', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ScriptParameter, self).__init__(**kwargs) - self.type = None - self.name = kwargs.get('name', None) - self.description = None - self.visibility = None - self.optional = None - - -class ScriptSecureStringExecutionParameter(ScriptExecutionParameter): - """a plain text value execution parameter. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The parameter name. - :type name: str - :param type: Required. The type of execution parameter.Constant filled by server. Possible - values include: "Value", "SecureValue", "Credential". - :type type: str or ~azure.mgmt.avs.models.ScriptExecutionParameterType - :param secure_value: A secure value for the passed parameter, not to be stored in logs. - :type secure_value: str - """ - - _validation = { - 'name': {'required': True}, - 'type': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'secure_value': {'key': 'secureValue', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ScriptSecureStringExecutionParameter, self).__init__(**kwargs) - self.type = 'SecureValue' # type: str - self.secure_value = kwargs.get('secure_value', None) - - -class ScriptStringExecutionParameter(ScriptExecutionParameter): - """a plain text value execution parameter. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The parameter name. - :type name: str - :param type: Required. The type of execution parameter.Constant filled by server. Possible - values include: "Value", "SecureValue", "Credential". - :type type: str or ~azure.mgmt.avs.models.ScriptExecutionParameterType - :param value: The value for the passed parameter. - :type value: str - """ - - _validation = { - 'name': {'required': True}, - 'type': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ScriptStringExecutionParameter, self).__init__(**kwargs) - self.type = 'Value' # type: str - self.value = kwargs.get('value', None) - - -class ServiceSpecification(msrest.serialization.Model): - """Service specification payload. - - :param log_specifications: Specifications of the Log for Azure Monitoring. - :type log_specifications: list[~azure.mgmt.avs.models.LogSpecification] - :param metric_specifications: Specifications of the Metrics for Azure Monitoring. - :type metric_specifications: list[~azure.mgmt.avs.models.MetricSpecification] - """ - - _attribute_map = { - 'log_specifications': {'key': 'logSpecifications', 'type': '[LogSpecification]'}, - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecification]'}, - } - - def __init__( - self, - **kwargs - ): - super(ServiceSpecification, self).__init__(**kwargs) - self.log_specifications = kwargs.get('log_specifications', None) - self.metric_specifications = kwargs.get('metric_specifications', None) - - -class Sku(msrest.serialization.Model): - """The resource model definition representing SKU. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The name of the SKU. - :type name: str - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Sku, self).__init__(**kwargs) - self.name = kwargs['name'] - - -class Trial(msrest.serialization.Model): - """Subscription trial availability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar status: Trial status. Possible values include: "TrialAvailable", "TrialUsed", - "TrialDisabled". - :vartype status: str or ~azure.mgmt.avs.models.TrialStatus - :ivar available_hosts: Number of trial hosts available. - :vartype available_hosts: int - """ - - _validation = { - 'status': {'readonly': True}, - 'available_hosts': {'readonly': True}, - } - - _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'available_hosts': {'key': 'availableHosts', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(Trial, self).__init__(**kwargs) - self.status = None - self.available_hosts = None - - -class VirtualMachine(ProxyResource): - """Virtual Machine. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar display_name: Display name of the VM. - :vartype display_name: str - :ivar mo_ref_id: Virtual machine managed object reference id. - :vartype mo_ref_id: str - :ivar folder_path: Path to virtual machine's folder starting from datacenter virtual machine - folder. - :vartype folder_path: str - :ivar restrict_movement: Whether VM DRS-driven movement is restricted (enabled) or not - (disabled). Possible values include: "Enabled", "Disabled". - :vartype restrict_movement: str or ~azure.mgmt.avs.models.VirtualMachineRestrictMovementState - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'display_name': {'readonly': True}, - 'mo_ref_id': {'readonly': True}, - 'folder_path': {'readonly': True}, - 'restrict_movement': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'mo_ref_id': {'key': 'properties.moRefId', 'type': 'str'}, - 'folder_path': {'key': 'properties.folderPath', 'type': 'str'}, - 'restrict_movement': {'key': 'properties.restrictMovement', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(VirtualMachine, self).__init__(**kwargs) - self.display_name = None - self.mo_ref_id = None - self.folder_path = None - self.restrict_movement = None - - -class VirtualMachineRestrictMovement(msrest.serialization.Model): - """Set VM DRS-driven movement to restricted (enabled) or not (disabled). - - :param restrict_movement: Whether VM DRS-driven movement is restricted (enabled) or not - (disabled). Possible values include: "Enabled", "Disabled". - :type restrict_movement: str or ~azure.mgmt.avs.models.VirtualMachineRestrictMovementState - """ - - _attribute_map = { - 'restrict_movement': {'key': 'restrictMovement', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(VirtualMachineRestrictMovement, self).__init__(**kwargs) - self.restrict_movement = kwargs.get('restrict_movement', None) - - -class VirtualMachinesList(msrest.serialization.Model): - """A list of Virtual Machines. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The items to be displayed on the page. - :vartype value: list[~azure.mgmt.avs.models.VirtualMachine] - :ivar next_link: URL to get the next page if any. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[VirtualMachine]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(VirtualMachinesList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class VmHostPlacementPolicyProperties(PlacementPolicyProperties): - """VM-Host placement policy properties. - - 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 type: Required. placement policy type.Constant filled by server. Possible values - include: "VmVm", "VmHost". - :type type: str or ~azure.mgmt.avs.models.PlacementPolicyType - :param state: Whether the placement policy is enabled or disabled. Possible values include: - "Enabled", "Disabled". - :type state: str or ~azure.mgmt.avs.models.PlacementPolicyState - :param display_name: Display name of the placement policy. - :type display_name: str - :ivar provisioning_state: The provisioning state. Possible values include: "Succeeded", - "Failed", "Building", "Deleting", "Updating". - :vartype provisioning_state: str or ~azure.mgmt.avs.models.PlacementPolicyProvisioningState - :param vm_members: Required. Virtual machine members list. - :type vm_members: list[str] - :param host_members: Required. Host members list. - :type host_members: list[str] - :param affinity_type: Required. placement policy affinity type. Possible values include: - "Affinity", "AntiAffinity". - :type affinity_type: str or ~azure.mgmt.avs.models.AffinityType - """ - - _validation = { - 'type': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'vm_members': {'required': True}, - 'host_members': {'required': True}, - 'affinity_type': {'required': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'vm_members': {'key': 'vmMembers', 'type': '[str]'}, - 'host_members': {'key': 'hostMembers', 'type': '[str]'}, - 'affinity_type': {'key': 'affinityType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(VmHostPlacementPolicyProperties, self).__init__(**kwargs) - self.type = 'VmHost' # type: str - self.vm_members = kwargs['vm_members'] - self.host_members = kwargs['host_members'] - self.affinity_type = kwargs['affinity_type'] - - -class VmPlacementPolicyProperties(PlacementPolicyProperties): - """VM-VM placement policy properties. - - 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 type: Required. placement policy type.Constant filled by server. Possible values - include: "VmVm", "VmHost". - :type type: str or ~azure.mgmt.avs.models.PlacementPolicyType - :param state: Whether the placement policy is enabled or disabled. Possible values include: - "Enabled", "Disabled". - :type state: str or ~azure.mgmt.avs.models.PlacementPolicyState - :param display_name: Display name of the placement policy. - :type display_name: str - :ivar provisioning_state: The provisioning state. Possible values include: "Succeeded", - "Failed", "Building", "Deleting", "Updating". - :vartype provisioning_state: str or ~azure.mgmt.avs.models.PlacementPolicyProvisioningState - :param vm_members: Required. Virtual machine members list. - :type vm_members: list[str] - :param affinity_type: Required. placement policy affinity type. Possible values include: - "Affinity", "AntiAffinity". - :type affinity_type: str or ~azure.mgmt.avs.models.AffinityType - """ - - _validation = { - 'type': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'vm_members': {'required': True}, - 'affinity_type': {'required': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'vm_members': {'key': 'vmMembers', 'type': '[str]'}, - 'affinity_type': {'key': 'affinityType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(VmPlacementPolicyProperties, self).__init__(**kwargs) - self.type = 'VmVm' # type: str - self.vm_members = kwargs['vm_members'] - self.affinity_type = kwargs['affinity_type'] - - -class WorkloadNetworkDhcp(ProxyResource): - """NSX DHCP. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param properties: DHCP properties. - :type properties: ~azure.mgmt.avs.models.WorkloadNetworkDhcpEntity - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'WorkloadNetworkDhcpEntity'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkloadNetworkDhcp, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - - -class WorkloadNetworkDhcpEntity(msrest.serialization.Model): - """Base class for WorkloadNetworkDhcpServer and WorkloadNetworkDhcpRelay to inherit from. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: WorkloadNetworkDhcpRelay, WorkloadNetworkDhcpServer. - - 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 dhcp_type: Required. Type of DHCP: SERVER or RELAY.Constant filled by server. Possible - values include: "SERVER", "RELAY". - :type dhcp_type: str or ~azure.mgmt.avs.models.DhcpTypeEnum - :param display_name: Display name of the DHCP entity. - :type display_name: str - :ivar segments: NSX Segments consuming DHCP. - :vartype segments: list[str] - :ivar provisioning_state: The provisioning state. Possible values include: "Succeeded", - "Failed", "Building", "Deleting", "Updating". - :vartype provisioning_state: str or ~azure.mgmt.avs.models.WorkloadNetworkDhcpProvisioningState - :param revision: NSX revision number. - :type revision: long - """ - - _validation = { - 'dhcp_type': {'required': True}, - 'segments': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'dhcp_type': {'key': 'dhcpType', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'segments': {'key': 'segments', 'type': '[str]'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'revision': {'key': 'revision', 'type': 'long'}, - } - - _subtype_map = { - 'dhcp_type': {'RELAY': 'WorkloadNetworkDhcpRelay', 'SERVER': 'WorkloadNetworkDhcpServer'} - } - - def __init__( - self, - **kwargs - ): - super(WorkloadNetworkDhcpEntity, self).__init__(**kwargs) - self.dhcp_type = None # type: Optional[str] - self.display_name = kwargs.get('display_name', None) - self.segments = None - self.provisioning_state = None - self.revision = kwargs.get('revision', None) - - -class WorkloadNetworkDhcpList(msrest.serialization.Model): - """A list of NSX dhcp entities. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The items on the page. - :vartype value: list[~azure.mgmt.avs.models.WorkloadNetworkDhcp] - :ivar next_link: URL to get the next page if any. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[WorkloadNetworkDhcp]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkloadNetworkDhcpList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class WorkloadNetworkDhcpRelay(WorkloadNetworkDhcpEntity): - """NSX DHCP Relay. - - 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 dhcp_type: Required. Type of DHCP: SERVER or RELAY.Constant filled by server. Possible - values include: "SERVER", "RELAY". - :type dhcp_type: str or ~azure.mgmt.avs.models.DhcpTypeEnum - :param display_name: Display name of the DHCP entity. - :type display_name: str - :ivar segments: NSX Segments consuming DHCP. - :vartype segments: list[str] - :ivar provisioning_state: The provisioning state. Possible values include: "Succeeded", - "Failed", "Building", "Deleting", "Updating". - :vartype provisioning_state: str or ~azure.mgmt.avs.models.WorkloadNetworkDhcpProvisioningState - :param revision: NSX revision number. - :type revision: long - :param server_addresses: DHCP Relay Addresses. Max 3. - :type server_addresses: list[str] - """ - - _validation = { - 'dhcp_type': {'required': True}, - 'segments': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'server_addresses': {'max_items': 3, 'min_items': 1}, - } - - _attribute_map = { - 'dhcp_type': {'key': 'dhcpType', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'segments': {'key': 'segments', 'type': '[str]'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'revision': {'key': 'revision', 'type': 'long'}, - 'server_addresses': {'key': 'serverAddresses', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkloadNetworkDhcpRelay, self).__init__(**kwargs) - self.dhcp_type = 'RELAY' # type: str - self.server_addresses = kwargs.get('server_addresses', None) - - -class WorkloadNetworkDhcpServer(WorkloadNetworkDhcpEntity): - """NSX DHCP Server. - - 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 dhcp_type: Required. Type of DHCP: SERVER or RELAY.Constant filled by server. Possible - values include: "SERVER", "RELAY". - :type dhcp_type: str or ~azure.mgmt.avs.models.DhcpTypeEnum - :param display_name: Display name of the DHCP entity. - :type display_name: str - :ivar segments: NSX Segments consuming DHCP. - :vartype segments: list[str] - :ivar provisioning_state: The provisioning state. Possible values include: "Succeeded", - "Failed", "Building", "Deleting", "Updating". - :vartype provisioning_state: str or ~azure.mgmt.avs.models.WorkloadNetworkDhcpProvisioningState - :param revision: NSX revision number. - :type revision: long - :param server_address: DHCP Server Address. - :type server_address: str - :param lease_time: DHCP Server Lease Time. - :type lease_time: long - """ - - _validation = { - 'dhcp_type': {'required': True}, - 'segments': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'dhcp_type': {'key': 'dhcpType', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'segments': {'key': 'segments', 'type': '[str]'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'revision': {'key': 'revision', 'type': 'long'}, - 'server_address': {'key': 'serverAddress', 'type': 'str'}, - 'lease_time': {'key': 'leaseTime', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkloadNetworkDhcpServer, self).__init__(**kwargs) - self.dhcp_type = 'SERVER' # type: str - self.server_address = kwargs.get('server_address', None) - self.lease_time = kwargs.get('lease_time', None) - - -class WorkloadNetworkDnsService(ProxyResource): - """NSX DNS Service. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param display_name: Display name of the DNS Service. - :type display_name: str - :param dns_service_ip: DNS service IP of the DNS Service. - :type dns_service_ip: str - :param default_dns_zone: Default DNS zone of the DNS Service. - :type default_dns_zone: str - :param fqdn_zones: FQDN zones of the DNS Service. - :type fqdn_zones: list[str] - :param log_level: DNS Service log level. Possible values include: "DEBUG", "INFO", "WARNING", - "ERROR", "FATAL". - :type log_level: str or ~azure.mgmt.avs.models.DnsServiceLogLevelEnum - :ivar status: DNS Service status. Possible values include: "SUCCESS", "FAILURE". - :vartype status: str or ~azure.mgmt.avs.models.DnsServiceStatusEnum - :ivar provisioning_state: The provisioning state. Possible values include: "Succeeded", - "Failed", "Building", "Deleting", "Updating". - :vartype provisioning_state: str or - ~azure.mgmt.avs.models.WorkloadNetworkDnsServiceProvisioningState - :param revision: NSX revision number. - :type revision: long - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'status': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'dns_service_ip': {'key': 'properties.dnsServiceIp', 'type': 'str'}, - 'default_dns_zone': {'key': 'properties.defaultDnsZone', 'type': 'str'}, - 'fqdn_zones': {'key': 'properties.fqdnZones', 'type': '[str]'}, - 'log_level': {'key': 'properties.logLevel', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'revision': {'key': 'properties.revision', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkloadNetworkDnsService, self).__init__(**kwargs) - self.display_name = kwargs.get('display_name', None) - self.dns_service_ip = kwargs.get('dns_service_ip', None) - self.default_dns_zone = kwargs.get('default_dns_zone', None) - self.fqdn_zones = kwargs.get('fqdn_zones', None) - self.log_level = kwargs.get('log_level', None) - self.status = None - self.provisioning_state = None - self.revision = kwargs.get('revision', None) - - -class WorkloadNetworkDnsServicesList(msrest.serialization.Model): - """A list of NSX DNS Services. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The items on the page. - :vartype value: list[~azure.mgmt.avs.models.WorkloadNetworkDnsService] - :ivar next_link: URL to get the next page if any. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[WorkloadNetworkDnsService]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkloadNetworkDnsServicesList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class WorkloadNetworkDnsZone(ProxyResource): - """NSX DNS Zone. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param display_name: Display name of the DNS Zone. - :type display_name: str - :param domain: Domain names of the DNS Zone. - :type domain: list[str] - :param dns_server_ips: DNS Server IP array of the DNS Zone. - :type dns_server_ips: list[str] - :param source_ip: Source IP of the DNS Zone. - :type source_ip: str - :param dns_services: Number of DNS Services using the DNS zone. - :type dns_services: long - :ivar provisioning_state: The provisioning state. Possible values include: "Succeeded", - "Failed", "Building", "Deleting", "Updating". - :vartype provisioning_state: str or - ~azure.mgmt.avs.models.WorkloadNetworkDnsZoneProvisioningState - :param revision: NSX revision number. - :type revision: long - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'domain': {'key': 'properties.domain', 'type': '[str]'}, - 'dns_server_ips': {'key': 'properties.dnsServerIps', 'type': '[str]'}, - 'source_ip': {'key': 'properties.sourceIp', 'type': 'str'}, - 'dns_services': {'key': 'properties.dnsServices', 'type': 'long'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'revision': {'key': 'properties.revision', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkloadNetworkDnsZone, self).__init__(**kwargs) - self.display_name = kwargs.get('display_name', None) - self.domain = kwargs.get('domain', None) - self.dns_server_ips = kwargs.get('dns_server_ips', None) - self.source_ip = kwargs.get('source_ip', None) - self.dns_services = kwargs.get('dns_services', None) - self.provisioning_state = None - self.revision = kwargs.get('revision', None) - - -class WorkloadNetworkDnsZonesList(msrest.serialization.Model): - """A list of NSX DNS Zones. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The items on the page. - :vartype value: list[~azure.mgmt.avs.models.WorkloadNetworkDnsZone] - :ivar next_link: URL to get the next page if any. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[WorkloadNetworkDnsZone]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkloadNetworkDnsZonesList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class WorkloadNetworkGateway(ProxyResource): - """NSX Gateway. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param display_name: Display name of the DHCP entity. - :type display_name: str - :ivar path: NSX Gateway Path. - :vartype path: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'path': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'path': {'key': 'properties.path', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkloadNetworkGateway, self).__init__(**kwargs) - self.display_name = kwargs.get('display_name', None) - self.path = None - - -class WorkloadNetworkGatewayList(msrest.serialization.Model): - """A list of NSX Gateways. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The items on the page. - :vartype value: list[~azure.mgmt.avs.models.WorkloadNetworkGateway] - :ivar next_link: URL to get the next page if any. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[WorkloadNetworkGateway]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkloadNetworkGatewayList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class WorkloadNetworkPortMirroring(ProxyResource): - """NSX Port Mirroring. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param display_name: Display name of the port mirroring profile. - :type display_name: str - :param direction: Direction of port mirroring profile. Possible values include: "INGRESS", - "EGRESS", "BIDIRECTIONAL". - :type direction: str or ~azure.mgmt.avs.models.PortMirroringDirectionEnum - :param source: Source VM Group. - :type source: str - :param destination: Destination VM Group. - :type destination: str - :ivar status: Port Mirroring Status. Possible values include: "SUCCESS", "FAILURE". - :vartype status: str or ~azure.mgmt.avs.models.PortMirroringStatusEnum - :ivar provisioning_state: The provisioning state. Possible values include: "Succeeded", - "Failed", "Building", "Deleting", "Updating". - :vartype provisioning_state: str or - ~azure.mgmt.avs.models.WorkloadNetworkPortMirroringProvisioningState - :param revision: NSX revision number. - :type revision: long - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'status': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'direction': {'key': 'properties.direction', 'type': 'str'}, - 'source': {'key': 'properties.source', 'type': 'str'}, - 'destination': {'key': 'properties.destination', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'revision': {'key': 'properties.revision', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkloadNetworkPortMirroring, self).__init__(**kwargs) - self.display_name = kwargs.get('display_name', None) - self.direction = kwargs.get('direction', None) - self.source = kwargs.get('source', None) - self.destination = kwargs.get('destination', None) - self.status = None - self.provisioning_state = None - self.revision = kwargs.get('revision', None) - - -class WorkloadNetworkPortMirroringList(msrest.serialization.Model): - """A list of NSX Port Mirroring. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The items on the page. - :vartype value: list[~azure.mgmt.avs.models.WorkloadNetworkPortMirroring] - :ivar next_link: URL to get the next page if any. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[WorkloadNetworkPortMirroring]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkloadNetworkPortMirroringList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class WorkloadNetworkPublicIP(ProxyResource): - """NSX Public IP Block. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param display_name: Display name of the Public IP Block. - :type display_name: str - :param number_of_public_i_ps: Number of Public IPs requested. - :type number_of_public_i_ps: long - :ivar public_ip_block: CIDR Block of the Public IP Block. - :vartype public_ip_block: str - :ivar provisioning_state: The provisioning state. Possible values include: "Succeeded", - "Failed", "Building", "Deleting", "Updating". - :vartype provisioning_state: str or - ~azure.mgmt.avs.models.WorkloadNetworkPublicIPProvisioningState - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'public_ip_block': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'number_of_public_i_ps': {'key': 'properties.numberOfPublicIPs', 'type': 'long'}, - 'public_ip_block': {'key': 'properties.publicIPBlock', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkloadNetworkPublicIP, self).__init__(**kwargs) - self.display_name = kwargs.get('display_name', None) - self.number_of_public_i_ps = kwargs.get('number_of_public_i_ps', None) - self.public_ip_block = None - self.provisioning_state = None - - -class WorkloadNetworkPublicIPsList(msrest.serialization.Model): - """A list of NSX Public IP Blocks. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The items on the page. - :vartype value: list[~azure.mgmt.avs.models.WorkloadNetworkPublicIP] - :ivar next_link: URL to get the next page if any. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[WorkloadNetworkPublicIP]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkloadNetworkPublicIPsList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class WorkloadNetworkSegment(ProxyResource): - """NSX Segment. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param display_name: Display name of the segment. - :type display_name: str - :param connected_gateway: Gateway which to connect segment to. - :type connected_gateway: str - :param subnet: Subnet which to connect segment to. - :type subnet: ~azure.mgmt.avs.models.WorkloadNetworkSegmentSubnet - :ivar port_vif: Port Vif which segment is associated with. - :vartype port_vif: list[~azure.mgmt.avs.models.WorkloadNetworkSegmentPortVif] - :ivar status: Segment status. Possible values include: "SUCCESS", "FAILURE". - :vartype status: str or ~azure.mgmt.avs.models.SegmentStatusEnum - :ivar provisioning_state: The provisioning state. Possible values include: "Succeeded", - "Failed", "Building", "Deleting", "Updating". - :vartype provisioning_state: str or - ~azure.mgmt.avs.models.WorkloadNetworkSegmentProvisioningState - :param revision: NSX revision number. - :type revision: long - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'port_vif': {'readonly': True}, - 'status': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'connected_gateway': {'key': 'properties.connectedGateway', 'type': 'str'}, - 'subnet': {'key': 'properties.subnet', 'type': 'WorkloadNetworkSegmentSubnet'}, - 'port_vif': {'key': 'properties.portVif', 'type': '[WorkloadNetworkSegmentPortVif]'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'revision': {'key': 'properties.revision', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkloadNetworkSegment, self).__init__(**kwargs) - self.display_name = kwargs.get('display_name', None) - self.connected_gateway = kwargs.get('connected_gateway', None) - self.subnet = kwargs.get('subnet', None) - self.port_vif = None - self.status = None - self.provisioning_state = None - self.revision = kwargs.get('revision', None) - - -class WorkloadNetworkSegmentPortVif(msrest.serialization.Model): - """Ports and any VIF attached to segment. - - :param port_name: Name of port or VIF attached to segment. - :type port_name: str - """ - - _attribute_map = { - 'port_name': {'key': 'portName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkloadNetworkSegmentPortVif, self).__init__(**kwargs) - self.port_name = kwargs.get('port_name', None) - - -class WorkloadNetworkSegmentsList(msrest.serialization.Model): - """A list of NSX Segments. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The items on the page. - :vartype value: list[~azure.mgmt.avs.models.WorkloadNetworkSegment] - :ivar next_link: URL to get the next page if any. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[WorkloadNetworkSegment]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkloadNetworkSegmentsList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class WorkloadNetworkSegmentSubnet(msrest.serialization.Model): - """Subnet configuration for segment. - - :param dhcp_ranges: DHCP Range assigned for subnet. - :type dhcp_ranges: list[str] - :param gateway_address: Gateway address. - :type gateway_address: str - """ - - _attribute_map = { - 'dhcp_ranges': {'key': 'dhcpRanges', 'type': '[str]'}, - 'gateway_address': {'key': 'gatewayAddress', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkloadNetworkSegmentSubnet, self).__init__(**kwargs) - self.dhcp_ranges = kwargs.get('dhcp_ranges', None) - self.gateway_address = kwargs.get('gateway_address', None) - - -class WorkloadNetworkVirtualMachine(ProxyResource): - """NSX Virtual Machine. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param display_name: Display name of the VM. - :type display_name: str - :ivar vm_type: Virtual machine type. Possible values include: "REGULAR", "EDGE", "SERVICE". - :vartype vm_type: str or ~azure.mgmt.avs.models.VMTypeEnum - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'vm_type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'vm_type': {'key': 'properties.vmType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkloadNetworkVirtualMachine, self).__init__(**kwargs) - self.display_name = kwargs.get('display_name', None) - self.vm_type = None - - -class WorkloadNetworkVirtualMachinesList(msrest.serialization.Model): - """A list of NSX Virtual Machines. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The items on the page. - :vartype value: list[~azure.mgmt.avs.models.WorkloadNetworkVirtualMachine] - :ivar next_link: URL to get the next page if any. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[WorkloadNetworkVirtualMachine]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkloadNetworkVirtualMachinesList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class WorkloadNetworkVMGroup(ProxyResource): - """NSX VM Group. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Resource ID. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :param display_name: Display name of the VM group. - :type display_name: str - :param members: Virtual machine members of this group. - :type members: list[str] - :ivar status: VM Group status. Possible values include: "SUCCESS", "FAILURE". - :vartype status: str or ~azure.mgmt.avs.models.VMGroupStatusEnum - :ivar provisioning_state: The provisioning state. Possible values include: "Succeeded", - "Failed", "Building", "Deleting", "Updating". - :vartype provisioning_state: str or - ~azure.mgmt.avs.models.WorkloadNetworkVMGroupProvisioningState - :param revision: NSX revision number. - :type revision: long - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'status': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'members': {'key': 'properties.members', 'type': '[str]'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'revision': {'key': 'properties.revision', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkloadNetworkVMGroup, self).__init__(**kwargs) - self.display_name = kwargs.get('display_name', None) - self.members = kwargs.get('members', None) - self.status = None - self.provisioning_state = None - self.revision = kwargs.get('revision', None) - - -class WorkloadNetworkVMGroupsList(msrest.serialization.Model): - """A list of NSX VM Groups. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The items on the page. - :vartype value: list[~azure.mgmt.avs.models.WorkloadNetworkVMGroup] - :ivar next_link: URL to get the next page if any. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[WorkloadNetworkVMGroup]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkloadNetworkVMGroupsList, self).__init__(**kwargs) - self.value = None - self.next_link = None diff --git a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/models/_models_py3.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/models/_models_py3.py index 792e14146f7f..187cbae2ccd2 100644 --- a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/models/_models_py3.py +++ b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/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. @@ -6,14 +7,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from .. import _serialization -from ._avs_client_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 Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """The core properties of ARM resources. Variables are only populated by the server, and will be ignored when sending a request. @@ -27,22 +36,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 @@ -59,115 +66,154 @@ class Addon(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param properties: The properties of an addon resource. - :type properties: ~azure.mgmt.avs.models.AddonProperties + :ivar properties: The properties of an addon resource. + :vartype properties: ~azure.mgmt.avs.models.AddonProperties """ _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'}, - 'properties': {'key': 'properties', 'type': 'AddonProperties'}, - } - - def __init__( - self, - *, - properties: Optional["AddonProperties"] = None, - **kwargs - ): - super(Addon, self).__init__(**kwargs) + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "AddonProperties"}, + } + + def __init__(self, *, properties: Optional["_models.AddonProperties"] = None, **kwargs): + """ + :keyword properties: The properties of an addon resource. + :paramtype properties: ~azure.mgmt.avs.models.AddonProperties + """ + super().__init__(**kwargs) self.properties = properties -class AddonProperties(msrest.serialization.Model): +class AddonProperties(_serialization.Model): """The properties of an addon. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: AddonHcxProperties, AddonSrmProperties, AddonVrProperties. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AddonArcProperties, AddonHcxProperties, AddonSrmProperties, AddonVrProperties 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 addon_type: Required. The type of private cloud addon.Constant filled by server. - Possible values include: "SRM", "VR", "HCX". - :type addon_type: str or ~azure.mgmt.avs.models.AddonType - :ivar provisioning_state: The state of the addon provisioning. Possible values include: - "Succeeded", "Failed", "Cancelled", "Building", "Deleting", "Updating". + :ivar addon_type: The type of private cloud addon. Required. Known values are: "SRM", "VR", + "HCX", and "Arc". + :vartype addon_type: str or ~azure.mgmt.avs.models.AddonType + :ivar provisioning_state: The state of the addon provisioning. Known values are: "Succeeded", + "Failed", "Cancelled", "Building", "Deleting", "Updating", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.avs.models.AddonProvisioningState """ _validation = { - 'addon_type': {'required': True}, - 'provisioning_state': {'readonly': True}, + "addon_type": {"required": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'addon_type': {'key': 'addonType', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "addon_type": {"key": "addonType", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } _subtype_map = { - 'addon_type': {'HCX': 'AddonHcxProperties', 'SRM': 'AddonSrmProperties', 'VR': 'AddonVrProperties'} + "addon_type": { + "Arc": "AddonArcProperties", + "HCX": "AddonHcxProperties", + "SRM": "AddonSrmProperties", + "VR": "AddonVrProperties", + } } - def __init__( - self, - **kwargs - ): - super(AddonProperties, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.addon_type = None # type: Optional[str] self.provisioning_state = None -class AddonHcxProperties(AddonProperties): - """The properties of an HCX addon. +class AddonArcProperties(AddonProperties): + """The properties of an Arc addon. 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 addon_type: Required. The type of private cloud addon.Constant filled by server. - Possible values include: "SRM", "VR", "HCX". - :type addon_type: str or ~azure.mgmt.avs.models.AddonType - :ivar provisioning_state: The state of the addon provisioning. Possible values include: - "Succeeded", "Failed", "Cancelled", "Building", "Deleting", "Updating". + :ivar addon_type: The type of private cloud addon. Required. Known values are: "SRM", "VR", + "HCX", and "Arc". + :vartype addon_type: str or ~azure.mgmt.avs.models.AddonType + :ivar provisioning_state: The state of the addon provisioning. Known values are: "Succeeded", + "Failed", "Cancelled", "Building", "Deleting", "Updating", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.avs.models.AddonProvisioningState - :param offer: Required. The HCX offer, example VMware MaaS Cloud Provider (Enterprise). - :type offer: str + :ivar v_center: The VMware vCenter resource ID. + :vartype v_center: str """ _validation = { - 'addon_type': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'offer': {'required': True}, + "addon_type": {"required": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'addon_type': {'key': 'addonType', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'offer': {'key': 'offer', 'type': 'str'}, + "addon_type": {"key": "addonType", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "v_center": {"key": "vCenter", "type": "str"}, } - def __init__( - self, - *, - offer: str, - **kwargs - ): - super(AddonHcxProperties, self).__init__(**kwargs) - self.addon_type = 'HCX' # type: str + def __init__(self, *, v_center: Optional[str] = None, **kwargs): + """ + :keyword v_center: The VMware vCenter resource ID. + :paramtype v_center: str + """ + super().__init__(**kwargs) + self.addon_type = "Arc" # type: str + self.v_center = v_center + + +class AddonHcxProperties(AddonProperties): + """The properties of an HCX addon. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar addon_type: The type of private cloud addon. Required. Known values are: "SRM", "VR", + "HCX", and "Arc". + :vartype addon_type: str or ~azure.mgmt.avs.models.AddonType + :ivar provisioning_state: The state of the addon provisioning. Known values are: "Succeeded", + "Failed", "Cancelled", "Building", "Deleting", "Updating", and "Canceled". + :vartype provisioning_state: str or ~azure.mgmt.avs.models.AddonProvisioningState + :ivar offer: The HCX offer, example VMware MaaS Cloud Provider (Enterprise). Required. + :vartype offer: str + """ + + _validation = { + "addon_type": {"required": True}, + "provisioning_state": {"readonly": True}, + "offer": {"required": True}, + } + + _attribute_map = { + "addon_type": {"key": "addonType", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "offer": {"key": "offer", "type": "str"}, + } + + def __init__(self, *, offer: str, **kwargs): + """ + :keyword offer: The HCX offer, example VMware MaaS Cloud Provider (Enterprise). Required. + :paramtype offer: str + """ + super().__init__(**kwargs) + self.addon_type = "HCX" # type: str self.offer = offer -class AddonList(msrest.serialization.Model): +class AddonList(_serialization.Model): """A paged list of addons. Variables are only populated by the server, and will be ignored when sending a request. @@ -179,20 +225,18 @@ class AddonList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Addon]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Addon]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(AddonList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None @@ -204,35 +248,34 @@ class AddonSrmProperties(AddonProperties): All required parameters must be populated in order to send to Azure. - :param addon_type: Required. The type of private cloud addon.Constant filled by server. - Possible values include: "SRM", "VR", "HCX". - :type addon_type: str or ~azure.mgmt.avs.models.AddonType - :ivar provisioning_state: The state of the addon provisioning. Possible values include: - "Succeeded", "Failed", "Cancelled", "Building", "Deleting", "Updating". + :ivar addon_type: The type of private cloud addon. Required. Known values are: "SRM", "VR", + "HCX", and "Arc". + :vartype addon_type: str or ~azure.mgmt.avs.models.AddonType + :ivar provisioning_state: The state of the addon provisioning. Known values are: "Succeeded", + "Failed", "Cancelled", "Building", "Deleting", "Updating", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.avs.models.AddonProvisioningState - :param license_key: The Site Recovery Manager (SRM) license. - :type license_key: str + :ivar license_key: The Site Recovery Manager (SRM) license. + :vartype license_key: str """ _validation = { - 'addon_type': {'required': True}, - 'provisioning_state': {'readonly': True}, + "addon_type": {"required": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'addon_type': {'key': 'addonType', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'license_key': {'key': 'licenseKey', 'type': 'str'}, - } - - def __init__( - self, - *, - license_key: Optional[str] = None, - **kwargs - ): - super(AddonSrmProperties, self).__init__(**kwargs) - self.addon_type = 'SRM' # type: str + "addon_type": {"key": "addonType", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "license_key": {"key": "licenseKey", "type": "str"}, + } + + def __init__(self, *, license_key: Optional[str] = None, **kwargs): + """ + :keyword license_key: The Site Recovery Manager (SRM) license. + :paramtype license_key: str + """ + super().__init__(**kwargs) + self.addon_type = "SRM" # type: str self.license_key = license_key @@ -243,40 +286,39 @@ class AddonVrProperties(AddonProperties): All required parameters must be populated in order to send to Azure. - :param addon_type: Required. The type of private cloud addon.Constant filled by server. - Possible values include: "SRM", "VR", "HCX". - :type addon_type: str or ~azure.mgmt.avs.models.AddonType - :ivar provisioning_state: The state of the addon provisioning. Possible values include: - "Succeeded", "Failed", "Cancelled", "Building", "Deleting", "Updating". + :ivar addon_type: The type of private cloud addon. Required. Known values are: "SRM", "VR", + "HCX", and "Arc". + :vartype addon_type: str or ~azure.mgmt.avs.models.AddonType + :ivar provisioning_state: The state of the addon provisioning. Known values are: "Succeeded", + "Failed", "Cancelled", "Building", "Deleting", "Updating", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.avs.models.AddonProvisioningState - :param vrs_count: Required. The vSphere Replication Server (VRS) count. - :type vrs_count: int + :ivar vrs_count: The vSphere Replication Server (VRS) count. Required. + :vartype vrs_count: int """ _validation = { - 'addon_type': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'vrs_count': {'required': True}, + "addon_type": {"required": True}, + "provisioning_state": {"readonly": True}, + "vrs_count": {"required": True}, } _attribute_map = { - 'addon_type': {'key': 'addonType', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'vrs_count': {'key': 'vrsCount', 'type': 'int'}, - } - - def __init__( - self, - *, - vrs_count: int, - **kwargs - ): - super(AddonVrProperties, self).__init__(**kwargs) - self.addon_type = 'VR' # type: str + "addon_type": {"key": "addonType", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "vrs_count": {"key": "vrsCount", "type": "int"}, + } + + def __init__(self, *, vrs_count: int, **kwargs): + """ + :keyword vrs_count: The vSphere Replication Server (VRS) count. Required. + :paramtype vrs_count: int + """ + super().__init__(**kwargs) + self.addon_type = "VR" # type: str self.vrs_count = vrs_count -class AdminCredentials(msrest.serialization.Model): +class AdminCredentials(_serialization.Model): """Administrative credentials for accessing vCenter and NSX-T. Variables are only populated by the server, and will be ignored when sending a request. @@ -292,63 +334,70 @@ class AdminCredentials(msrest.serialization.Model): """ _validation = { - 'nsxt_username': {'readonly': True}, - 'nsxt_password': {'readonly': True}, - 'vcenter_username': {'readonly': True}, - 'vcenter_password': {'readonly': True}, + "nsxt_username": {"readonly": True}, + "nsxt_password": {"readonly": True}, + "vcenter_username": {"readonly": True}, + "vcenter_password": {"readonly": True}, } _attribute_map = { - 'nsxt_username': {'key': 'nsxtUsername', 'type': 'str'}, - 'nsxt_password': {'key': 'nsxtPassword', 'type': 'str'}, - 'vcenter_username': {'key': 'vcenterUsername', 'type': 'str'}, - 'vcenter_password': {'key': 'vcenterPassword', 'type': 'str'}, + "nsxt_username": {"key": "nsxtUsername", "type": "str"}, + "nsxt_password": {"key": "nsxtPassword", "type": "str"}, + "vcenter_username": {"key": "vcenterUsername", "type": "str"}, + "vcenter_password": {"key": "vcenterPassword", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(AdminCredentials, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.nsxt_username = None self.nsxt_password = None self.vcenter_username = None self.vcenter_password = None -class AvailabilityProperties(msrest.serialization.Model): +class AvailabilityProperties(_serialization.Model): """The properties describing private cloud availability zone distribution. - :param strategy: The availability strategy for the private cloud. Possible values include: - "SingleZone", "DualZone". - :type strategy: str or ~azure.mgmt.avs.models.AvailabilityStrategy - :param zone: The primary availability zone for the private cloud. - :type zone: int - :param secondary_zone: The secondary availability zone for the private cloud. - :type secondary_zone: int + :ivar strategy: The availability strategy for the private cloud. Known values are: "SingleZone" + and "DualZone". + :vartype strategy: str or ~azure.mgmt.avs.models.AvailabilityStrategy + :ivar zone: The primary availability zone for the private cloud. + :vartype zone: int + :ivar secondary_zone: The secondary availability zone for the private cloud. + :vartype secondary_zone: int """ _attribute_map = { - 'strategy': {'key': 'strategy', 'type': 'str'}, - 'zone': {'key': 'zone', 'type': 'int'}, - 'secondary_zone': {'key': 'secondaryZone', 'type': 'int'}, + "strategy": {"key": "strategy", "type": "str"}, + "zone": {"key": "zone", "type": "int"}, + "secondary_zone": {"key": "secondaryZone", "type": "int"}, } def __init__( self, *, - strategy: Optional[Union[str, "AvailabilityStrategy"]] = None, + strategy: Optional[Union[str, "_models.AvailabilityStrategy"]] = None, zone: Optional[int] = None, secondary_zone: Optional[int] = None, **kwargs ): - super(AvailabilityProperties, self).__init__(**kwargs) + """ + :keyword strategy: The availability strategy for the private cloud. Known values are: + "SingleZone" and "DualZone". + :paramtype strategy: str or ~azure.mgmt.avs.models.AvailabilityStrategy + :keyword zone: The primary availability zone for the private cloud. + :paramtype zone: int + :keyword secondary_zone: The secondary availability zone for the private cloud. + :paramtype secondary_zone: int + """ + super().__init__(**kwargs) self.strategy = strategy self.zone = zone self.secondary_zone = secondary_zone -class Circuit(msrest.serialization.Model): +class Circuit(_serialization.Model): """An ExpressRoute Circuit. Variables are only populated by the server, and will be ignored when sending a request. @@ -364,24 +413,22 @@ class Circuit(msrest.serialization.Model): """ _validation = { - 'primary_subnet': {'readonly': True}, - 'secondary_subnet': {'readonly': True}, - 'express_route_id': {'readonly': True}, - 'express_route_private_peering_id': {'readonly': True}, + "primary_subnet": {"readonly": True}, + "secondary_subnet": {"readonly": True}, + "express_route_id": {"readonly": True}, + "express_route_private_peering_id": {"readonly": True}, } _attribute_map = { - 'primary_subnet': {'key': 'primarySubnet', 'type': 'str'}, - 'secondary_subnet': {'key': 'secondarySubnet', 'type': 'str'}, - 'express_route_id': {'key': 'expressRouteID', 'type': 'str'}, - 'express_route_private_peering_id': {'key': 'expressRoutePrivatePeeringID', 'type': 'str'}, + "primary_subnet": {"key": "primarySubnet", "type": "str"}, + "secondary_subnet": {"key": "secondarySubnet", "type": "str"}, + "express_route_id": {"key": "expressRouteID", "type": "str"}, + "express_route_private_peering_id": {"key": "expressRoutePrivatePeeringID", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(Circuit, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.primary_subnet = None self.secondary_subnet = None self.express_route_id = None @@ -399,40 +446,39 @@ class CloudLink(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar status: The state of the cloud link. Possible values include: "Active", "Building", - "Deleting", "Failed", "Disconnected". + :ivar status: The state of the cloud link. Known values are: "Active", "Building", "Deleting", + "Failed", and "Disconnected". :vartype status: str or ~azure.mgmt.avs.models.CloudLinkStatus - :param linked_cloud: Identifier of the other private cloud participating in the link. - :type linked_cloud: str + :ivar linked_cloud: Identifier of the other private cloud participating in the link. + :vartype linked_cloud: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'status': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "status": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'linked_cloud': {'key': 'properties.linkedCloud', 'type': 'str'}, - } - - def __init__( - self, - *, - linked_cloud: Optional[str] = None, - **kwargs - ): - super(CloudLink, self).__init__(**kwargs) + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, + "linked_cloud": {"key": "properties.linkedCloud", "type": "str"}, + } + + def __init__(self, *, linked_cloud: Optional[str] = None, **kwargs): + """ + :keyword linked_cloud: Identifier of the other private cloud participating in the link. + :paramtype linked_cloud: str + """ + super().__init__(**kwargs) self.status = None self.linked_cloud = linked_cloud -class CloudLinkList(msrest.serialization.Model): +class CloudLinkList(_serialization.Model): """A paged list of cloud links. Variables are only populated by the server, and will be ignored when sending a request. @@ -444,20 +490,18 @@ class CloudLinkList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[CloudLink]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[CloudLink]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(CloudLinkList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None @@ -475,48 +519,51 @@ class Cluster(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param sku: Required. The cluster SKU. - :type sku: ~azure.mgmt.avs.models.Sku - :param cluster_size: The cluster size. - :type cluster_size: int - :ivar provisioning_state: The state of the cluster provisioning. Possible values include: - "Succeeded", "Failed", "Cancelled", "Deleting", "Updating". + :ivar sku: The cluster SKU. Required. + :vartype sku: ~azure.mgmt.avs.models.Sku + :ivar cluster_size: The cluster size. + :vartype cluster_size: int + :ivar provisioning_state: The state of the cluster provisioning. Known values are: "Succeeded", + "Failed", "Cancelled", "Deleting", "Updating", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.avs.models.ClusterProvisioningState :ivar cluster_id: The identity. :vartype cluster_id: int - :param hosts: The hosts. - :type hosts: list[str] + :ivar hosts: The hosts. + :vartype hosts: list[str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'sku': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'cluster_id': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "sku": {"required": True}, + "provisioning_state": {"readonly": True}, + "cluster_id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'cluster_size': {'key': 'properties.clusterSize', 'type': 'int'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'cluster_id': {'key': 'properties.clusterId', 'type': 'int'}, - 'hosts': {'key': 'properties.hosts', 'type': '[str]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "cluster_size": {"key": "properties.clusterSize", "type": "int"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "cluster_id": {"key": "properties.clusterId", "type": "int"}, + "hosts": {"key": "properties.hosts", "type": "[str]"}, } def __init__( - self, - *, - sku: "Sku", - cluster_size: Optional[int] = None, - hosts: Optional[List[str]] = None, - **kwargs + self, *, sku: "_models.Sku", cluster_size: Optional[int] = None, hosts: Optional[List[str]] = None, **kwargs ): - super(Cluster, self).__init__(**kwargs) + """ + :keyword sku: The cluster SKU. Required. + :paramtype sku: ~azure.mgmt.avs.models.Sku + :keyword cluster_size: The cluster size. + :paramtype cluster_size: int + :keyword hosts: The hosts. + :paramtype hosts: list[str] + """ + super().__init__(**kwargs) self.sku = sku self.cluster_size = cluster_size self.provisioning_state = None @@ -524,7 +571,7 @@ def __init__( self.hosts = hosts -class ClusterList(msrest.serialization.Model): +class ClusterList(_serialization.Model): """A paged list of clusters. Variables are only populated by the server, and will be ignored when sending a request. @@ -536,60 +583,58 @@ class ClusterList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Cluster]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Cluster]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(ClusterList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class CommonClusterProperties(msrest.serialization.Model): +class CommonClusterProperties(_serialization.Model): """The common properties of a cluster. Variables are only populated by the server, and will be ignored when sending a request. - :param cluster_size: The cluster size. - :type cluster_size: int - :ivar provisioning_state: The state of the cluster provisioning. Possible values include: - "Succeeded", "Failed", "Cancelled", "Deleting", "Updating". + :ivar cluster_size: The cluster size. + :vartype cluster_size: int + :ivar provisioning_state: The state of the cluster provisioning. Known values are: "Succeeded", + "Failed", "Cancelled", "Deleting", "Updating", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.avs.models.ClusterProvisioningState :ivar cluster_id: The identity. :vartype cluster_id: int - :param hosts: The hosts. - :type hosts: list[str] + :ivar hosts: The hosts. + :vartype hosts: list[str] """ _validation = { - 'provisioning_state': {'readonly': True}, - 'cluster_id': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "cluster_id": {"readonly": True}, } _attribute_map = { - 'cluster_size': {'key': 'clusterSize', 'type': 'int'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'cluster_id': {'key': 'clusterId', 'type': 'int'}, - 'hosts': {'key': 'hosts', 'type': '[str]'}, - } - - def __init__( - self, - *, - cluster_size: Optional[int] = None, - hosts: Optional[List[str]] = None, - **kwargs - ): - super(CommonClusterProperties, self).__init__(**kwargs) + "cluster_size": {"key": "clusterSize", "type": "int"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "cluster_id": {"key": "clusterId", "type": "int"}, + "hosts": {"key": "hosts", "type": "[str]"}, + } + + def __init__(self, *, cluster_size: Optional[int] = None, hosts: Optional[List[str]] = None, **kwargs): + """ + :keyword cluster_size: The cluster size. + :paramtype cluster_size: int + :keyword hosts: The hosts. + :paramtype hosts: list[str] + """ + super().__init__(**kwargs) self.cluster_size = cluster_size self.provisioning_state = None self.cluster_id = None @@ -601,65 +646,113 @@ class ClusterProperties(CommonClusterProperties): Variables are only populated by the server, and will be ignored when sending a request. - :param cluster_size: The cluster size. - :type cluster_size: int - :ivar provisioning_state: The state of the cluster provisioning. Possible values include: - "Succeeded", "Failed", "Cancelled", "Deleting", "Updating". + :ivar cluster_size: The cluster size. + :vartype cluster_size: int + :ivar provisioning_state: The state of the cluster provisioning. Known values are: "Succeeded", + "Failed", "Cancelled", "Deleting", "Updating", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.avs.models.ClusterProvisioningState :ivar cluster_id: The identity. :vartype cluster_id: int - :param hosts: The hosts. - :type hosts: list[str] + :ivar hosts: The hosts. + :vartype hosts: list[str] """ _validation = { - 'provisioning_state': {'readonly': True}, - 'cluster_id': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "cluster_id": {"readonly": True}, } _attribute_map = { - 'cluster_size': {'key': 'clusterSize', 'type': 'int'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'cluster_id': {'key': 'clusterId', 'type': 'int'}, - 'hosts': {'key': 'hosts', 'type': '[str]'}, + "cluster_size": {"key": "clusterSize", "type": "int"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "cluster_id": {"key": "clusterId", "type": "int"}, + "hosts": {"key": "hosts", "type": "[str]"}, } - def __init__( - self, - *, - cluster_size: Optional[int] = None, - hosts: Optional[List[str]] = None, - **kwargs - ): - super(ClusterProperties, self).__init__(cluster_size=cluster_size, hosts=hosts, **kwargs) + def __init__(self, *, cluster_size: Optional[int] = None, hosts: Optional[List[str]] = None, **kwargs): + """ + :keyword cluster_size: The cluster size. + :paramtype cluster_size: int + :keyword hosts: The hosts. + :paramtype hosts: list[str] + """ + super().__init__(cluster_size=cluster_size, hosts=hosts, **kwargs) -class ClusterUpdate(msrest.serialization.Model): +class ClusterUpdate(_serialization.Model): """An update of a cluster resource. - :param cluster_size: The cluster size. - :type cluster_size: int - :param hosts: The hosts. - :type hosts: list[str] + :ivar cluster_size: The cluster size. + :vartype cluster_size: int + :ivar hosts: The hosts. + :vartype hosts: list[str] """ _attribute_map = { - 'cluster_size': {'key': 'properties.clusterSize', 'type': 'int'}, - 'hosts': {'key': 'properties.hosts', 'type': '[str]'}, - } - - def __init__( - self, - *, - cluster_size: Optional[int] = None, - hosts: Optional[List[str]] = None, - **kwargs - ): - super(ClusterUpdate, self).__init__(**kwargs) + "cluster_size": {"key": "properties.clusterSize", "type": "int"}, + "hosts": {"key": "properties.hosts", "type": "[str]"}, + } + + def __init__(self, *, cluster_size: Optional[int] = None, hosts: Optional[List[str]] = None, **kwargs): + """ + :keyword cluster_size: The cluster size. + :paramtype cluster_size: int + :keyword hosts: The hosts. + :paramtype hosts: list[str] + """ + super().__init__(**kwargs) self.cluster_size = cluster_size self.hosts = hosts +class ClusterZone(_serialization.Model): + """Zone and associated hosts info. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar hosts: List of hosts belonging to the availability zone in a cluster. + :vartype hosts: list[str] + :ivar zone: Availability zone identifier. + :vartype zone: str + """ + + _validation = { + "hosts": {"readonly": True}, + "zone": {"readonly": True}, + } + + _attribute_map = { + "hosts": {"key": "hosts", "type": "[str]"}, + "zone": {"key": "zone", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.hosts = None + self.zone = None + + +class ClusterZoneList(_serialization.Model): + """List of all zones and associated hosts for a cluster. + + :ivar zones: Zone and associated hosts info. + :vartype zones: list[~azure.mgmt.avs.models.ClusterZone] + """ + + _attribute_map = { + "zones": {"key": "zones", "type": "[ClusterZone]"}, + } + + def __init__(self, *, zones: Optional[List["_models.ClusterZone"]] = None, **kwargs): + """ + :keyword zones: Zone and associated hosts info. + :paramtype zones: list[~azure.mgmt.avs.models.ClusterZone] + """ + super().__init__(**kwargs) + self.zones = zones + + class Datastore(Resource): """A datastore resource. @@ -671,51 +764,58 @@ class Datastore(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar provisioning_state: The state of the datastore provisioning. Possible values include: - "Succeeded", "Failed", "Cancelled", "Pending", "Creating", "Updating", "Deleting". + :ivar provisioning_state: The state of the datastore provisioning. Known values are: + "Succeeded", "Failed", "Cancelled", "Pending", "Creating", "Updating", "Deleting", and + "Canceled". :vartype provisioning_state: str or ~azure.mgmt.avs.models.DatastoreProvisioningState - :param net_app_volume: An Azure NetApp Files volume. - :type net_app_volume: ~azure.mgmt.avs.models.NetAppVolume - :param disk_pool_volume: An iSCSI volume. - :type disk_pool_volume: ~azure.mgmt.avs.models.DiskPoolVolume - :ivar status: The operational status of the datastore. Possible values include: "Unknown", - "Accessible", "Inaccessible", "Attached", "Detached", "LostCommunication", "DeadOrError". + :ivar net_app_volume: An Azure NetApp Files volume. + :vartype net_app_volume: ~azure.mgmt.avs.models.NetAppVolume + :ivar disk_pool_volume: An iSCSI volume. + :vartype disk_pool_volume: ~azure.mgmt.avs.models.DiskPoolVolume + :ivar status: The operational status of the datastore. Known values are: "Unknown", + "Accessible", "Inaccessible", "Attached", "Detached", "LostCommunication", and "DeadOrError". :vartype status: str or ~azure.mgmt.avs.models.DatastoreStatus """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'net_app_volume': {'key': 'properties.netAppVolume', 'type': 'NetAppVolume'}, - 'disk_pool_volume': {'key': 'properties.diskPoolVolume', 'type': 'DiskPoolVolume'}, - 'status': {'key': 'properties.status', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "net_app_volume": {"key": "properties.netAppVolume", "type": "NetAppVolume"}, + "disk_pool_volume": {"key": "properties.diskPoolVolume", "type": "DiskPoolVolume"}, + "status": {"key": "properties.status", "type": "str"}, } def __init__( self, *, - net_app_volume: Optional["NetAppVolume"] = None, - disk_pool_volume: Optional["DiskPoolVolume"] = None, + net_app_volume: Optional["_models.NetAppVolume"] = None, + disk_pool_volume: Optional["_models.DiskPoolVolume"] = None, **kwargs ): - super(Datastore, self).__init__(**kwargs) + """ + :keyword net_app_volume: An Azure NetApp Files volume. + :paramtype net_app_volume: ~azure.mgmt.avs.models.NetAppVolume + :keyword disk_pool_volume: An iSCSI volume. + :paramtype disk_pool_volume: ~azure.mgmt.avs.models.DiskPoolVolume + """ + super().__init__(**kwargs) self.provisioning_state = None self.net_app_volume = net_app_volume self.disk_pool_volume = disk_pool_volume self.status = None -class DatastoreList(msrest.serialization.Model): +class DatastoreList(_serialization.Model): """A paged list of datastores. Variables are only populated by the server, and will be ignored when sending a request. @@ -727,127 +827,140 @@ class DatastoreList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Datastore]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Datastore]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(DatastoreList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class DiskPoolVolume(msrest.serialization.Model): +class DiskPoolVolume(_serialization.Model): """An iSCSI volume from Microsoft.StoragePool provider. 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 target_id: Required. Azure resource ID of the iSCSI target. - :type target_id: str - :param lun_name: Required. Name of the LUN to be used for datastore. - :type lun_name: str - :param mount_option: Mode that describes whether the LUN has to be mounted as a datastore or - attached as a LUN. Possible values include: "MOUNT", "ATTACH". Default value: "MOUNT". - :type mount_option: str or ~azure.mgmt.avs.models.MountOptionEnum + :ivar target_id: Azure resource ID of the iSCSI target. Required. + :vartype target_id: str + :ivar lun_name: Name of the LUN to be used for datastore. Required. + :vartype lun_name: str + :ivar mount_option: Mode that describes whether the LUN has to be mounted as a datastore or + attached as a LUN. Known values are: "MOUNT" and "ATTACH". + :vartype mount_option: str or ~azure.mgmt.avs.models.MountOptionEnum :ivar path: Device path. :vartype path: str """ _validation = { - 'target_id': {'required': True}, - 'lun_name': {'required': True}, - 'path': {'readonly': True}, + "target_id": {"required": True}, + "lun_name": {"required": True}, + "path": {"readonly": True}, } _attribute_map = { - 'target_id': {'key': 'targetId', 'type': 'str'}, - 'lun_name': {'key': 'lunName', 'type': 'str'}, - 'mount_option': {'key': 'mountOption', 'type': 'str'}, - 'path': {'key': 'path', 'type': 'str'}, + "target_id": {"key": "targetId", "type": "str"}, + "lun_name": {"key": "lunName", "type": "str"}, + "mount_option": {"key": "mountOption", "type": "str"}, + "path": {"key": "path", "type": "str"}, } def __init__( - self, - *, - target_id: str, - lun_name: str, - mount_option: Optional[Union[str, "MountOptionEnum"]] = "MOUNT", - **kwargs + self, *, target_id: str, lun_name: str, mount_option: Union[str, "_models.MountOptionEnum"] = "MOUNT", **kwargs ): - super(DiskPoolVolume, self).__init__(**kwargs) + """ + :keyword target_id: Azure resource ID of the iSCSI target. Required. + :paramtype target_id: str + :keyword lun_name: Name of the LUN to be used for datastore. Required. + :paramtype lun_name: str + :keyword mount_option: Mode that describes whether the LUN has to be mounted as a datastore or + attached as a LUN. Known values are: "MOUNT" and "ATTACH". + :paramtype mount_option: str or ~azure.mgmt.avs.models.MountOptionEnum + """ + super().__init__(**kwargs) self.target_id = target_id self.lun_name = lun_name self.mount_option = mount_option self.path = None -class Encryption(msrest.serialization.Model): +class Encryption(_serialization.Model): """The properties of customer managed encryption key. - :param status: Status of customer managed encryption key. Possible values include: "Enabled", + :ivar status: Status of customer managed encryption key. Known values are: "Enabled" and "Disabled". - :type status: str or ~azure.mgmt.avs.models.EncryptionState - :param key_vault_properties: The key vault where the encryption key is stored. - :type key_vault_properties: ~azure.mgmt.avs.models.EncryptionKeyVaultProperties + :vartype status: str or ~azure.mgmt.avs.models.EncryptionState + :ivar key_vault_properties: The key vault where the encryption key is stored. + :vartype key_vault_properties: ~azure.mgmt.avs.models.EncryptionKeyVaultProperties """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'key_vault_properties': {'key': 'keyVaultProperties', 'type': 'EncryptionKeyVaultProperties'}, + "status": {"key": "status", "type": "str"}, + "key_vault_properties": {"key": "keyVaultProperties", "type": "EncryptionKeyVaultProperties"}, } def __init__( self, *, - status: Optional[Union[str, "EncryptionState"]] = None, - key_vault_properties: Optional["EncryptionKeyVaultProperties"] = None, + status: Optional[Union[str, "_models.EncryptionState"]] = None, + key_vault_properties: Optional["_models.EncryptionKeyVaultProperties"] = None, **kwargs ): - super(Encryption, self).__init__(**kwargs) + """ + :keyword status: Status of customer managed encryption key. Known values are: "Enabled" and + "Disabled". + :paramtype status: str or ~azure.mgmt.avs.models.EncryptionState + :keyword key_vault_properties: The key vault where the encryption key is stored. + :paramtype key_vault_properties: ~azure.mgmt.avs.models.EncryptionKeyVaultProperties + """ + super().__init__(**kwargs) self.status = status self.key_vault_properties = key_vault_properties -class EncryptionKeyVaultProperties(msrest.serialization.Model): +class EncryptionKeyVaultProperties(_serialization.Model): """An Encryption Key. Variables are only populated by the server, and will be ignored when sending a request. - :param key_name: The name of the key. - :type key_name: str - :param key_version: The version of the key. - :type key_version: str - :param key_vault_url: The URL of the vault. - :type key_vault_url: str - :ivar key_state: The state of key provided. Possible values include: "Connected", - "AccessDenied". + :ivar key_name: The name of the key. + :vartype key_name: str + :ivar key_version: The version of the key. + :vartype key_version: str + :ivar auto_detected_key_version: The auto-detected version of the key if versionType is + auto-detected. + :vartype auto_detected_key_version: str + :ivar key_vault_url: The URL of the vault. + :vartype key_vault_url: str + :ivar key_state: The state of key provided. Known values are: "Connected" and "AccessDenied". :vartype key_state: str or ~azure.mgmt.avs.models.EncryptionKeyStatus - :ivar version_type: Property of the key if user provided or auto detected. Possible values - include: "Fixed", "AutoDetected". + :ivar version_type: Property of the key if user provided or auto detected. Known values are: + "Fixed" and "AutoDetected". :vartype version_type: str or ~azure.mgmt.avs.models.EncryptionVersionType """ _validation = { - 'key_state': {'readonly': True}, - 'version_type': {'readonly': True}, + "auto_detected_key_version": {"readonly": True}, + "key_state": {"readonly": True}, + "version_type": {"readonly": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, - 'key_version': {'key': 'keyVersion', 'type': 'str'}, - 'key_vault_url': {'key': 'keyVaultUrl', 'type': 'str'}, - 'key_state': {'key': 'keyState', 'type': 'str'}, - 'version_type': {'key': 'versionType', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, + "key_version": {"key": "keyVersion", "type": "str"}, + "auto_detected_key_version": {"key": "autoDetectedKeyVersion", "type": "str"}, + "key_vault_url": {"key": "keyVaultUrl", "type": "str"}, + "key_state": {"key": "keyState", "type": "str"}, + "version_type": {"key": "versionType", "type": "str"}, } def __init__( @@ -858,15 +971,24 @@ def __init__( key_vault_url: Optional[str] = None, **kwargs ): - super(EncryptionKeyVaultProperties, self).__init__(**kwargs) + """ + :keyword key_name: The name of the key. + :paramtype key_name: str + :keyword key_version: The version of the key. + :paramtype key_version: str + :keyword key_vault_url: The URL of the vault. + :paramtype key_vault_url: str + """ + super().__init__(**kwargs) self.key_name = key_name self.key_version = key_version + self.auto_detected_key_version = None self.key_vault_url = key_vault_url self.key_state = None self.version_type = None -class Endpoints(msrest.serialization.Model): +class Endpoints(_serialization.Model): """Endpoint addresses. Variables are only populated by the server, and will be ignored when sending a request. @@ -880,28 +1002,26 @@ class Endpoints(msrest.serialization.Model): """ _validation = { - 'nsxt_manager': {'readonly': True}, - 'vcsa': {'readonly': True}, - 'hcx_cloud_manager': {'readonly': True}, + "nsxt_manager": {"readonly": True}, + "vcsa": {"readonly": True}, + "hcx_cloud_manager": {"readonly": True}, } _attribute_map = { - 'nsxt_manager': {'key': 'nsxtManager', 'type': 'str'}, - 'vcsa': {'key': 'vcsa', 'type': 'str'}, - 'hcx_cloud_manager': {'key': 'hcxCloudManager', 'type': 'str'}, + "nsxt_manager": {"key": "nsxtManager", "type": "str"}, + "vcsa": {"key": "vcsa", "type": "str"}, + "hcx_cloud_manager": {"key": "hcxCloudManager", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(Endpoints, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.nsxt_manager = None self.vcsa = None self.hcx_cloud_manager = None -class ErrorAdditionalInfo(msrest.serialization.Model): +class ErrorAdditionalInfo(_serialization.Model): """The resource management error additional info. Variables are only populated by the server, and will be ignored when sending a request. @@ -909,29 +1029,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). Variables are only populated by the server, and will be ignored when sending a request. @@ -949,26 +1067,24 @@ class ErrorResponse(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponse]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorResponse]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -988,50 +1104,49 @@ class ExpressRouteAuthorization(Resource): :ivar type: Resource type. :vartype type: str :ivar provisioning_state: The state of the ExpressRoute Circuit Authorization provisioning. - Possible values include: "Succeeded", "Failed", "Updating". + Known values are: "Succeeded", "Failed", "Updating", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.avs.models.ExpressRouteAuthorizationProvisioningState :ivar express_route_authorization_id: The ID of the ExpressRoute Circuit Authorization. :vartype express_route_authorization_id: str :ivar express_route_authorization_key: The key of the ExpressRoute Circuit Authorization. :vartype express_route_authorization_key: str - :param express_route_id: The ID of the ExpressRoute Circuit. - :type express_route_id: str + :ivar express_route_id: The ID of the ExpressRoute Circuit. + :vartype express_route_id: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'express_route_authorization_id': {'readonly': True}, - 'express_route_authorization_key': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "express_route_authorization_id": {"readonly": True}, + "express_route_authorization_key": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'express_route_authorization_id': {'key': 'properties.expressRouteAuthorizationId', 'type': 'str'}, - 'express_route_authorization_key': {'key': 'properties.expressRouteAuthorizationKey', 'type': 'str'}, - 'express_route_id': {'key': 'properties.expressRouteId', 'type': 'str'}, - } - - def __init__( - self, - *, - express_route_id: Optional[str] = None, - **kwargs - ): - super(ExpressRouteAuthorization, self).__init__(**kwargs) + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "express_route_authorization_id": {"key": "properties.expressRouteAuthorizationId", "type": "str"}, + "express_route_authorization_key": {"key": "properties.expressRouteAuthorizationKey", "type": "str"}, + "express_route_id": {"key": "properties.expressRouteId", "type": "str"}, + } + + def __init__(self, *, express_route_id: Optional[str] = None, **kwargs): + """ + :keyword express_route_id: The ID of the ExpressRoute Circuit. + :paramtype express_route_id: str + """ + super().__init__(**kwargs) self.provisioning_state = None self.express_route_authorization_id = None self.express_route_authorization_key = None self.express_route_id = express_route_id -class ExpressRouteAuthorizationList(msrest.serialization.Model): +class ExpressRouteAuthorizationList(_serialization.Model): """A paged list of ExpressRoute Circuit Authorizations. Variables are only populated by the server, and will be ignored when sending a request. @@ -1043,20 +1158,18 @@ class ExpressRouteAuthorizationList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ExpressRouteAuthorization]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ExpressRouteAuthorization]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(ExpressRouteAuthorizationList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None @@ -1073,45 +1186,45 @@ class GlobalReachConnection(Resource): :ivar type: Resource type. :vartype type: str :ivar provisioning_state: The state of the ExpressRoute Circuit Authorization provisioning. - Possible values include: "Succeeded", "Failed", "Updating". + Known values are: "Succeeded", "Failed", "Updating", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.avs.models.GlobalReachConnectionProvisioningState :ivar address_prefix: The network used for global reach carved out from the original network block provided for the private cloud. :vartype address_prefix: str - :param authorization_key: Authorization key from the peer express route used for the global + :ivar authorization_key: Authorization key from the peer express route used for the global reach connection. - :type authorization_key: str - :ivar circuit_connection_status: The connection status of the global reach connection. Possible - values include: "Connected", "Connecting", "Disconnected". + :vartype authorization_key: str + :ivar circuit_connection_status: The connection status of the global reach connection. Known + values are: "Connected", "Connecting", and "Disconnected". :vartype circuit_connection_status: str or ~azure.mgmt.avs.models.GlobalReachConnectionStatus - :param peer_express_route_circuit: Identifier of the ExpressRoute Circuit to peer with in the + :ivar peer_express_route_circuit: Identifier of the ExpressRoute Circuit to peer with in the global reach connection. - :type peer_express_route_circuit: str - :param express_route_id: The ID of the Private Cloud's ExpressRoute Circuit that is + :vartype peer_express_route_circuit: str + :ivar express_route_id: The ID of the Private Cloud's ExpressRoute Circuit that is participating in the global reach connection. - :type express_route_id: str + :vartype express_route_id: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'address_prefix': {'readonly': True}, - 'circuit_connection_status': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "address_prefix": {"readonly": True}, + "circuit_connection_status": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'address_prefix': {'key': 'properties.addressPrefix', 'type': 'str'}, - 'authorization_key': {'key': 'properties.authorizationKey', 'type': 'str'}, - 'circuit_connection_status': {'key': 'properties.circuitConnectionStatus', 'type': 'str'}, - 'peer_express_route_circuit': {'key': 'properties.peerExpressRouteCircuit', 'type': 'str'}, - 'express_route_id': {'key': 'properties.expressRouteId', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "address_prefix": {"key": "properties.addressPrefix", "type": "str"}, + "authorization_key": {"key": "properties.authorizationKey", "type": "str"}, + "circuit_connection_status": {"key": "properties.circuitConnectionStatus", "type": "str"}, + "peer_express_route_circuit": {"key": "properties.peerExpressRouteCircuit", "type": "str"}, + "express_route_id": {"key": "properties.expressRouteId", "type": "str"}, } def __init__( @@ -1122,7 +1235,18 @@ def __init__( express_route_id: Optional[str] = None, **kwargs ): - super(GlobalReachConnection, self).__init__(**kwargs) + """ + :keyword authorization_key: Authorization key from the peer express route used for the global + reach connection. + :paramtype authorization_key: str + :keyword peer_express_route_circuit: Identifier of the ExpressRoute Circuit to peer with in the + global reach connection. + :paramtype peer_express_route_circuit: str + :keyword express_route_id: The ID of the Private Cloud's ExpressRoute Circuit that is + participating in the global reach connection. + :paramtype express_route_id: str + """ + super().__init__(**kwargs) self.provisioning_state = None self.address_prefix = None self.authorization_key = authorization_key @@ -1131,7 +1255,7 @@ def __init__( self.express_route_id = express_route_id -class GlobalReachConnectionList(msrest.serialization.Model): +class GlobalReachConnectionList(_serialization.Model): """A paged list of global reach connections. Variables are only populated by the server, and will be ignored when sending a request. @@ -1143,20 +1267,18 @@ class GlobalReachConnectionList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[GlobalReachConnection]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[GlobalReachConnection]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(GlobalReachConnectionList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None @@ -1174,37 +1296,35 @@ class HcxEnterpriseSite(Resource): :vartype type: str :ivar activation_key: The activation key. :vartype activation_key: str - :ivar status: The status of the HCX Enterprise Site. Possible values include: "Available", - "Consumed", "Deactivated", "Deleted". + :ivar status: The status of the HCX Enterprise Site. Known values are: "Available", "Consumed", + "Deactivated", and "Deleted". :vartype status: str or ~azure.mgmt.avs.models.HcxEnterpriseSiteStatus """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'activation_key': {'readonly': True}, - 'status': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "activation_key": {"readonly": True}, + "status": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'activation_key': {'key': 'properties.activationKey', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "activation_key": {"key": "properties.activationKey", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(HcxEnterpriseSite, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.activation_key = None self.status = None -class HcxEnterpriseSiteList(msrest.serialization.Model): +class HcxEnterpriseSiteList(_serialization.Model): """A paged list of HCX Enterprise Sites. Variables are only populated by the server, and will be ignored when sending a request. @@ -1216,63 +1336,61 @@ class HcxEnterpriseSiteList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[HcxEnterpriseSite]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[HcxEnterpriseSite]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(HcxEnterpriseSiteList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class IdentitySource(msrest.serialization.Model): +class IdentitySource(_serialization.Model): """vCenter Single Sign On Identity Source. - :param name: The name of the identity source. - :type name: str - :param alias: The domain's NetBIOS name. - :type alias: str - :param domain: The domain's dns name. - :type domain: str - :param base_user_dn: The base distinguished name for users. - :type base_user_dn: str - :param base_group_dn: The base distinguished name for groups. - :type base_group_dn: str - :param primary_server: Primary server URL. - :type primary_server: str - :param secondary_server: Secondary server URL. - :type secondary_server: str - :param ssl: Protect LDAP communication using SSL certificate (LDAPS). Possible values include: - "Enabled", "Disabled". - :type ssl: str or ~azure.mgmt.avs.models.SslEnum - :param username: The ID of an Active Directory user with a minimum of read-only access to Base + :ivar name: The name of the identity source. + :vartype name: str + :ivar alias: The domain's NetBIOS name. + :vartype alias: str + :ivar domain: The domain's dns name. + :vartype domain: str + :ivar base_user_dn: The base distinguished name for users. + :vartype base_user_dn: str + :ivar base_group_dn: The base distinguished name for groups. + :vartype base_group_dn: str + :ivar primary_server: Primary server URL. + :vartype primary_server: str + :ivar secondary_server: Secondary server URL. + :vartype secondary_server: str + :ivar ssl: Protect LDAP communication using SSL certificate (LDAPS). Known values are: + "Enabled" and "Disabled". + :vartype ssl: str or ~azure.mgmt.avs.models.SslEnum + :ivar username: The ID of an Active Directory user with a minimum of read-only access to Base DN for users and group. - :type username: str - :param password: The password of the Active Directory user with a minimum of read-only access - to Base DN for users and groups. - :type password: str + :vartype username: str + :ivar password: The password of the Active Directory user with a minimum of read-only access to + Base DN for users and groups. + :vartype password: str """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'alias': {'key': 'alias', 'type': 'str'}, - 'domain': {'key': 'domain', 'type': 'str'}, - 'base_user_dn': {'key': 'baseUserDN', 'type': 'str'}, - 'base_group_dn': {'key': 'baseGroupDN', 'type': 'str'}, - 'primary_server': {'key': 'primaryServer', 'type': 'str'}, - 'secondary_server': {'key': 'secondaryServer', 'type': 'str'}, - 'ssl': {'key': 'ssl', 'type': 'str'}, - 'username': {'key': 'username', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "alias": {"key": "alias", "type": "str"}, + "domain": {"key": "domain", "type": "str"}, + "base_user_dn": {"key": "baseUserDN", "type": "str"}, + "base_group_dn": {"key": "baseGroupDN", "type": "str"}, + "primary_server": {"key": "primaryServer", "type": "str"}, + "secondary_server": {"key": "secondaryServer", "type": "str"}, + "ssl": {"key": "ssl", "type": "str"}, + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, } def __init__( @@ -1285,12 +1403,37 @@ def __init__( base_group_dn: Optional[str] = None, primary_server: Optional[str] = None, secondary_server: Optional[str] = None, - ssl: Optional[Union[str, "SslEnum"]] = None, + ssl: Optional[Union[str, "_models.SslEnum"]] = None, username: Optional[str] = None, password: Optional[str] = None, **kwargs ): - super(IdentitySource, self).__init__(**kwargs) + """ + :keyword name: The name of the identity source. + :paramtype name: str + :keyword alias: The domain's NetBIOS name. + :paramtype alias: str + :keyword domain: The domain's dns name. + :paramtype domain: str + :keyword base_user_dn: The base distinguished name for users. + :paramtype base_user_dn: str + :keyword base_group_dn: The base distinguished name for groups. + :paramtype base_group_dn: str + :keyword primary_server: Primary server URL. + :paramtype primary_server: str + :keyword secondary_server: Secondary server URL. + :paramtype secondary_server: str + :keyword ssl: Protect LDAP communication using SSL certificate (LDAPS). Known values are: + "Enabled" and "Disabled". + :paramtype ssl: str or ~azure.mgmt.avs.models.SslEnum + :keyword username: The ID of an Active Directory user with a minimum of read-only access to + Base DN for users and group. + :paramtype username: str + :keyword password: The password of the Active Directory user with a minimum of read-only access + to Base DN for users and groups. + :paramtype password: str + """ + super().__init__(**kwargs) self.name = name self.alias = alias self.domain = domain @@ -1303,21 +1446,21 @@ def __init__( self.password = password -class LogSpecification(msrest.serialization.Model): +class LogSpecification(_serialization.Model): """Specifications of the Log for Azure Monitoring. - :param name: Name of the log. - :type name: str - :param display_name: Localized friendly display name of the log. - :type display_name: str - :param blob_duration: Blob duration of the log. - :type blob_duration: str + :ivar name: Name of the log. + :vartype name: str + :ivar display_name: Localized friendly display name of the log. + :vartype display_name: str + :ivar blob_duration: Blob duration of the log. + :vartype blob_duration: str """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'blob_duration': {'key': 'blobDuration', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "blob_duration": {"key": "blobDuration", "type": "str"}, } def __init__( @@ -1328,7 +1471,15 @@ def __init__( blob_duration: Optional[str] = None, **kwargs ): - super(LogSpecification, self).__init__(**kwargs) + """ + :keyword name: Name of the log. + :paramtype name: str + :keyword display_name: Localized friendly display name of the log. + :paramtype display_name: str + :keyword blob_duration: Blob duration of the log. + :paramtype blob_duration: str + """ + super().__init__(**kwargs) self.name = name self.display_name = display_name self.blob_duration = blob_duration @@ -1339,58 +1490,58 @@ class ManagementCluster(CommonClusterProperties): Variables are only populated by the server, and will be ignored when sending a request. - :param cluster_size: The cluster size. - :type cluster_size: int - :ivar provisioning_state: The state of the cluster provisioning. Possible values include: - "Succeeded", "Failed", "Cancelled", "Deleting", "Updating". + :ivar cluster_size: The cluster size. + :vartype cluster_size: int + :ivar provisioning_state: The state of the cluster provisioning. Known values are: "Succeeded", + "Failed", "Cancelled", "Deleting", "Updating", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.avs.models.ClusterProvisioningState :ivar cluster_id: The identity. :vartype cluster_id: int - :param hosts: The hosts. - :type hosts: list[str] + :ivar hosts: The hosts. + :vartype hosts: list[str] """ _validation = { - 'provisioning_state': {'readonly': True}, - 'cluster_id': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "cluster_id": {"readonly": True}, } _attribute_map = { - 'cluster_size': {'key': 'clusterSize', 'type': 'int'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'cluster_id': {'key': 'clusterId', 'type': 'int'}, - 'hosts': {'key': 'hosts', 'type': '[str]'}, + "cluster_size": {"key": "clusterSize", "type": "int"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "cluster_id": {"key": "clusterId", "type": "int"}, + "hosts": {"key": "hosts", "type": "[str]"}, } - def __init__( - self, - *, - cluster_size: Optional[int] = None, - hosts: Optional[List[str]] = None, - **kwargs - ): - super(ManagementCluster, self).__init__(cluster_size=cluster_size, hosts=hosts, **kwargs) + def __init__(self, *, cluster_size: Optional[int] = None, hosts: Optional[List[str]] = None, **kwargs): + """ + :keyword cluster_size: The cluster size. + :paramtype cluster_size: int + :keyword hosts: The hosts. + :paramtype hosts: list[str] + """ + super().__init__(cluster_size=cluster_size, hosts=hosts, **kwargs) -class MetricDimension(msrest.serialization.Model): +class MetricDimension(_serialization.Model): """Specifications of the Dimension of metrics. - :param name: Name of the dimension. - :type name: str - :param display_name: Localized friendly display name of the dimension. - :type display_name: str - :param internal_name: Name of the dimension as it appears in MDM. - :type internal_name: str - :param to_be_exported_for_shoebox: A boolean flag indicating whether this dimension should be + :ivar name: Name of the dimension. + :vartype name: str + :ivar display_name: Localized friendly display name of the dimension. + :vartype display_name: str + :ivar internal_name: Name of the dimension as it appears in MDM. + :vartype internal_name: str + :ivar to_be_exported_for_shoebox: A boolean flag indicating whether this dimension should be included for the shoebox export scenario. - :type to_be_exported_for_shoebox: bool + :vartype to_be_exported_for_shoebox: bool """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'internal_name': {'key': 'internalName', 'type': 'str'}, - 'to_be_exported_for_shoebox': {'key': 'toBeExportedForShoebox', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "internal_name": {"key": "internalName", "type": "str"}, + "to_be_exported_for_shoebox": {"key": "toBeExportedForShoebox", "type": "bool"}, } def __init__( @@ -1402,61 +1553,72 @@ def __init__( to_be_exported_for_shoebox: Optional[bool] = None, **kwargs ): - super(MetricDimension, self).__init__(**kwargs) + """ + :keyword name: Name of the dimension. + :paramtype name: str + :keyword display_name: Localized friendly display name of the dimension. + :paramtype display_name: str + :keyword internal_name: Name of the dimension as it appears in MDM. + :paramtype internal_name: str + :keyword to_be_exported_for_shoebox: A boolean flag indicating whether this dimension should be + included for the shoebox export scenario. + :paramtype to_be_exported_for_shoebox: bool + """ + super().__init__(**kwargs) self.name = name self.display_name = display_name self.internal_name = internal_name self.to_be_exported_for_shoebox = to_be_exported_for_shoebox -class MetricSpecification(msrest.serialization.Model): +class MetricSpecification(_serialization.Model): # pylint: disable=too-many-instance-attributes """Specifications of the Metrics for Azure Monitoring. - :param name: Name of the metric. - :type name: str - :param display_name: Localized friendly display name of the metric. - :type display_name: str - :param display_description: Localized friendly description of the metric. - :type display_description: str - :param unit: Unit that makes sense for the metric. - :type unit: str - :param category: Name of the metric category that the metric belongs to. A metric can only + :ivar name: Name of the metric. + :vartype name: str + :ivar display_name: Localized friendly display name of the metric. + :vartype display_name: str + :ivar display_description: Localized friendly description of the metric. + :vartype display_description: str + :ivar unit: Unit that makes sense for the metric. + :vartype unit: str + :ivar category: Name of the metric category that the metric belongs to. A metric can only belong to a single category. - :type category: str - :param aggregation_type: Only provide one value for this field. Valid values: Average, Minimum, + :vartype category: str + :ivar aggregation_type: Only provide one value for this field. Valid values: Average, Minimum, Maximum, Total, Count. - :type aggregation_type: str - :param supported_aggregation_types: Supported aggregation types. - :type supported_aggregation_types: list[str] - :param supported_time_grain_types: Supported time grain types. - :type supported_time_grain_types: list[str] - :param fill_gap_with_zero: Optional. If set to true, then zero will be returned for time + :vartype aggregation_type: str + :ivar supported_aggregation_types: Supported aggregation types. + :vartype supported_aggregation_types: list[str] + :ivar supported_time_grain_types: Supported time grain types. + :vartype supported_time_grain_types: list[str] + :ivar fill_gap_with_zero: Optional. If set to true, then zero will be returned for time duration where no metric is emitted/published. - :type fill_gap_with_zero: bool - :param dimensions: Dimensions of the metric. - :type dimensions: list[~azure.mgmt.avs.models.MetricDimension] - :param enable_regional_mdm_account: Whether or not the service is using regional MDM accounts. - :type enable_regional_mdm_account: str - :param source_mdm_account: The name of the MDM account. - :type source_mdm_account: str - :param source_mdm_namespace: The name of the MDM namespace. - :type source_mdm_namespace: str + :vartype fill_gap_with_zero: bool + :ivar dimensions: Dimensions of the metric. + :vartype dimensions: list[~azure.mgmt.avs.models.MetricDimension] + :ivar enable_regional_mdm_account: Whether or not the service is using regional MDM accounts. + :vartype enable_regional_mdm_account: str + :ivar source_mdm_account: The name of the MDM account. + :vartype source_mdm_account: str + :ivar source_mdm_namespace: The name of the MDM namespace. + :vartype source_mdm_namespace: str """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'category': {'key': 'category', 'type': 'str'}, - 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, - 'supported_aggregation_types': {'key': 'supportedAggregationTypes', 'type': '[str]'}, - 'supported_time_grain_types': {'key': 'supportedTimeGrainTypes', 'type': '[str]'}, - 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'bool'}, - 'dimensions': {'key': 'dimensions', 'type': '[MetricDimension]'}, - 'enable_regional_mdm_account': {'key': 'enableRegionalMdmAccount', 'type': 'str'}, - 'source_mdm_account': {'key': 'sourceMdmAccount', 'type': 'str'}, - 'source_mdm_namespace': {'key': 'sourceMdmNamespace', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "display_description": {"key": "displayDescription", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "category": {"key": "category", "type": "str"}, + "aggregation_type": {"key": "aggregationType", "type": "str"}, + "supported_aggregation_types": {"key": "supportedAggregationTypes", "type": "[str]"}, + "supported_time_grain_types": {"key": "supportedTimeGrainTypes", "type": "[str]"}, + "fill_gap_with_zero": {"key": "fillGapWithZero", "type": "bool"}, + "dimensions": {"key": "dimensions", "type": "[MetricDimension]"}, + "enable_regional_mdm_account": {"key": "enableRegionalMdmAccount", "type": "str"}, + "source_mdm_account": {"key": "sourceMdmAccount", "type": "str"}, + "source_mdm_namespace": {"key": "sourceMdmNamespace", "type": "str"}, } def __init__( @@ -1471,13 +1633,45 @@ def __init__( supported_aggregation_types: Optional[List[str]] = None, supported_time_grain_types: Optional[List[str]] = None, fill_gap_with_zero: Optional[bool] = None, - dimensions: Optional[List["MetricDimension"]] = None, + dimensions: Optional[List["_models.MetricDimension"]] = None, enable_regional_mdm_account: Optional[str] = None, source_mdm_account: Optional[str] = None, source_mdm_namespace: Optional[str] = None, **kwargs ): - super(MetricSpecification, self).__init__(**kwargs) + """ + :keyword name: Name of the metric. + :paramtype name: str + :keyword display_name: Localized friendly display name of the metric. + :paramtype display_name: str + :keyword display_description: Localized friendly description of the metric. + :paramtype display_description: str + :keyword unit: Unit that makes sense for the metric. + :paramtype unit: str + :keyword category: Name of the metric category that the metric belongs to. A metric can only + belong to a single category. + :paramtype category: str + :keyword aggregation_type: Only provide one value for this field. Valid values: Average, + Minimum, Maximum, Total, Count. + :paramtype aggregation_type: str + :keyword supported_aggregation_types: Supported aggregation types. + :paramtype supported_aggregation_types: list[str] + :keyword supported_time_grain_types: Supported time grain types. + :paramtype supported_time_grain_types: list[str] + :keyword fill_gap_with_zero: Optional. If set to true, then zero will be returned for time + duration where no metric is emitted/published. + :paramtype fill_gap_with_zero: bool + :keyword dimensions: Dimensions of the metric. + :paramtype dimensions: list[~azure.mgmt.avs.models.MetricDimension] + :keyword enable_regional_mdm_account: Whether or not the service is using regional MDM + accounts. + :paramtype enable_regional_mdm_account: str + :keyword source_mdm_account: The name of the MDM account. + :paramtype source_mdm_account: str + :keyword source_mdm_namespace: The name of the MDM namespace. + :paramtype source_mdm_namespace: str + """ + super().__init__(**kwargs) self.name = name self.display_name = display_name self.display_description = display_description @@ -1493,34 +1687,33 @@ def __init__( self.source_mdm_namespace = source_mdm_namespace -class NetAppVolume(msrest.serialization.Model): +class NetAppVolume(_serialization.Model): """An Azure NetApp Files volume from Microsoft.NetApp provider. All required parameters must be populated in order to send to Azure. - :param id: Required. Azure resource ID of the NetApp volume. - :type id: str + :ivar id: Azure resource ID of the NetApp volume. Required. + :vartype id: str """ _validation = { - 'id': {'required': True}, + "id": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: str, - **kwargs - ): - super(NetAppVolume, self).__init__(**kwargs) + def __init__(self, *, id: str, **kwargs): # pylint: disable=redefined-builtin + """ + :keyword id: Azure resource ID of the NetApp volume. Required. + :paramtype id: str + """ + super().__init__(**kwargs) self.id = id -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """A REST API operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1529,26 +1722,26 @@ class Operation(msrest.serialization.Model): :vartype name: str :ivar display: Contains the localized display information for this operation. :vartype display: ~azure.mgmt.avs.models.OperationDisplay - :param is_data_action: Gets or sets a value indicating whether the operation is a data action - or not. - :type is_data_action: bool - :param origin: Origin of the operation. - :type origin: str - :param properties: Properties of the operation. - :type properties: ~azure.mgmt.avs.models.OperationProperties + :ivar is_data_action: Gets or sets a value indicating whether the operation is a data action or + not. + :vartype is_data_action: bool + :ivar origin: Origin of the operation. + :vartype origin: str + :ivar properties: Properties of the operation. + :vartype properties: ~azure.mgmt.avs.models.OperationProperties """ _validation = { - 'name': {'readonly': True}, - 'display': {'readonly': True}, + "name": {"readonly": True}, + "display": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'OperationProperties'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "origin": {"key": "origin", "type": "str"}, + "properties": {"key": "properties", "type": "OperationProperties"}, } def __init__( @@ -1556,10 +1749,19 @@ def __init__( *, is_data_action: Optional[bool] = None, origin: Optional[str] = None, - properties: Optional["OperationProperties"] = None, + properties: Optional["_models.OperationProperties"] = None, **kwargs ): - super(Operation, self).__init__(**kwargs) + """ + :keyword is_data_action: Gets or sets a value indicating whether the operation is a data action + or not. + :paramtype is_data_action: bool + :keyword origin: Origin of the operation. + :paramtype origin: str + :keyword properties: Properties of the operation. + :paramtype properties: ~azure.mgmt.avs.models.OperationProperties + """ + super().__init__(**kwargs) self.name = None self.display = None self.is_data_action = is_data_action @@ -1567,7 +1769,7 @@ def __init__( self.properties = properties -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """Contains the localized display information for this operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1583,31 +1785,29 @@ class OperationDisplay(msrest.serialization.Model): """ _validation = { - 'provider': {'readonly': True}, - 'resource': {'readonly': True}, - 'operation': {'readonly': True}, - 'description': {'readonly': True}, + "provider": {"readonly": True}, + "resource": {"readonly": True}, + "operation": {"readonly": True}, + "description": {"readonly": True}, } _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 - ): - super(OperationDisplay, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provider = None self.resource = None self.operation = None self.description = None -class OperationList(msrest.serialization.Model): +class OperationList(_serialization.Model): """Pageable list of operations. Variables are only populated by the server, and will be ignored when sending a request. @@ -1619,46 +1819,43 @@ class OperationList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(OperationList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class OperationProperties(msrest.serialization.Model): +class OperationProperties(_serialization.Model): """Extra Operation properties. - :param service_specification: Service specifications of the operation. - :type service_specification: ~azure.mgmt.avs.models.ServiceSpecification + :ivar service_specification: Service specifications of the operation. + :vartype service_specification: ~azure.mgmt.avs.models.ServiceSpecification """ _attribute_map = { - 'service_specification': {'key': 'serviceSpecification', 'type': 'ServiceSpecification'}, + "service_specification": {"key": "serviceSpecification", "type": "ServiceSpecification"}, } - def __init__( - self, - *, - service_specification: Optional["ServiceSpecification"] = None, - **kwargs - ): - super(OperationProperties, self).__init__(**kwargs) + def __init__(self, *, service_specification: Optional["_models.ServiceSpecification"] = None, **kwargs): + """ + :keyword service_specification: Service specifications of the operation. + :paramtype service_specification: ~azure.mgmt.avs.models.ServiceSpecification + """ + super().__init__(**kwargs) self.service_specification = service_specification -class PlacementPoliciesList(msrest.serialization.Model): +class PlacementPoliciesList(_serialization.Model): """Represents list of placement policies. Variables are only populated by the server, and will be ignored when sending a request. @@ -1670,20 +1867,18 @@ class PlacementPoliciesList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[PlacementPolicy]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PlacementPolicy]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(PlacementPoliciesList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None @@ -1699,116 +1894,146 @@ class PlacementPolicy(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param properties: placement policy properties. - :type properties: ~azure.mgmt.avs.models.PlacementPolicyProperties + :ivar properties: placement policy properties. + :vartype properties: ~azure.mgmt.avs.models.PlacementPolicyProperties """ _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'}, - 'properties': {'key': 'properties', 'type': 'PlacementPolicyProperties'}, - } - - def __init__( - self, - *, - properties: Optional["PlacementPolicyProperties"] = None, - **kwargs - ): - super(PlacementPolicy, self).__init__(**kwargs) + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "PlacementPolicyProperties"}, + } + + def __init__(self, *, properties: Optional["_models.PlacementPolicyProperties"] = None, **kwargs): + """ + :keyword properties: placement policy properties. + :paramtype properties: ~azure.mgmt.avs.models.PlacementPolicyProperties + """ + super().__init__(**kwargs) self.properties = properties -class PlacementPolicyProperties(msrest.serialization.Model): +class PlacementPolicyProperties(_serialization.Model): """Abstract placement policy properties. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: VmHostPlacementPolicyProperties, VmPlacementPolicyProperties. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + VmHostPlacementPolicyProperties, VmPlacementPolicyProperties 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 type: Required. placement policy type.Constant filled by server. Possible values - include: "VmVm", "VmHost". - :type type: str or ~azure.mgmt.avs.models.PlacementPolicyType - :param state: Whether the placement policy is enabled or disabled. Possible values include: - "Enabled", "Disabled". - :type state: str or ~azure.mgmt.avs.models.PlacementPolicyState - :param display_name: Display name of the placement policy. - :type display_name: str - :ivar provisioning_state: The provisioning state. Possible values include: "Succeeded", - "Failed", "Building", "Deleting", "Updating". + :ivar type: placement policy type. Required. Known values are: "VmVm" and "VmHost". + :vartype type: str or ~azure.mgmt.avs.models.PlacementPolicyType + :ivar state: Whether the placement policy is enabled or disabled. Known values are: "Enabled" + and "Disabled". + :vartype state: str or ~azure.mgmt.avs.models.PlacementPolicyState + :ivar display_name: Display name of the placement policy. + :vartype display_name: str + :ivar provisioning_state: The provisioning state. Known values are: "Succeeded", "Failed", + "Building", "Deleting", "Updating", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.avs.models.PlacementPolicyProvisioningState """ _validation = { - 'type': {'required': True}, - 'provisioning_state': {'readonly': True}, + "type": {"required": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "state": {"key": "state", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, } - _subtype_map = { - 'type': {'VmHost': 'VmHostPlacementPolicyProperties', 'VmVm': 'VmPlacementPolicyProperties'} - } + _subtype_map = {"type": {"VmHost": "VmHostPlacementPolicyProperties", "VmVm": "VmPlacementPolicyProperties"}} def __init__( self, *, - state: Optional[Union[str, "PlacementPolicyState"]] = None, + state: Optional[Union[str, "_models.PlacementPolicyState"]] = None, display_name: Optional[str] = None, **kwargs ): - super(PlacementPolicyProperties, self).__init__(**kwargs) + """ + :keyword state: Whether the placement policy is enabled or disabled. Known values are: + "Enabled" and "Disabled". + :paramtype state: str or ~azure.mgmt.avs.models.PlacementPolicyState + :keyword display_name: Display name of the placement policy. + :paramtype display_name: str + """ + super().__init__(**kwargs) self.type = None # type: Optional[str] self.state = state self.display_name = display_name self.provisioning_state = None -class PlacementPolicyUpdate(msrest.serialization.Model): +class PlacementPolicyUpdate(_serialization.Model): """An update of a DRS placement policy resource. - :param state: Whether the placement policy is enabled or disabled. Possible values include: - "Enabled", "Disabled". - :type state: str or ~azure.mgmt.avs.models.PlacementPolicyState - :param vm_members: Virtual machine members list. - :type vm_members: list[str] - :param host_members: Host members list. - :type host_members: list[str] + :ivar state: Whether the placement policy is enabled or disabled. Known values are: "Enabled" + and "Disabled". + :vartype state: str or ~azure.mgmt.avs.models.PlacementPolicyState + :ivar vm_members: Virtual machine members list. + :vartype vm_members: list[str] + :ivar host_members: Host members list. + :vartype host_members: list[str] + :ivar affinity_strength: vm-host placement policy affinity strength (should/must). Known values + are: "Should" and "Must". + :vartype affinity_strength: str or ~azure.mgmt.avs.models.AffinityStrength + :ivar azure_hybrid_benefit_type: placement policy azure hybrid benefit opt-in type. Known + values are: "SqlHost" and "None". + :vartype azure_hybrid_benefit_type: str or ~azure.mgmt.avs.models.AzureHybridBenefitType """ _attribute_map = { - 'state': {'key': 'properties.state', 'type': 'str'}, - 'vm_members': {'key': 'properties.vmMembers', 'type': '[str]'}, - 'host_members': {'key': 'properties.hostMembers', 'type': '[str]'}, + "state": {"key": "properties.state", "type": "str"}, + "vm_members": {"key": "properties.vmMembers", "type": "[str]"}, + "host_members": {"key": "properties.hostMembers", "type": "[str]"}, + "affinity_strength": {"key": "properties.affinityStrength", "type": "str"}, + "azure_hybrid_benefit_type": {"key": "properties.azureHybridBenefitType", "type": "str"}, } def __init__( self, *, - state: Optional[Union[str, "PlacementPolicyState"]] = None, + state: Optional[Union[str, "_models.PlacementPolicyState"]] = None, vm_members: Optional[List[str]] = None, host_members: Optional[List[str]] = None, + affinity_strength: Optional[Union[str, "_models.AffinityStrength"]] = None, + azure_hybrid_benefit_type: Optional[Union[str, "_models.AzureHybridBenefitType"]] = None, **kwargs ): - super(PlacementPolicyUpdate, self).__init__(**kwargs) + """ + :keyword state: Whether the placement policy is enabled or disabled. Known values are: + "Enabled" and "Disabled". + :paramtype state: str or ~azure.mgmt.avs.models.PlacementPolicyState + :keyword vm_members: Virtual machine members list. + :paramtype vm_members: list[str] + :keyword host_members: Host members list. + :paramtype host_members: list[str] + :keyword affinity_strength: vm-host placement policy affinity strength (should/must). Known + values are: "Should" and "Must". + :paramtype affinity_strength: str or ~azure.mgmt.avs.models.AffinityStrength + :keyword azure_hybrid_benefit_type: placement policy azure hybrid benefit opt-in type. Known + values are: "SqlHost" and "None". + :paramtype azure_hybrid_benefit_type: str or ~azure.mgmt.avs.models.AzureHybridBenefitType + """ + super().__init__(**kwargs) self.state = state self.vm_members = vm_members self.host_members = host_members + self.affinity_strength = affinity_strength + self.azure_hybrid_benefit_type = azure_hybrid_benefit_type class TrackedResource(Resource): @@ -1822,39 +2047,39 @@ class TrackedResource(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar location: Resource location. + :vartype location: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] """ _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'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - *, - location: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): - super(TrackedResource, self).__init__(**kwargs) + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + } + + def __init__(self, *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs): + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) self.location = location self.tags = tags -class PrivateCloud(TrackedResource): +class PrivateCloud(TrackedResource): # pylint: disable=too-many-instance-attributes """A private cloud resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1867,37 +2092,37 @@ class PrivateCloud(TrackedResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param location: Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param sku: Required. The private cloud SKU. - :type sku: ~azure.mgmt.avs.models.Sku - :param identity: The identity of the private cloud, if configured. - :type identity: ~azure.mgmt.avs.models.PrivateCloudIdentity - :param management_cluster: The default cluster used for management. - :type management_cluster: ~azure.mgmt.avs.models.ManagementCluster - :param internet: Connectivity to internet is enabled or disabled. Possible values include: - "Enabled", "Disabled". Default value: "Disabled". - :type internet: str or ~azure.mgmt.avs.models.InternetEnum - :param identity_sources: vCenter Single Sign On Identity Sources. - :type identity_sources: list[~azure.mgmt.avs.models.IdentitySource] - :param availability: Properties describing how the cloud is distributed across availability + :ivar location: Resource location. + :vartype location: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar sku: The private cloud SKU. Required. + :vartype sku: ~azure.mgmt.avs.models.Sku + :ivar identity: The identity of the private cloud, if configured. + :vartype identity: ~azure.mgmt.avs.models.PrivateCloudIdentity + :ivar management_cluster: The default cluster used for management. + :vartype management_cluster: ~azure.mgmt.avs.models.ManagementCluster + :ivar internet: Connectivity to internet is enabled or disabled. Known values are: "Enabled" + and "Disabled". + :vartype internet: str or ~azure.mgmt.avs.models.InternetEnum + :ivar identity_sources: vCenter Single Sign On Identity Sources. + :vartype identity_sources: list[~azure.mgmt.avs.models.IdentitySource] + :ivar availability: Properties describing how the cloud is distributed across availability zones. - :type availability: ~azure.mgmt.avs.models.AvailabilityProperties - :param encryption: Customer managed key encryption, can be enabled or disabled. - :type encryption: ~azure.mgmt.avs.models.Encryption - :ivar provisioning_state: The provisioning state. Possible values include: "Succeeded", - "Failed", "Cancelled", "Pending", "Building", "Deleting", "Updating". + :vartype availability: ~azure.mgmt.avs.models.AvailabilityProperties + :ivar encryption: Customer managed key encryption, can be enabled or disabled. + :vartype encryption: ~azure.mgmt.avs.models.Encryption + :ivar provisioning_state: The provisioning state. Known values are: "Succeeded", "Failed", + "Cancelled", "Pending", "Building", "Deleting", "Updating", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.avs.models.PrivateCloudProvisioningState - :param circuit: An ExpressRoute Circuit. - :type circuit: ~azure.mgmt.avs.models.Circuit + :ivar circuit: An ExpressRoute Circuit. + :vartype circuit: ~azure.mgmt.avs.models.Circuit :ivar endpoints: The endpoints. :vartype endpoints: ~azure.mgmt.avs.models.Endpoints - :param network_block: The block of addresses should be unique across VNet in your subscription + :ivar network_block: The block of addresses should be unique across VNet in your subscription as well as on-premise. Make sure the CIDR format is conformed to (A.B.C.D/X) where A,B,C,D are between 0 and 255, and X is between 0 and 22. - :type network_block: str + :vartype network_block: str :ivar management_network: Network used to access vCenter Server and NSX-T Manager. :vartype management_network: str :ivar provisioning_network: Used for virtual machine cold migration, cloning, and snapshot @@ -1905,86 +2130,129 @@ class PrivateCloud(TrackedResource): :vartype provisioning_network: str :ivar vmotion_network: Used for live migration of virtual machines. :vartype vmotion_network: str - :param vcenter_password: Optionally, set the vCenter admin password when the private cloud is + :ivar vcenter_password: Optionally, set the vCenter admin password when the private cloud is created. - :type vcenter_password: str - :param nsxt_password: Optionally, set the NSX-T Manager password when the private cloud is + :vartype vcenter_password: str + :ivar nsxt_password: Optionally, set the NSX-T Manager password when the private cloud is created. - :type nsxt_password: str + :vartype nsxt_password: str :ivar vcenter_certificate_thumbprint: Thumbprint of the vCenter Server SSL certificate. :vartype vcenter_certificate_thumbprint: str :ivar nsxt_certificate_thumbprint: Thumbprint of the NSX-T Manager SSL certificate. :vartype nsxt_certificate_thumbprint: str :ivar external_cloud_links: Array of cloud link IDs from other clouds that connect to this one. :vartype external_cloud_links: list[str] - :param secondary_circuit: A secondary expressRoute circuit from a separate AZ. Only present in - a stretched private cloud. - :type secondary_circuit: ~azure.mgmt.avs.models.Circuit + :ivar secondary_circuit: A secondary expressRoute circuit from a separate AZ. Only present in a + stretched private cloud. + :vartype secondary_circuit: ~azure.mgmt.avs.models.Circuit + :ivar nsx_public_ip_quota_raised: Flag to indicate whether the private cloud has the quota for + provisioned NSX Public IP count raised from 64 to 1024. Known values are: "Enabled" and + "Disabled". + :vartype nsx_public_ip_quota_raised: str or ~azure.mgmt.avs.models.NsxPublicIpQuotaRaisedEnum """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'sku': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'endpoints': {'readonly': True}, - 'management_network': {'readonly': True}, - 'provisioning_network': {'readonly': True}, - 'vmotion_network': {'readonly': True}, - 'vcenter_certificate_thumbprint': {'readonly': True}, - 'nsxt_certificate_thumbprint': {'readonly': True}, - 'external_cloud_links': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "sku": {"required": True}, + "provisioning_state": {"readonly": True}, + "endpoints": {"readonly": True}, + "management_network": {"readonly": True}, + "provisioning_network": {"readonly": True}, + "vmotion_network": {"readonly": True}, + "vcenter_certificate_thumbprint": {"readonly": True}, + "nsxt_certificate_thumbprint": {"readonly": True}, + "external_cloud_links": {"readonly": True}, + "nsx_public_ip_quota_raised": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'identity': {'key': 'identity', 'type': 'PrivateCloudIdentity'}, - 'management_cluster': {'key': 'properties.managementCluster', 'type': 'ManagementCluster'}, - 'internet': {'key': 'properties.internet', 'type': 'str'}, - 'identity_sources': {'key': 'properties.identitySources', 'type': '[IdentitySource]'}, - 'availability': {'key': 'properties.availability', 'type': 'AvailabilityProperties'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'circuit': {'key': 'properties.circuit', 'type': 'Circuit'}, - 'endpoints': {'key': 'properties.endpoints', 'type': 'Endpoints'}, - 'network_block': {'key': 'properties.networkBlock', 'type': 'str'}, - 'management_network': {'key': 'properties.managementNetwork', 'type': 'str'}, - 'provisioning_network': {'key': 'properties.provisioningNetwork', 'type': 'str'}, - 'vmotion_network': {'key': 'properties.vmotionNetwork', 'type': 'str'}, - 'vcenter_password': {'key': 'properties.vcenterPassword', 'type': 'str'}, - 'nsxt_password': {'key': 'properties.nsxtPassword', 'type': 'str'}, - 'vcenter_certificate_thumbprint': {'key': 'properties.vcenterCertificateThumbprint', 'type': 'str'}, - 'nsxt_certificate_thumbprint': {'key': 'properties.nsxtCertificateThumbprint', 'type': 'str'}, - 'external_cloud_links': {'key': 'properties.externalCloudLinks', 'type': '[str]'}, - 'secondary_circuit': {'key': 'properties.secondaryCircuit', 'type': 'Circuit'}, - } - - def __init__( + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "sku": {"key": "sku", "type": "Sku"}, + "identity": {"key": "identity", "type": "PrivateCloudIdentity"}, + "management_cluster": {"key": "properties.managementCluster", "type": "ManagementCluster"}, + "internet": {"key": "properties.internet", "type": "str"}, + "identity_sources": {"key": "properties.identitySources", "type": "[IdentitySource]"}, + "availability": {"key": "properties.availability", "type": "AvailabilityProperties"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "circuit": {"key": "properties.circuit", "type": "Circuit"}, + "endpoints": {"key": "properties.endpoints", "type": "Endpoints"}, + "network_block": {"key": "properties.networkBlock", "type": "str"}, + "management_network": {"key": "properties.managementNetwork", "type": "str"}, + "provisioning_network": {"key": "properties.provisioningNetwork", "type": "str"}, + "vmotion_network": {"key": "properties.vmotionNetwork", "type": "str"}, + "vcenter_password": {"key": "properties.vcenterPassword", "type": "str"}, + "nsxt_password": {"key": "properties.nsxtPassword", "type": "str"}, + "vcenter_certificate_thumbprint": {"key": "properties.vcenterCertificateThumbprint", "type": "str"}, + "nsxt_certificate_thumbprint": {"key": "properties.nsxtCertificateThumbprint", "type": "str"}, + "external_cloud_links": {"key": "properties.externalCloudLinks", "type": "[str]"}, + "secondary_circuit": {"key": "properties.secondaryCircuit", "type": "Circuit"}, + "nsx_public_ip_quota_raised": {"key": "properties.nsxPublicIpQuotaRaised", "type": "str"}, + } + + def __init__( # pylint: disable=too-many-locals self, *, - sku: "Sku", + sku: "_models.Sku", location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - identity: Optional["PrivateCloudIdentity"] = None, - management_cluster: Optional["ManagementCluster"] = None, - internet: Optional[Union[str, "InternetEnum"]] = "Disabled", - identity_sources: Optional[List["IdentitySource"]] = None, - availability: Optional["AvailabilityProperties"] = None, - encryption: Optional["Encryption"] = None, - circuit: Optional["Circuit"] = None, + identity: Optional["_models.PrivateCloudIdentity"] = None, + management_cluster: Optional["_models.ManagementCluster"] = None, + internet: Union[str, "_models.InternetEnum"] = "Disabled", + identity_sources: Optional[List["_models.IdentitySource"]] = None, + availability: Optional["_models.AvailabilityProperties"] = None, + encryption: Optional["_models.Encryption"] = None, + circuit: Optional["_models.Circuit"] = None, network_block: Optional[str] = None, vcenter_password: Optional[str] = None, nsxt_password: Optional[str] = None, - secondary_circuit: Optional["Circuit"] = None, + secondary_circuit: Optional["_models.Circuit"] = None, **kwargs ): - super(PrivateCloud, self).__init__(location=location, tags=tags, **kwargs) + """ + :keyword location: Resource location. + :paramtype location: str + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword sku: The private cloud SKU. Required. + :paramtype sku: ~azure.mgmt.avs.models.Sku + :keyword identity: The identity of the private cloud, if configured. + :paramtype identity: ~azure.mgmt.avs.models.PrivateCloudIdentity + :keyword management_cluster: The default cluster used for management. + :paramtype management_cluster: ~azure.mgmt.avs.models.ManagementCluster + :keyword internet: Connectivity to internet is enabled or disabled. Known values are: "Enabled" + and "Disabled". + :paramtype internet: str or ~azure.mgmt.avs.models.InternetEnum + :keyword identity_sources: vCenter Single Sign On Identity Sources. + :paramtype identity_sources: list[~azure.mgmt.avs.models.IdentitySource] + :keyword availability: Properties describing how the cloud is distributed across availability + zones. + :paramtype availability: ~azure.mgmt.avs.models.AvailabilityProperties + :keyword encryption: Customer managed key encryption, can be enabled or disabled. + :paramtype encryption: ~azure.mgmt.avs.models.Encryption + :keyword circuit: An ExpressRoute Circuit. + :paramtype circuit: ~azure.mgmt.avs.models.Circuit + :keyword network_block: The block of addresses should be unique across VNet in your + subscription as well as on-premise. Make sure the CIDR format is conformed to (A.B.C.D/X) where + A,B,C,D are between 0 and 255, and X is between 0 and 22. + :paramtype network_block: str + :keyword vcenter_password: Optionally, set the vCenter admin password when the private cloud is + created. + :paramtype vcenter_password: str + :keyword nsxt_password: Optionally, set the NSX-T Manager password when the private cloud is + created. + :paramtype nsxt_password: str + :keyword secondary_circuit: A secondary expressRoute circuit from a separate AZ. Only present + in a stretched private cloud. + :paramtype secondary_circuit: ~azure.mgmt.avs.models.Circuit + """ + super().__init__(location=location, tags=tags, **kwargs) self.sku = sku self.identity = identity self.management_cluster = management_cluster @@ -2005,9 +2273,10 @@ def __init__( self.nsxt_certificate_thumbprint = None self.external_cloud_links = None self.secondary_circuit = secondary_circuit + self.nsx_public_ip_quota_raised = None -class PrivateCloudIdentity(msrest.serialization.Model): +class PrivateCloudIdentity(_serialization.Model): """Identity for the virtual machine. Variables are only populated by the server, and will be ignored when sending a request. @@ -2018,36 +2287,37 @@ class PrivateCloudIdentity(msrest.serialization.Model): :ivar tenant_id: The tenant ID associated with the private cloud. This property will only be provided for a system assigned identity. :vartype tenant_id: str - :param type: The type of identity used for the private cloud. The type 'SystemAssigned' refers + :ivar type: The type of identity used for the private cloud. The type 'SystemAssigned' refers to an implicitly created identity. The type 'None' will remove any identities from the Private - Cloud. Possible values include: "SystemAssigned", "None". - :type type: str or ~azure.mgmt.avs.models.ResourceIdentityType + Cloud. Known values are: "SystemAssigned" and "None". + :vartype type: str or ~azure.mgmt.avs.models.ResourceIdentityType """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - **kwargs - ): - super(PrivateCloudIdentity, self).__init__(**kwargs) + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, *, type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, **kwargs): + """ + :keyword type: The type of identity used for the private cloud. The type 'SystemAssigned' + refers to an implicitly created identity. The type 'None' will remove any identities from the + Private Cloud. Known values are: "SystemAssigned" and "None". + :paramtype type: str or ~azure.mgmt.avs.models.ResourceIdentityType + """ + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type -class PrivateCloudList(msrest.serialization.Model): +class PrivateCloudList(_serialization.Model): """A paged list of private clouds. Variables are only populated by the server, and will be ignored when sending a request. @@ -2059,60 +2329,72 @@ class PrivateCloudList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateCloud]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PrivateCloud]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(PrivateCloudList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class PrivateCloudUpdateProperties(msrest.serialization.Model): +class PrivateCloudUpdateProperties(_serialization.Model): """The properties of a private cloud resource that may be updated. - :param management_cluster: The default cluster used for management. - :type management_cluster: ~azure.mgmt.avs.models.ManagementCluster - :param internet: Connectivity to internet is enabled or disabled. Possible values include: - "Enabled", "Disabled". Default value: "Disabled". - :type internet: str or ~azure.mgmt.avs.models.InternetEnum - :param identity_sources: vCenter Single Sign On Identity Sources. - :type identity_sources: list[~azure.mgmt.avs.models.IdentitySource] - :param availability: Properties describing how the cloud is distributed across availability + :ivar management_cluster: The default cluster used for management. + :vartype management_cluster: ~azure.mgmt.avs.models.ManagementCluster + :ivar internet: Connectivity to internet is enabled or disabled. Known values are: "Enabled" + and "Disabled". + :vartype internet: str or ~azure.mgmt.avs.models.InternetEnum + :ivar identity_sources: vCenter Single Sign On Identity Sources. + :vartype identity_sources: list[~azure.mgmt.avs.models.IdentitySource] + :ivar availability: Properties describing how the cloud is distributed across availability zones. - :type availability: ~azure.mgmt.avs.models.AvailabilityProperties - :param encryption: Customer managed key encryption, can be enabled or disabled. - :type encryption: ~azure.mgmt.avs.models.Encryption + :vartype availability: ~azure.mgmt.avs.models.AvailabilityProperties + :ivar encryption: Customer managed key encryption, can be enabled or disabled. + :vartype encryption: ~azure.mgmt.avs.models.Encryption """ _attribute_map = { - 'management_cluster': {'key': 'managementCluster', 'type': 'ManagementCluster'}, - 'internet': {'key': 'internet', 'type': 'str'}, - 'identity_sources': {'key': 'identitySources', 'type': '[IdentitySource]'}, - 'availability': {'key': 'availability', 'type': 'AvailabilityProperties'}, - 'encryption': {'key': 'encryption', 'type': 'Encryption'}, + "management_cluster": {"key": "managementCluster", "type": "ManagementCluster"}, + "internet": {"key": "internet", "type": "str"}, + "identity_sources": {"key": "identitySources", "type": "[IdentitySource]"}, + "availability": {"key": "availability", "type": "AvailabilityProperties"}, + "encryption": {"key": "encryption", "type": "Encryption"}, } def __init__( self, *, - management_cluster: Optional["ManagementCluster"] = None, - internet: Optional[Union[str, "InternetEnum"]] = "Disabled", - identity_sources: Optional[List["IdentitySource"]] = None, - availability: Optional["AvailabilityProperties"] = None, - encryption: Optional["Encryption"] = None, + management_cluster: Optional["_models.ManagementCluster"] = None, + internet: Union[str, "_models.InternetEnum"] = "Disabled", + identity_sources: Optional[List["_models.IdentitySource"]] = None, + availability: Optional["_models.AvailabilityProperties"] = None, + encryption: Optional["_models.Encryption"] = None, **kwargs ): - super(PrivateCloudUpdateProperties, self).__init__(**kwargs) + """ + :keyword management_cluster: The default cluster used for management. + :paramtype management_cluster: ~azure.mgmt.avs.models.ManagementCluster + :keyword internet: Connectivity to internet is enabled or disabled. Known values are: "Enabled" + and "Disabled". + :paramtype internet: str or ~azure.mgmt.avs.models.InternetEnum + :keyword identity_sources: vCenter Single Sign On Identity Sources. + :paramtype identity_sources: list[~azure.mgmt.avs.models.IdentitySource] + :keyword availability: Properties describing how the cloud is distributed across availability + zones. + :paramtype availability: ~azure.mgmt.avs.models.AvailabilityProperties + :keyword encryption: Customer managed key encryption, can be enabled or disabled. + :paramtype encryption: ~azure.mgmt.avs.models.Encryption + """ + super().__init__(**kwargs) self.management_cluster = management_cluster self.internet = internet self.identity_sources = identity_sources @@ -2120,36 +2402,36 @@ def __init__( self.encryption = encryption -class PrivateCloudProperties(PrivateCloudUpdateProperties): +class PrivateCloudProperties(PrivateCloudUpdateProperties): # pylint: disable=too-many-instance-attributes """The properties of a private cloud resource. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :param management_cluster: The default cluster used for management. - :type management_cluster: ~azure.mgmt.avs.models.ManagementCluster - :param internet: Connectivity to internet is enabled or disabled. Possible values include: - "Enabled", "Disabled". Default value: "Disabled". - :type internet: str or ~azure.mgmt.avs.models.InternetEnum - :param identity_sources: vCenter Single Sign On Identity Sources. - :type identity_sources: list[~azure.mgmt.avs.models.IdentitySource] - :param availability: Properties describing how the cloud is distributed across availability + :ivar management_cluster: The default cluster used for management. + :vartype management_cluster: ~azure.mgmt.avs.models.ManagementCluster + :ivar internet: Connectivity to internet is enabled or disabled. Known values are: "Enabled" + and "Disabled". + :vartype internet: str or ~azure.mgmt.avs.models.InternetEnum + :ivar identity_sources: vCenter Single Sign On Identity Sources. + :vartype identity_sources: list[~azure.mgmt.avs.models.IdentitySource] + :ivar availability: Properties describing how the cloud is distributed across availability zones. - :type availability: ~azure.mgmt.avs.models.AvailabilityProperties - :param encryption: Customer managed key encryption, can be enabled or disabled. - :type encryption: ~azure.mgmt.avs.models.Encryption - :ivar provisioning_state: The provisioning state. Possible values include: "Succeeded", - "Failed", "Cancelled", "Pending", "Building", "Deleting", "Updating". + :vartype availability: ~azure.mgmt.avs.models.AvailabilityProperties + :ivar encryption: Customer managed key encryption, can be enabled or disabled. + :vartype encryption: ~azure.mgmt.avs.models.Encryption + :ivar provisioning_state: The provisioning state. Known values are: "Succeeded", "Failed", + "Cancelled", "Pending", "Building", "Deleting", "Updating", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.avs.models.PrivateCloudProvisioningState - :param circuit: An ExpressRoute Circuit. - :type circuit: ~azure.mgmt.avs.models.Circuit + :ivar circuit: An ExpressRoute Circuit. + :vartype circuit: ~azure.mgmt.avs.models.Circuit :ivar endpoints: The endpoints. :vartype endpoints: ~azure.mgmt.avs.models.Endpoints - :param network_block: Required. The block of addresses should be unique across VNet in your - subscription as well as on-premise. Make sure the CIDR format is conformed to (A.B.C.D/X) where - A,B,C,D are between 0 and 255, and X is between 0 and 22. - :type network_block: str + :ivar network_block: The block of addresses should be unique across VNet in your subscription + as well as on-premise. Make sure the CIDR format is conformed to (A.B.C.D/X) where A,B,C,D are + between 0 and 255, and X is between 0 and 22. Required. + :vartype network_block: str :ivar management_network: Network used to access vCenter Server and NSX-T Manager. :vartype management_network: str :ivar provisioning_network: Used for virtual machine cold migration, cloning, and snapshot @@ -2157,72 +2439,114 @@ class PrivateCloudProperties(PrivateCloudUpdateProperties): :vartype provisioning_network: str :ivar vmotion_network: Used for live migration of virtual machines. :vartype vmotion_network: str - :param vcenter_password: Optionally, set the vCenter admin password when the private cloud is + :ivar vcenter_password: Optionally, set the vCenter admin password when the private cloud is created. - :type vcenter_password: str - :param nsxt_password: Optionally, set the NSX-T Manager password when the private cloud is + :vartype vcenter_password: str + :ivar nsxt_password: Optionally, set the NSX-T Manager password when the private cloud is created. - :type nsxt_password: str + :vartype nsxt_password: str :ivar vcenter_certificate_thumbprint: Thumbprint of the vCenter Server SSL certificate. :vartype vcenter_certificate_thumbprint: str :ivar nsxt_certificate_thumbprint: Thumbprint of the NSX-T Manager SSL certificate. :vartype nsxt_certificate_thumbprint: str :ivar external_cloud_links: Array of cloud link IDs from other clouds that connect to this one. :vartype external_cloud_links: list[str] - :param secondary_circuit: A secondary expressRoute circuit from a separate AZ. Only present in - a stretched private cloud. - :type secondary_circuit: ~azure.mgmt.avs.models.Circuit + :ivar secondary_circuit: A secondary expressRoute circuit from a separate AZ. Only present in a + stretched private cloud. + :vartype secondary_circuit: ~azure.mgmt.avs.models.Circuit + :ivar nsx_public_ip_quota_raised: Flag to indicate whether the private cloud has the quota for + provisioned NSX Public IP count raised from 64 to 1024. Known values are: "Enabled" and + "Disabled". + :vartype nsx_public_ip_quota_raised: str or ~azure.mgmt.avs.models.NsxPublicIpQuotaRaisedEnum """ _validation = { - 'provisioning_state': {'readonly': True}, - 'endpoints': {'readonly': True}, - 'network_block': {'required': True}, - 'management_network': {'readonly': True}, - 'provisioning_network': {'readonly': True}, - 'vmotion_network': {'readonly': True}, - 'vcenter_certificate_thumbprint': {'readonly': True}, - 'nsxt_certificate_thumbprint': {'readonly': True}, - 'external_cloud_links': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "endpoints": {"readonly": True}, + "network_block": {"required": True}, + "management_network": {"readonly": True}, + "provisioning_network": {"readonly": True}, + "vmotion_network": {"readonly": True}, + "vcenter_certificate_thumbprint": {"readonly": True}, + "nsxt_certificate_thumbprint": {"readonly": True}, + "external_cloud_links": {"readonly": True}, + "nsx_public_ip_quota_raised": {"readonly": True}, } _attribute_map = { - 'management_cluster': {'key': 'managementCluster', 'type': 'ManagementCluster'}, - 'internet': {'key': 'internet', 'type': 'str'}, - 'identity_sources': {'key': 'identitySources', 'type': '[IdentitySource]'}, - 'availability': {'key': 'availability', 'type': 'AvailabilityProperties'}, - 'encryption': {'key': 'encryption', 'type': 'Encryption'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'circuit': {'key': 'circuit', 'type': 'Circuit'}, - 'endpoints': {'key': 'endpoints', 'type': 'Endpoints'}, - 'network_block': {'key': 'networkBlock', 'type': 'str'}, - 'management_network': {'key': 'managementNetwork', 'type': 'str'}, - 'provisioning_network': {'key': 'provisioningNetwork', 'type': 'str'}, - 'vmotion_network': {'key': 'vmotionNetwork', 'type': 'str'}, - 'vcenter_password': {'key': 'vcenterPassword', 'type': 'str'}, - 'nsxt_password': {'key': 'nsxtPassword', 'type': 'str'}, - 'vcenter_certificate_thumbprint': {'key': 'vcenterCertificateThumbprint', 'type': 'str'}, - 'nsxt_certificate_thumbprint': {'key': 'nsxtCertificateThumbprint', 'type': 'str'}, - 'external_cloud_links': {'key': 'externalCloudLinks', 'type': '[str]'}, - 'secondary_circuit': {'key': 'secondaryCircuit', 'type': 'Circuit'}, + "management_cluster": {"key": "managementCluster", "type": "ManagementCluster"}, + "internet": {"key": "internet", "type": "str"}, + "identity_sources": {"key": "identitySources", "type": "[IdentitySource]"}, + "availability": {"key": "availability", "type": "AvailabilityProperties"}, + "encryption": {"key": "encryption", "type": "Encryption"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "circuit": {"key": "circuit", "type": "Circuit"}, + "endpoints": {"key": "endpoints", "type": "Endpoints"}, + "network_block": {"key": "networkBlock", "type": "str"}, + "management_network": {"key": "managementNetwork", "type": "str"}, + "provisioning_network": {"key": "provisioningNetwork", "type": "str"}, + "vmotion_network": {"key": "vmotionNetwork", "type": "str"}, + "vcenter_password": {"key": "vcenterPassword", "type": "str"}, + "nsxt_password": {"key": "nsxtPassword", "type": "str"}, + "vcenter_certificate_thumbprint": {"key": "vcenterCertificateThumbprint", "type": "str"}, + "nsxt_certificate_thumbprint": {"key": "nsxtCertificateThumbprint", "type": "str"}, + "external_cloud_links": {"key": "externalCloudLinks", "type": "[str]"}, + "secondary_circuit": {"key": "secondaryCircuit", "type": "Circuit"}, + "nsx_public_ip_quota_raised": {"key": "nsxPublicIpQuotaRaised", "type": "str"}, } def __init__( self, *, network_block: str, - management_cluster: Optional["ManagementCluster"] = None, - internet: Optional[Union[str, "InternetEnum"]] = "Disabled", - identity_sources: Optional[List["IdentitySource"]] = None, - availability: Optional["AvailabilityProperties"] = None, - encryption: Optional["Encryption"] = None, - circuit: Optional["Circuit"] = None, + management_cluster: Optional["_models.ManagementCluster"] = None, + internet: Union[str, "_models.InternetEnum"] = "Disabled", + identity_sources: Optional[List["_models.IdentitySource"]] = None, + availability: Optional["_models.AvailabilityProperties"] = None, + encryption: Optional["_models.Encryption"] = None, + circuit: Optional["_models.Circuit"] = None, vcenter_password: Optional[str] = None, nsxt_password: Optional[str] = None, - secondary_circuit: Optional["Circuit"] = None, + secondary_circuit: Optional["_models.Circuit"] = None, **kwargs ): - super(PrivateCloudProperties, self).__init__(management_cluster=management_cluster, internet=internet, identity_sources=identity_sources, availability=availability, encryption=encryption, **kwargs) + """ + :keyword management_cluster: The default cluster used for management. + :paramtype management_cluster: ~azure.mgmt.avs.models.ManagementCluster + :keyword internet: Connectivity to internet is enabled or disabled. Known values are: "Enabled" + and "Disabled". + :paramtype internet: str or ~azure.mgmt.avs.models.InternetEnum + :keyword identity_sources: vCenter Single Sign On Identity Sources. + :paramtype identity_sources: list[~azure.mgmt.avs.models.IdentitySource] + :keyword availability: Properties describing how the cloud is distributed across availability + zones. + :paramtype availability: ~azure.mgmt.avs.models.AvailabilityProperties + :keyword encryption: Customer managed key encryption, can be enabled or disabled. + :paramtype encryption: ~azure.mgmt.avs.models.Encryption + :keyword circuit: An ExpressRoute Circuit. + :paramtype circuit: ~azure.mgmt.avs.models.Circuit + :keyword network_block: The block of addresses should be unique across VNet in your + subscription as well as on-premise. Make sure the CIDR format is conformed to (A.B.C.D/X) where + A,B,C,D are between 0 and 255, and X is between 0 and 22. Required. + :paramtype network_block: str + :keyword vcenter_password: Optionally, set the vCenter admin password when the private cloud is + created. + :paramtype vcenter_password: str + :keyword nsxt_password: Optionally, set the NSX-T Manager password when the private cloud is + created. + :paramtype nsxt_password: str + :keyword secondary_circuit: A secondary expressRoute circuit from a separate AZ. Only present + in a stretched private cloud. + :paramtype secondary_circuit: ~azure.mgmt.avs.models.Circuit + """ + super().__init__( + management_cluster=management_cluster, + internet=internet, + identity_sources=identity_sources, + availability=availability, + encryption=encryption, + **kwargs + ) self.provisioning_state = None self.circuit = circuit self.endpoints = None @@ -2236,52 +2560,71 @@ def __init__( self.nsxt_certificate_thumbprint = None self.external_cloud_links = None self.secondary_circuit = secondary_circuit + self.nsx_public_ip_quota_raised = None -class PrivateCloudUpdate(msrest.serialization.Model): +class PrivateCloudUpdate(_serialization.Model): """An update to a private cloud resource. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param identity: The identity of the private cloud, if configured. - :type identity: ~azure.mgmt.avs.models.PrivateCloudIdentity - :param management_cluster: The default cluster used for management. - :type management_cluster: ~azure.mgmt.avs.models.ManagementCluster - :param internet: Connectivity to internet is enabled or disabled. Possible values include: - "Enabled", "Disabled". Default value: "Disabled". - :type internet: str or ~azure.mgmt.avs.models.InternetEnum - :param identity_sources: vCenter Single Sign On Identity Sources. - :type identity_sources: list[~azure.mgmt.avs.models.IdentitySource] - :param availability: Properties describing how the cloud is distributed across availability + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar identity: The identity of the private cloud, if configured. + :vartype identity: ~azure.mgmt.avs.models.PrivateCloudIdentity + :ivar management_cluster: The default cluster used for management. + :vartype management_cluster: ~azure.mgmt.avs.models.ManagementCluster + :ivar internet: Connectivity to internet is enabled or disabled. Known values are: "Enabled" + and "Disabled". + :vartype internet: str or ~azure.mgmt.avs.models.InternetEnum + :ivar identity_sources: vCenter Single Sign On Identity Sources. + :vartype identity_sources: list[~azure.mgmt.avs.models.IdentitySource] + :ivar availability: Properties describing how the cloud is distributed across availability zones. - :type availability: ~azure.mgmt.avs.models.AvailabilityProperties - :param encryption: Customer managed key encryption, can be enabled or disabled. - :type encryption: ~azure.mgmt.avs.models.Encryption + :vartype availability: ~azure.mgmt.avs.models.AvailabilityProperties + :ivar encryption: Customer managed key encryption, can be enabled or disabled. + :vartype encryption: ~azure.mgmt.avs.models.Encryption """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'PrivateCloudIdentity'}, - 'management_cluster': {'key': 'properties.managementCluster', 'type': 'ManagementCluster'}, - 'internet': {'key': 'properties.internet', 'type': 'str'}, - 'identity_sources': {'key': 'properties.identitySources', 'type': '[IdentitySource]'}, - 'availability': {'key': 'properties.availability', 'type': 'AvailabilityProperties'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "PrivateCloudIdentity"}, + "management_cluster": {"key": "properties.managementCluster", "type": "ManagementCluster"}, + "internet": {"key": "properties.internet", "type": "str"}, + "identity_sources": {"key": "properties.identitySources", "type": "[IdentitySource]"}, + "availability": {"key": "properties.availability", "type": "AvailabilityProperties"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, } def __init__( self, *, tags: Optional[Dict[str, str]] = None, - identity: Optional["PrivateCloudIdentity"] = None, - management_cluster: Optional["ManagementCluster"] = None, - internet: Optional[Union[str, "InternetEnum"]] = "Disabled", - identity_sources: Optional[List["IdentitySource"]] = None, - availability: Optional["AvailabilityProperties"] = None, - encryption: Optional["Encryption"] = None, + identity: Optional["_models.PrivateCloudIdentity"] = None, + management_cluster: Optional["_models.ManagementCluster"] = None, + internet: Union[str, "_models.InternetEnum"] = "Disabled", + identity_sources: Optional[List["_models.IdentitySource"]] = None, + availability: Optional["_models.AvailabilityProperties"] = None, + encryption: Optional["_models.Encryption"] = None, **kwargs ): - super(PrivateCloudUpdate, self).__init__(**kwargs) + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword identity: The identity of the private cloud, if configured. + :paramtype identity: ~azure.mgmt.avs.models.PrivateCloudIdentity + :keyword management_cluster: The default cluster used for management. + :paramtype management_cluster: ~azure.mgmt.avs.models.ManagementCluster + :keyword internet: Connectivity to internet is enabled or disabled. Known values are: "Enabled" + and "Disabled". + :paramtype internet: str or ~azure.mgmt.avs.models.InternetEnum + :keyword identity_sources: vCenter Single Sign On Identity Sources. + :paramtype identity_sources: list[~azure.mgmt.avs.models.IdentitySource] + :keyword availability: Properties describing how the cloud is distributed across availability + zones. + :paramtype availability: ~azure.mgmt.avs.models.AvailabilityProperties + :keyword encryption: Customer managed key encryption, can be enabled or disabled. + :paramtype encryption: ~azure.mgmt.avs.models.Encryption + """ + super().__init__(**kwargs) self.tags = tags self.identity = identity self.management_cluster = management_cluster @@ -2305,60 +2648,62 @@ 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 ScriptExecutionParameter(msrest.serialization.Model): +class ScriptExecutionParameter(_serialization.Model): """The arguments passed in to the execution. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: PSCredentialExecutionParameter, ScriptSecureStringExecutionParameter, ScriptStringExecutionParameter. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + PSCredentialExecutionParameter, ScriptSecureStringExecutionParameter, + ScriptStringExecutionParameter All required parameters must be populated in order to send to Azure. - :param name: Required. The parameter name. - :type name: str - :param type: Required. The type of execution parameter.Constant filled by server. Possible - values include: "Value", "SecureValue", "Credential". - :type type: str or ~azure.mgmt.avs.models.ScriptExecutionParameterType + :ivar name: The parameter name. Required. + :vartype name: str + :ivar type: The type of execution parameter. Required. Known values are: "Value", + "SecureValue", and "Credential". + :vartype type: str or ~azure.mgmt.avs.models.ScriptExecutionParameterType """ _validation = { - 'name': {'required': True}, - 'type': {'required': True}, + "name": {"required": True}, + "type": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } _subtype_map = { - 'type': {'Credential': 'PSCredentialExecutionParameter', 'SecureValue': 'ScriptSecureStringExecutionParameter', 'Value': 'ScriptStringExecutionParameter'} - } - - def __init__( - self, - *, - name: str, - **kwargs - ): - super(ScriptExecutionParameter, self).__init__(**kwargs) + "type": { + "Credential": "PSCredentialExecutionParameter", + "SecureValue": "ScriptSecureStringExecutionParameter", + "Value": "ScriptStringExecutionParameter", + } + } + + def __init__(self, *, name: str, **kwargs): + """ + :keyword name: The parameter name. Required. + :paramtype name: str + """ + super().__init__(**kwargs) self.name = name self.type = None # type: Optional[str] @@ -2368,70 +2713,69 @@ class PSCredentialExecutionParameter(ScriptExecutionParameter): All required parameters must be populated in order to send to Azure. - :param name: Required. The parameter name. - :type name: str - :param type: Required. The type of execution parameter.Constant filled by server. Possible - values include: "Value", "SecureValue", "Credential". - :type type: str or ~azure.mgmt.avs.models.ScriptExecutionParameterType - :param username: username for login. - :type username: str - :param password: password for login. - :type password: str + :ivar name: The parameter name. Required. + :vartype name: str + :ivar type: The type of execution parameter. Required. Known values are: "Value", + "SecureValue", and "Credential". + :vartype type: str or ~azure.mgmt.avs.models.ScriptExecutionParameterType + :ivar username: username for login. + :vartype username: str + :ivar password: password for login. + :vartype password: str """ _validation = { - 'name': {'required': True}, - 'type': {'required': True}, + "name": {"required": True}, + "type": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'username': {'key': 'username', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, - } - - def __init__( - self, - *, - name: str, - username: Optional[str] = None, - password: Optional[str] = None, - **kwargs - ): - super(PSCredentialExecutionParameter, self).__init__(name=name, **kwargs) - self.type = 'Credential' # type: str + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, + } + + def __init__(self, *, name: str, username: Optional[str] = None, password: Optional[str] = None, **kwargs): + """ + :keyword name: The parameter name. Required. + :paramtype name: str + :keyword username: username for login. + :paramtype username: str + :keyword password: password for login. + :paramtype password: str + """ + super().__init__(name=name, **kwargs) + self.type = "Credential" # type: str self.username = username self.password = password -class Quota(msrest.serialization.Model): +class Quota(_serialization.Model): """Subscription quotas. Variables are only populated by the server, and will be ignored when sending a request. :ivar hosts_remaining: Remaining hosts quota by sku type. :vartype hosts_remaining: dict[str, int] - :ivar quota_enabled: Host quota is active for current subscription. Possible values include: - "Enabled", "Disabled". + :ivar quota_enabled: Host quota is active for current subscription. Known values are: "Enabled" + and "Disabled". :vartype quota_enabled: str or ~azure.mgmt.avs.models.QuotaEnabled """ _validation = { - 'hosts_remaining': {'readonly': True}, - 'quota_enabled': {'readonly': True}, + "hosts_remaining": {"readonly": True}, + "quota_enabled": {"readonly": True}, } _attribute_map = { - 'hosts_remaining': {'key': 'hostsRemaining', 'type': '{int}'}, - 'quota_enabled': {'key': 'quotaEnabled', 'type': 'str'}, + "hosts_remaining": {"key": "hostsRemaining", "type": "{int}"}, + "quota_enabled": {"key": "quotaEnabled", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(Quota, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.hosts_remaining = None self.quota_enabled = None @@ -2456,34 +2800,32 @@ class ScriptCmdlet(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'description': {'readonly': True}, - 'timeout': {'readonly': True}, - 'parameters': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "description": {"readonly": True}, + "timeout": {"readonly": True}, + "parameters": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'timeout': {'key': 'properties.timeout', 'type': 'str'}, - 'parameters': {'key': 'properties.parameters', 'type': '[ScriptParameter]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "timeout": {"key": "properties.timeout", "type": "str"}, + "parameters": {"key": "properties.parameters", "type": "[ScriptParameter]"}, } - def __init__( - self, - **kwargs - ): - super(ScriptCmdlet, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.description = None self.timeout = None self.parameters = None -class ScriptCmdletsList(msrest.serialization.Model): +class ScriptCmdletsList(_serialization.Model): """Pageable list of scripts/cmdlets. Variables are only populated by the server, and will be ignored when sending a request. @@ -2495,25 +2837,23 @@ class ScriptCmdletsList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ScriptCmdlet]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ScriptCmdlet]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(ScriptCmdletsList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class ScriptExecution(ProxyResource): +class ScriptExecution(ProxyResource): # pylint: disable=too-many-instance-attributes """An instance of a script executed by a user - custom or AVS. Variables are only populated by the server, and will be ignored when sending a request. @@ -2524,35 +2864,35 @@ class ScriptExecution(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param script_cmdlet_id: A reference to the script cmdlet resource if user is running a AVS + :ivar script_cmdlet_id: A reference to the script cmdlet resource if user is running a AVS script. - :type script_cmdlet_id: str - :param parameters: Parameters the script will accept. - :type parameters: list[~azure.mgmt.avs.models.ScriptExecutionParameter] - :param hidden_parameters: Parameters that will be hidden/not visible to ARM, such as passwords + :vartype script_cmdlet_id: str + :ivar parameters: Parameters the script will accept. + :vartype parameters: list[~azure.mgmt.avs.models.ScriptExecutionParameter] + :ivar hidden_parameters: Parameters that will be hidden/not visible to ARM, such as passwords and credentials. - :type hidden_parameters: list[~azure.mgmt.avs.models.ScriptExecutionParameter] - :param failure_reason: Error message if the script was able to run, but if the script itself - had errors or powershell threw an exception. - :type failure_reason: str - :param timeout: Time limit for execution. - :type timeout: str - :param retention: Time to live for the resource. If not provided, will be available for 60 - days. - :type retention: str + :vartype hidden_parameters: list[~azure.mgmt.avs.models.ScriptExecutionParameter] + :ivar failure_reason: Error message if the script was able to run, but if the script itself had + errors or powershell threw an exception. + :vartype failure_reason: str + :ivar timeout: Time limit for execution. + :vartype timeout: str + :ivar retention: Time to live for the resource. If not provided, will be available for 60 days. + :vartype retention: str :ivar submitted_at: Time the script execution was submitted. :vartype submitted_at: ~datetime.datetime :ivar started_at: Time the script execution was started. :vartype started_at: ~datetime.datetime :ivar finished_at: Time the script execution was finished. :vartype finished_at: ~datetime.datetime - :ivar provisioning_state: The state of the script execution resource. Possible values include: - "Pending", "Running", "Succeeded", "Failed", "Cancelling", "Cancelled", "Deleting". + :ivar provisioning_state: The state of the script execution resource. Known values are: + "Pending", "Running", "Succeeded", "Failed", "Cancelling", "Cancelled", "Deleting", and + "Canceled". :vartype provisioning_state: str or ~azure.mgmt.avs.models.ScriptExecutionProvisioningState - :param output: Standard output stream from the powershell execution. - :type output: list[str] - :param named_outputs: User-defined dictionary. - :type named_outputs: dict[str, any] + :ivar output: Standard output stream from the powershell execution. + :vartype output: list[str] + :ivar named_outputs: User-defined dictionary. + :vartype named_outputs: dict[str, JSON] :ivar information: Standard information out stream from the powershell execution. :vartype information: list[str] :ivar warnings: Standard warning out stream from the powershell execution. @@ -2562,53 +2902,75 @@ class ScriptExecution(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'submitted_at': {'readonly': True}, - 'started_at': {'readonly': True}, - 'finished_at': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'information': {'readonly': True}, - 'warnings': {'readonly': True}, - 'errors': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "submitted_at": {"readonly": True}, + "started_at": {"readonly": True}, + "finished_at": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "information": {"readonly": True}, + "warnings": {"readonly": True}, + "errors": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'script_cmdlet_id': {'key': 'properties.scriptCmdletId', 'type': 'str'}, - 'parameters': {'key': 'properties.parameters', 'type': '[ScriptExecutionParameter]'}, - 'hidden_parameters': {'key': 'properties.hiddenParameters', 'type': '[ScriptExecutionParameter]'}, - 'failure_reason': {'key': 'properties.failureReason', 'type': 'str'}, - 'timeout': {'key': 'properties.timeout', 'type': 'str'}, - 'retention': {'key': 'properties.retention', 'type': 'str'}, - 'submitted_at': {'key': 'properties.submittedAt', 'type': 'iso-8601'}, - 'started_at': {'key': 'properties.startedAt', 'type': 'iso-8601'}, - 'finished_at': {'key': 'properties.finishedAt', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'output': {'key': 'properties.output', 'type': '[str]'}, - 'named_outputs': {'key': 'properties.namedOutputs', 'type': '{object}'}, - 'information': {'key': 'properties.information', 'type': '[str]'}, - 'warnings': {'key': 'properties.warnings', 'type': '[str]'}, - 'errors': {'key': 'properties.errors', 'type': '[str]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "script_cmdlet_id": {"key": "properties.scriptCmdletId", "type": "str"}, + "parameters": {"key": "properties.parameters", "type": "[ScriptExecutionParameter]"}, + "hidden_parameters": {"key": "properties.hiddenParameters", "type": "[ScriptExecutionParameter]"}, + "failure_reason": {"key": "properties.failureReason", "type": "str"}, + "timeout": {"key": "properties.timeout", "type": "str"}, + "retention": {"key": "properties.retention", "type": "str"}, + "submitted_at": {"key": "properties.submittedAt", "type": "iso-8601"}, + "started_at": {"key": "properties.startedAt", "type": "iso-8601"}, + "finished_at": {"key": "properties.finishedAt", "type": "iso-8601"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "output": {"key": "properties.output", "type": "[str]"}, + "named_outputs": {"key": "properties.namedOutputs", "type": "{object}"}, + "information": {"key": "properties.information", "type": "[str]"}, + "warnings": {"key": "properties.warnings", "type": "[str]"}, + "errors": {"key": "properties.errors", "type": "[str]"}, } def __init__( self, *, script_cmdlet_id: Optional[str] = None, - parameters: Optional[List["ScriptExecutionParameter"]] = None, - hidden_parameters: Optional[List["ScriptExecutionParameter"]] = None, + parameters: Optional[List["_models.ScriptExecutionParameter"]] = None, + hidden_parameters: Optional[List["_models.ScriptExecutionParameter"]] = None, failure_reason: Optional[str] = None, timeout: Optional[str] = None, retention: Optional[str] = None, output: Optional[List[str]] = None, - named_outputs: Optional[Dict[str, Any]] = None, + named_outputs: Optional[Dict[str, JSON]] = None, **kwargs ): - super(ScriptExecution, self).__init__(**kwargs) + """ + :keyword script_cmdlet_id: A reference to the script cmdlet resource if user is running a AVS + script. + :paramtype script_cmdlet_id: str + :keyword parameters: Parameters the script will accept. + :paramtype parameters: list[~azure.mgmt.avs.models.ScriptExecutionParameter] + :keyword hidden_parameters: Parameters that will be hidden/not visible to ARM, such as + passwords and credentials. + :paramtype hidden_parameters: list[~azure.mgmt.avs.models.ScriptExecutionParameter] + :keyword failure_reason: Error message if the script was able to run, but if the script itself + had errors or powershell threw an exception. + :paramtype failure_reason: str + :keyword timeout: Time limit for execution. + :paramtype timeout: str + :keyword retention: Time to live for the resource. If not provided, will be available for 60 + days. + :paramtype retention: str + :keyword output: Standard output stream from the powershell execution. + :paramtype output: list[str] + :keyword named_outputs: User-defined dictionary. + :paramtype named_outputs: dict[str, JSON] + """ + super().__init__(**kwargs) self.script_cmdlet_id = script_cmdlet_id self.parameters = parameters self.hidden_parameters = hidden_parameters @@ -2626,7 +2988,7 @@ def __init__( self.errors = None -class ScriptExecutionsList(msrest.serialization.Model): +class ScriptExecutionsList(_serialization.Model): """Pageable list of script executions. Variables are only populated by the server, and will be ignored when sending a request. @@ -2638,20 +3000,18 @@ class ScriptExecutionsList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ScriptExecution]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ScriptExecution]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(ScriptExecutionsList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None @@ -2671,34 +3031,42 @@ class ScriptPackage(ProxyResource): :vartype description: str :ivar version: Module version. :vartype version: str + :ivar company: Company that created and supports the package. + :vartype company: str + :ivar uri: Link to support by the package vendor. + :vartype uri: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'description': {'readonly': True}, - 'version': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "description": {"readonly": True}, + "version": {"readonly": True}, + "company": {"readonly": True}, + "uri": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ScriptPackage, self).__init__(**kwargs) + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "company": {"key": "properties.company", "type": "str"}, + "uri": {"key": "properties.uri", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.description = None self.version = None + self.company = None + self.uri = None -class ScriptPackagesList(msrest.serialization.Model): +class ScriptPackagesList(_serialization.Model): """A list of the available script packages. Variables are only populated by the server, and will be ignored when sending a request. @@ -2710,67 +3078,64 @@ class ScriptPackagesList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ScriptPackage]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ScriptPackage]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(ScriptPackagesList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class ScriptParameter(msrest.serialization.Model): +class ScriptParameter(_serialization.Model): """An parameter that the script will accept. Variables are only populated by the server, and will be ignored when sending a request. :ivar type: The type of parameter the script is expecting. psCredential is a - PSCredentialObject. Possible values include: "String", "SecureString", "Credential", "Int", - "Bool", "Float". + PSCredentialObject. Known values are: "String", "SecureString", "Credential", "Int", "Bool", + and "Float". :vartype type: str or ~azure.mgmt.avs.models.ScriptParameterTypes - :param name: The parameter name that the script will expect a parameter value for. - :type name: str + :ivar name: The parameter name that the script will expect a parameter value for. + :vartype name: str :ivar description: User friendly description of the parameter. :vartype description: str :ivar visibility: Should this parameter be visible to arm and passed in the parameters argument - when executing. Possible values include: "Visible", "Hidden". + when executing. Known values are: "Visible" and "Hidden". :vartype visibility: str or ~azure.mgmt.avs.models.VisibilityParameterEnum - :ivar optional: Is this parameter required or optional. Possible values include: "Optional", + :ivar optional: Is this parameter required or optional. Known values are: "Optional" and "Required". :vartype optional: str or ~azure.mgmt.avs.models.OptionalParamEnum """ _validation = { - 'type': {'readonly': True}, - 'description': {'readonly': True}, - 'visibility': {'readonly': True}, - 'optional': {'readonly': True}, + "type": {"readonly": True}, + "description": {"readonly": True}, + "visibility": {"readonly": True}, + "optional": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'visibility': {'key': 'visibility', 'type': 'str'}, - 'optional': {'key': 'optional', 'type': 'str'}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - **kwargs - ): - super(ScriptParameter, self).__init__(**kwargs) + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "visibility": {"key": "visibility", "type": "str"}, + "optional": {"key": "optional", "type": "str"}, + } + + def __init__(self, *, name: Optional[str] = None, **kwargs): + """ + :keyword name: The parameter name that the script will expect a parameter value for. + :paramtype name: str + """ + super().__init__(**kwargs) self.type = None self.name = name self.description = None @@ -2783,35 +3148,35 @@ class ScriptSecureStringExecutionParameter(ScriptExecutionParameter): All required parameters must be populated in order to send to Azure. - :param name: Required. The parameter name. - :type name: str - :param type: Required. The type of execution parameter.Constant filled by server. Possible - values include: "Value", "SecureValue", "Credential". - :type type: str or ~azure.mgmt.avs.models.ScriptExecutionParameterType - :param secure_value: A secure value for the passed parameter, not to be stored in logs. - :type secure_value: str + :ivar name: The parameter name. Required. + :vartype name: str + :ivar type: The type of execution parameter. Required. Known values are: "Value", + "SecureValue", and "Credential". + :vartype type: str or ~azure.mgmt.avs.models.ScriptExecutionParameterType + :ivar secure_value: A secure value for the passed parameter, not to be stored in logs. + :vartype secure_value: str """ _validation = { - 'name': {'required': True}, - 'type': {'required': True}, + "name": {"required": True}, + "type": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'secure_value': {'key': 'secureValue', 'type': 'str'}, - } - - def __init__( - self, - *, - name: str, - secure_value: Optional[str] = None, - **kwargs - ): - super(ScriptSecureStringExecutionParameter, self).__init__(name=name, **kwargs) - self.type = 'SecureValue' # type: str + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "secure_value": {"key": "secureValue", "type": "str"}, + } + + def __init__(self, *, name: str, secure_value: Optional[str] = None, **kwargs): + """ + :keyword name: The parameter name. Required. + :paramtype name: str + :keyword secure_value: A secure value for the passed parameter, not to be stored in logs. + :paramtype secure_value: str + """ + super().__init__(name=name, **kwargs) + self.type = "SecureValue" # type: str self.secure_value = secure_value @@ -2820,97 +3185,102 @@ class ScriptStringExecutionParameter(ScriptExecutionParameter): All required parameters must be populated in order to send to Azure. - :param name: Required. The parameter name. - :type name: str - :param type: Required. The type of execution parameter.Constant filled by server. Possible - values include: "Value", "SecureValue", "Credential". - :type type: str or ~azure.mgmt.avs.models.ScriptExecutionParameterType - :param value: The value for the passed parameter. - :type value: str + :ivar name: The parameter name. Required. + :vartype name: str + :ivar type: The type of execution parameter. Required. Known values are: "Value", + "SecureValue", and "Credential". + :vartype type: str or ~azure.mgmt.avs.models.ScriptExecutionParameterType + :ivar value: The value for the passed parameter. + :vartype value: str """ _validation = { - 'name': {'required': True}, - 'type': {'required': True}, + "name": {"required": True}, + "type": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - } - - def __init__( - self, - *, - name: str, - value: Optional[str] = None, - **kwargs - ): - super(ScriptStringExecutionParameter, self).__init__(name=name, **kwargs) - self.type = 'Value' # type: str + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "value": {"key": "value", "type": "str"}, + } + + def __init__(self, *, name: str, value: Optional[str] = None, **kwargs): + """ + :keyword name: The parameter name. Required. + :paramtype name: str + :keyword value: The value for the passed parameter. + :paramtype value: str + """ + super().__init__(name=name, **kwargs) + self.type = "Value" # type: str self.value = value -class ServiceSpecification(msrest.serialization.Model): +class ServiceSpecification(_serialization.Model): """Service specification payload. - :param log_specifications: Specifications of the Log for Azure Monitoring. - :type log_specifications: list[~azure.mgmt.avs.models.LogSpecification] - :param metric_specifications: Specifications of the Metrics for Azure Monitoring. - :type metric_specifications: list[~azure.mgmt.avs.models.MetricSpecification] + :ivar log_specifications: Specifications of the Log for Azure Monitoring. + :vartype log_specifications: list[~azure.mgmt.avs.models.LogSpecification] + :ivar metric_specifications: Specifications of the Metrics for Azure Monitoring. + :vartype metric_specifications: list[~azure.mgmt.avs.models.MetricSpecification] """ _attribute_map = { - 'log_specifications': {'key': 'logSpecifications', 'type': '[LogSpecification]'}, - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecification]'}, + "log_specifications": {"key": "logSpecifications", "type": "[LogSpecification]"}, + "metric_specifications": {"key": "metricSpecifications", "type": "[MetricSpecification]"}, } def __init__( self, *, - log_specifications: Optional[List["LogSpecification"]] = None, - metric_specifications: Optional[List["MetricSpecification"]] = None, + log_specifications: Optional[List["_models.LogSpecification"]] = None, + metric_specifications: Optional[List["_models.MetricSpecification"]] = None, **kwargs ): - super(ServiceSpecification, self).__init__(**kwargs) + """ + :keyword log_specifications: Specifications of the Log for Azure Monitoring. + :paramtype log_specifications: list[~azure.mgmt.avs.models.LogSpecification] + :keyword metric_specifications: Specifications of the Metrics for Azure Monitoring. + :paramtype metric_specifications: list[~azure.mgmt.avs.models.MetricSpecification] + """ + super().__init__(**kwargs) self.log_specifications = log_specifications self.metric_specifications = metric_specifications -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """The resource model definition representing SKU. All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the SKU. - :type name: str + :ivar name: The name of the SKU. Required. + :vartype name: str """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: str, - **kwargs - ): - super(Sku, self).__init__(**kwargs) + def __init__(self, *, name: str, **kwargs): + """ + :keyword name: The name of the SKU. Required. + :paramtype name: str + """ + super().__init__(**kwargs) self.name = name -class Trial(msrest.serialization.Model): +class Trial(_serialization.Model): """Subscription trial availability. Variables are only populated by the server, and will be ignored when sending a request. - :ivar status: Trial status. Possible values include: "TrialAvailable", "TrialUsed", + :ivar status: Trial status. Known values are: "TrialAvailable", "TrialUsed", and "TrialDisabled". :vartype status: str or ~azure.mgmt.avs.models.TrialStatus :ivar available_hosts: Number of trial hosts available. @@ -2918,20 +3288,18 @@ class Trial(msrest.serialization.Model): """ _validation = { - 'status': {'readonly': True}, - 'available_hosts': {'readonly': True}, + "status": {"readonly": True}, + "available_hosts": {"readonly": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'available_hosts': {'key': 'availableHosts', 'type': 'int'}, + "status": {"key": "status", "type": "str"}, + "available_hosts": {"key": "availableHosts", "type": "int"}, } - def __init__( - self, - **kwargs - ): - super(Trial, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.status = None self.available_hosts = None @@ -2955,64 +3323,64 @@ class VirtualMachine(ProxyResource): folder. :vartype folder_path: str :ivar restrict_movement: Whether VM DRS-driven movement is restricted (enabled) or not - (disabled). Possible values include: "Enabled", "Disabled". + (disabled). Known values are: "Enabled" and "Disabled". :vartype restrict_movement: str or ~azure.mgmt.avs.models.VirtualMachineRestrictMovementState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'display_name': {'readonly': True}, - 'mo_ref_id': {'readonly': True}, - 'folder_path': {'readonly': True}, - 'restrict_movement': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "display_name": {"readonly": True}, + "mo_ref_id": {"readonly": True}, + "folder_path": {"readonly": True}, + "restrict_movement": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'mo_ref_id': {'key': 'properties.moRefId', 'type': 'str'}, - 'folder_path': {'key': 'properties.folderPath', 'type': 'str'}, - 'restrict_movement': {'key': 'properties.restrictMovement', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(VirtualMachine, self).__init__(**kwargs) + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "mo_ref_id": {"key": "properties.moRefId", "type": "str"}, + "folder_path": {"key": "properties.folderPath", "type": "str"}, + "restrict_movement": {"key": "properties.restrictMovement", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.display_name = None self.mo_ref_id = None self.folder_path = None self.restrict_movement = None -class VirtualMachineRestrictMovement(msrest.serialization.Model): +class VirtualMachineRestrictMovement(_serialization.Model): """Set VM DRS-driven movement to restricted (enabled) or not (disabled). - :param restrict_movement: Whether VM DRS-driven movement is restricted (enabled) or not - (disabled). Possible values include: "Enabled", "Disabled". - :type restrict_movement: str or ~azure.mgmt.avs.models.VirtualMachineRestrictMovementState + :ivar restrict_movement: Whether VM DRS-driven movement is restricted (enabled) or not + (disabled). Known values are: "Enabled" and "Disabled". + :vartype restrict_movement: str or ~azure.mgmt.avs.models.VirtualMachineRestrictMovementState """ _attribute_map = { - 'restrict_movement': {'key': 'restrictMovement', 'type': 'str'}, + "restrict_movement": {"key": "restrictMovement", "type": "str"}, } def __init__( - self, - *, - restrict_movement: Optional[Union[str, "VirtualMachineRestrictMovementState"]] = None, - **kwargs + self, *, restrict_movement: Optional[Union[str, "_models.VirtualMachineRestrictMovementState"]] = None, **kwargs ): - super(VirtualMachineRestrictMovement, self).__init__(**kwargs) + """ + :keyword restrict_movement: Whether VM DRS-driven movement is restricted (enabled) or not + (disabled). Known values are: "Enabled" and "Disabled". + :paramtype restrict_movement: str or ~azure.mgmt.avs.models.VirtualMachineRestrictMovementState + """ + super().__init__(**kwargs) self.restrict_movement = restrict_movement -class VirtualMachinesList(msrest.serialization.Model): +class VirtualMachinesList(_serialization.Model): """A list of Virtual Machines. Variables are only populated by the server, and will be ignored when sending a request. @@ -3024,20 +3392,18 @@ class VirtualMachinesList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[VirtualMachine]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[VirtualMachine]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(VirtualMachinesList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None @@ -3049,42 +3415,49 @@ class VmHostPlacementPolicyProperties(PlacementPolicyProperties): All required parameters must be populated in order to send to Azure. - :param type: Required. placement policy type.Constant filled by server. Possible values - include: "VmVm", "VmHost". - :type type: str or ~azure.mgmt.avs.models.PlacementPolicyType - :param state: Whether the placement policy is enabled or disabled. Possible values include: - "Enabled", "Disabled". - :type state: str or ~azure.mgmt.avs.models.PlacementPolicyState - :param display_name: Display name of the placement policy. - :type display_name: str - :ivar provisioning_state: The provisioning state. Possible values include: "Succeeded", - "Failed", "Building", "Deleting", "Updating". + :ivar type: placement policy type. Required. Known values are: "VmVm" and "VmHost". + :vartype type: str or ~azure.mgmt.avs.models.PlacementPolicyType + :ivar state: Whether the placement policy is enabled or disabled. Known values are: "Enabled" + and "Disabled". + :vartype state: str or ~azure.mgmt.avs.models.PlacementPolicyState + :ivar display_name: Display name of the placement policy. + :vartype display_name: str + :ivar provisioning_state: The provisioning state. Known values are: "Succeeded", "Failed", + "Building", "Deleting", "Updating", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.avs.models.PlacementPolicyProvisioningState - :param vm_members: Required. Virtual machine members list. - :type vm_members: list[str] - :param host_members: Required. Host members list. - :type host_members: list[str] - :param affinity_type: Required. placement policy affinity type. Possible values include: - "Affinity", "AntiAffinity". - :type affinity_type: str or ~azure.mgmt.avs.models.AffinityType + :ivar vm_members: Virtual machine members list. Required. + :vartype vm_members: list[str] + :ivar host_members: Host members list. Required. + :vartype host_members: list[str] + :ivar affinity_type: placement policy affinity type. Required. Known values are: "Affinity" and + "AntiAffinity". + :vartype affinity_type: str or ~azure.mgmt.avs.models.AffinityType + :ivar affinity_strength: vm-host placement policy affinity strength (should/must). Known values + are: "Should" and "Must". + :vartype affinity_strength: str or ~azure.mgmt.avs.models.AffinityStrength + :ivar azure_hybrid_benefit_type: placement policy azure hybrid benefit opt-in type. Known + values are: "SqlHost" and "None". + :vartype azure_hybrid_benefit_type: str or ~azure.mgmt.avs.models.AzureHybridBenefitType """ _validation = { - 'type': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'vm_members': {'required': True}, - 'host_members': {'required': True}, - 'affinity_type': {'required': True}, + "type": {"required": True}, + "provisioning_state": {"readonly": True}, + "vm_members": {"required": True}, + "host_members": {"required": True}, + "affinity_type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'vm_members': {'key': 'vmMembers', 'type': '[str]'}, - 'host_members': {'key': 'hostMembers', 'type': '[str]'}, - 'affinity_type': {'key': 'affinityType', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "state": {"key": "state", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "vm_members": {"key": "vmMembers", "type": "[str]"}, + "host_members": {"key": "hostMembers", "type": "[str]"}, + "affinity_type": {"key": "affinityType", "type": "str"}, + "affinity_strength": {"key": "affinityStrength", "type": "str"}, + "azure_hybrid_benefit_type": {"key": "azureHybridBenefitType", "type": "str"}, } def __init__( @@ -3092,16 +3465,40 @@ def __init__( *, vm_members: List[str], host_members: List[str], - affinity_type: Union[str, "AffinityType"], - state: Optional[Union[str, "PlacementPolicyState"]] = None, + affinity_type: Union[str, "_models.AffinityType"], + state: Optional[Union[str, "_models.PlacementPolicyState"]] = None, display_name: Optional[str] = None, + affinity_strength: Optional[Union[str, "_models.AffinityStrength"]] = None, + azure_hybrid_benefit_type: Optional[Union[str, "_models.AzureHybridBenefitType"]] = None, **kwargs ): - super(VmHostPlacementPolicyProperties, self).__init__(state=state, display_name=display_name, **kwargs) - self.type = 'VmHost' # type: str + """ + :keyword state: Whether the placement policy is enabled or disabled. Known values are: + "Enabled" and "Disabled". + :paramtype state: str or ~azure.mgmt.avs.models.PlacementPolicyState + :keyword display_name: Display name of the placement policy. + :paramtype display_name: str + :keyword vm_members: Virtual machine members list. Required. + :paramtype vm_members: list[str] + :keyword host_members: Host members list. Required. + :paramtype host_members: list[str] + :keyword affinity_type: placement policy affinity type. Required. Known values are: "Affinity" + and "AntiAffinity". + :paramtype affinity_type: str or ~azure.mgmt.avs.models.AffinityType + :keyword affinity_strength: vm-host placement policy affinity strength (should/must). Known + values are: "Should" and "Must". + :paramtype affinity_strength: str or ~azure.mgmt.avs.models.AffinityStrength + :keyword azure_hybrid_benefit_type: placement policy azure hybrid benefit opt-in type. Known + values are: "SqlHost" and "None". + :paramtype azure_hybrid_benefit_type: str or ~azure.mgmt.avs.models.AzureHybridBenefitType + """ + super().__init__(state=state, display_name=display_name, **kwargs) + self.type = "VmHost" # type: str self.vm_members = vm_members self.host_members = host_members self.affinity_type = affinity_type + self.affinity_strength = affinity_strength + self.azure_hybrid_benefit_type = azure_hybrid_benefit_type class VmPlacementPolicyProperties(PlacementPolicyProperties): @@ -3111,57 +3508,68 @@ class VmPlacementPolicyProperties(PlacementPolicyProperties): All required parameters must be populated in order to send to Azure. - :param type: Required. placement policy type.Constant filled by server. Possible values - include: "VmVm", "VmHost". - :type type: str or ~azure.mgmt.avs.models.PlacementPolicyType - :param state: Whether the placement policy is enabled or disabled. Possible values include: - "Enabled", "Disabled". - :type state: str or ~azure.mgmt.avs.models.PlacementPolicyState - :param display_name: Display name of the placement policy. - :type display_name: str - :ivar provisioning_state: The provisioning state. Possible values include: "Succeeded", - "Failed", "Building", "Deleting", "Updating". + :ivar type: placement policy type. Required. Known values are: "VmVm" and "VmHost". + :vartype type: str or ~azure.mgmt.avs.models.PlacementPolicyType + :ivar state: Whether the placement policy is enabled or disabled. Known values are: "Enabled" + and "Disabled". + :vartype state: str or ~azure.mgmt.avs.models.PlacementPolicyState + :ivar display_name: Display name of the placement policy. + :vartype display_name: str + :ivar provisioning_state: The provisioning state. Known values are: "Succeeded", "Failed", + "Building", "Deleting", "Updating", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.avs.models.PlacementPolicyProvisioningState - :param vm_members: Required. Virtual machine members list. - :type vm_members: list[str] - :param affinity_type: Required. placement policy affinity type. Possible values include: - "Affinity", "AntiAffinity". - :type affinity_type: str or ~azure.mgmt.avs.models.AffinityType + :ivar vm_members: Virtual machine members list. Required. + :vartype vm_members: list[str] + :ivar affinity_type: placement policy affinity type. Required. Known values are: "Affinity" and + "AntiAffinity". + :vartype affinity_type: str or ~azure.mgmt.avs.models.AffinityType """ _validation = { - 'type': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'vm_members': {'required': True}, - 'affinity_type': {'required': True}, + "type": {"required": True}, + "provisioning_state": {"readonly": True}, + "vm_members": {"required": True}, + "affinity_type": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'vm_members': {'key': 'vmMembers', 'type': '[str]'}, - 'affinity_type': {'key': 'affinityType', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "state": {"key": "state", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "vm_members": {"key": "vmMembers", "type": "[str]"}, + "affinity_type": {"key": "affinityType", "type": "str"}, } def __init__( self, *, vm_members: List[str], - affinity_type: Union[str, "AffinityType"], - state: Optional[Union[str, "PlacementPolicyState"]] = None, + affinity_type: Union[str, "_models.AffinityType"], + state: Optional[Union[str, "_models.PlacementPolicyState"]] = None, display_name: Optional[str] = None, **kwargs ): - super(VmPlacementPolicyProperties, self).__init__(state=state, display_name=display_name, **kwargs) - self.type = 'VmVm' # type: str + """ + :keyword state: Whether the placement policy is enabled or disabled. Known values are: + "Enabled" and "Disabled". + :paramtype state: str or ~azure.mgmt.avs.models.PlacementPolicyState + :keyword display_name: Display name of the placement policy. + :paramtype display_name: str + :keyword vm_members: Virtual machine members list. Required. + :paramtype vm_members: list[str] + :keyword affinity_type: placement policy affinity type. Required. Known values are: "Affinity" + and "AntiAffinity". + :paramtype affinity_type: str or ~azure.mgmt.avs.models.AffinityType + """ + super().__init__(state=state, display_name=display_name, **kwargs) + self.type = "VmVm" # type: str self.vm_members = vm_members self.affinity_type = affinity_type -class WorkloadNetworkDhcp(ProxyResource): - """NSX DHCP. +class WorkloadNetwork(ProxyResource): + """Workload Network. Variables are only populated by the server, and will be ignored when sending a request. @@ -3171,83 +3579,110 @@ class WorkloadNetworkDhcp(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param properties: DHCP properties. - :type properties: ~azure.mgmt.avs.models.WorkloadNetworkDhcpEntity """ _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'}, - 'properties': {'key': 'properties', 'type': 'WorkloadNetworkDhcpEntity'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - properties: Optional["WorkloadNetworkDhcpEntity"] = None, - **kwargs - ): - super(WorkloadNetworkDhcp, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + + +class WorkloadNetworkDhcp(ProxyResource): + """NSX DHCP. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar properties: DHCP properties. + :vartype properties: ~azure.mgmt.avs.models.WorkloadNetworkDhcpEntity + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "WorkloadNetworkDhcpEntity"}, + } + + def __init__(self, *, properties: Optional["_models.WorkloadNetworkDhcpEntity"] = None, **kwargs): + """ + :keyword properties: DHCP properties. + :paramtype properties: ~azure.mgmt.avs.models.WorkloadNetworkDhcpEntity + """ + super().__init__(**kwargs) self.properties = properties -class WorkloadNetworkDhcpEntity(msrest.serialization.Model): +class WorkloadNetworkDhcpEntity(_serialization.Model): """Base class for WorkloadNetworkDhcpServer and WorkloadNetworkDhcpRelay to inherit from. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: WorkloadNetworkDhcpRelay, WorkloadNetworkDhcpServer. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + WorkloadNetworkDhcpRelay, WorkloadNetworkDhcpServer 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 dhcp_type: Required. Type of DHCP: SERVER or RELAY.Constant filled by server. Possible - values include: "SERVER", "RELAY". - :type dhcp_type: str or ~azure.mgmt.avs.models.DhcpTypeEnum - :param display_name: Display name of the DHCP entity. - :type display_name: str + :ivar dhcp_type: Type of DHCP: SERVER or RELAY. Required. Known values are: "SERVER" and + "RELAY". + :vartype dhcp_type: str or ~azure.mgmt.avs.models.DhcpTypeEnum + :ivar display_name: Display name of the DHCP entity. + :vartype display_name: str :ivar segments: NSX Segments consuming DHCP. :vartype segments: list[str] - :ivar provisioning_state: The provisioning state. Possible values include: "Succeeded", - "Failed", "Building", "Deleting", "Updating". + :ivar provisioning_state: The provisioning state. Known values are: "Succeeded", "Failed", + "Building", "Deleting", "Updating", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.avs.models.WorkloadNetworkDhcpProvisioningState - :param revision: NSX revision number. - :type revision: long + :ivar revision: NSX revision number. + :vartype revision: int """ _validation = { - 'dhcp_type': {'required': True}, - 'segments': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "dhcp_type": {"required": True}, + "segments": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'dhcp_type': {'key': 'dhcpType', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'segments': {'key': 'segments', 'type': '[str]'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'revision': {'key': 'revision', 'type': 'long'}, - } - - _subtype_map = { - 'dhcp_type': {'RELAY': 'WorkloadNetworkDhcpRelay', 'SERVER': 'WorkloadNetworkDhcpServer'} - } - - def __init__( - self, - *, - display_name: Optional[str] = None, - revision: Optional[int] = None, - **kwargs - ): - super(WorkloadNetworkDhcpEntity, self).__init__(**kwargs) + "dhcp_type": {"key": "dhcpType", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "segments": {"key": "segments", "type": "[str]"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "revision": {"key": "revision", "type": "int"}, + } + + _subtype_map = {"dhcp_type": {"RELAY": "WorkloadNetworkDhcpRelay", "SERVER": "WorkloadNetworkDhcpServer"}} + + def __init__(self, *, display_name: Optional[str] = None, revision: Optional[int] = None, **kwargs): + """ + :keyword display_name: Display name of the DHCP entity. + :paramtype display_name: str + :keyword revision: NSX revision number. + :paramtype revision: int + """ + super().__init__(**kwargs) self.dhcp_type = None # type: Optional[str] self.display_name = display_name self.segments = None @@ -3255,7 +3690,7 @@ def __init__( self.revision = revision -class WorkloadNetworkDhcpList(msrest.serialization.Model): +class WorkloadNetworkDhcpList(_serialization.Model): """A list of NSX dhcp entities. Variables are only populated by the server, and will be ignored when sending a request. @@ -3267,20 +3702,18 @@ class WorkloadNetworkDhcpList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[WorkloadNetworkDhcp]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[WorkloadNetworkDhcp]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(WorkloadNetworkDhcpList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None @@ -3292,36 +3725,36 @@ class WorkloadNetworkDhcpRelay(WorkloadNetworkDhcpEntity): All required parameters must be populated in order to send to Azure. - :param dhcp_type: Required. Type of DHCP: SERVER or RELAY.Constant filled by server. Possible - values include: "SERVER", "RELAY". - :type dhcp_type: str or ~azure.mgmt.avs.models.DhcpTypeEnum - :param display_name: Display name of the DHCP entity. - :type display_name: str + :ivar dhcp_type: Type of DHCP: SERVER or RELAY. Required. Known values are: "SERVER" and + "RELAY". + :vartype dhcp_type: str or ~azure.mgmt.avs.models.DhcpTypeEnum + :ivar display_name: Display name of the DHCP entity. + :vartype display_name: str :ivar segments: NSX Segments consuming DHCP. :vartype segments: list[str] - :ivar provisioning_state: The provisioning state. Possible values include: "Succeeded", - "Failed", "Building", "Deleting", "Updating". + :ivar provisioning_state: The provisioning state. Known values are: "Succeeded", "Failed", + "Building", "Deleting", "Updating", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.avs.models.WorkloadNetworkDhcpProvisioningState - :param revision: NSX revision number. - :type revision: long - :param server_addresses: DHCP Relay Addresses. Max 3. - :type server_addresses: list[str] + :ivar revision: NSX revision number. + :vartype revision: int + :ivar server_addresses: DHCP Relay Addresses. Max 3. + :vartype server_addresses: list[str] """ _validation = { - 'dhcp_type': {'required': True}, - 'segments': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'server_addresses': {'max_items': 3, 'min_items': 1}, + "dhcp_type": {"required": True}, + "segments": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "server_addresses": {"max_items": 3, "min_items": 1}, } _attribute_map = { - 'dhcp_type': {'key': 'dhcpType', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'segments': {'key': 'segments', 'type': '[str]'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'revision': {'key': 'revision', 'type': 'long'}, - 'server_addresses': {'key': 'serverAddresses', 'type': '[str]'}, + "dhcp_type": {"key": "dhcpType", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "segments": {"key": "segments", "type": "[str]"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "revision": {"key": "revision", "type": "int"}, + "server_addresses": {"key": "serverAddresses", "type": "[str]"}, } def __init__( @@ -3332,8 +3765,16 @@ def __init__( server_addresses: Optional[List[str]] = None, **kwargs ): - super(WorkloadNetworkDhcpRelay, self).__init__(display_name=display_name, revision=revision, **kwargs) - self.dhcp_type = 'RELAY' # type: str + """ + :keyword display_name: Display name of the DHCP entity. + :paramtype display_name: str + :keyword revision: NSX revision number. + :paramtype revision: int + :keyword server_addresses: DHCP Relay Addresses. Max 3. + :paramtype server_addresses: list[str] + """ + super().__init__(display_name=display_name, revision=revision, **kwargs) + self.dhcp_type = "RELAY" # type: str self.server_addresses = server_addresses @@ -3344,38 +3785,38 @@ class WorkloadNetworkDhcpServer(WorkloadNetworkDhcpEntity): All required parameters must be populated in order to send to Azure. - :param dhcp_type: Required. Type of DHCP: SERVER or RELAY.Constant filled by server. Possible - values include: "SERVER", "RELAY". - :type dhcp_type: str or ~azure.mgmt.avs.models.DhcpTypeEnum - :param display_name: Display name of the DHCP entity. - :type display_name: str + :ivar dhcp_type: Type of DHCP: SERVER or RELAY. Required. Known values are: "SERVER" and + "RELAY". + :vartype dhcp_type: str or ~azure.mgmt.avs.models.DhcpTypeEnum + :ivar display_name: Display name of the DHCP entity. + :vartype display_name: str :ivar segments: NSX Segments consuming DHCP. :vartype segments: list[str] - :ivar provisioning_state: The provisioning state. Possible values include: "Succeeded", - "Failed", "Building", "Deleting", "Updating". + :ivar provisioning_state: The provisioning state. Known values are: "Succeeded", "Failed", + "Building", "Deleting", "Updating", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.avs.models.WorkloadNetworkDhcpProvisioningState - :param revision: NSX revision number. - :type revision: long - :param server_address: DHCP Server Address. - :type server_address: str - :param lease_time: DHCP Server Lease Time. - :type lease_time: long + :ivar revision: NSX revision number. + :vartype revision: int + :ivar server_address: DHCP Server Address. + :vartype server_address: str + :ivar lease_time: DHCP Server Lease Time. + :vartype lease_time: int """ _validation = { - 'dhcp_type': {'required': True}, - 'segments': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "dhcp_type": {"required": True}, + "segments": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'dhcp_type': {'key': 'dhcpType', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'segments': {'key': 'segments', 'type': '[str]'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'revision': {'key': 'revision', 'type': 'long'}, - 'server_address': {'key': 'serverAddress', 'type': 'str'}, - 'lease_time': {'key': 'leaseTime', 'type': 'long'}, + "dhcp_type": {"key": "dhcpType", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "segments": {"key": "segments", "type": "[str]"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "revision": {"key": "revision", "type": "int"}, + "server_address": {"key": "serverAddress", "type": "str"}, + "lease_time": {"key": "leaseTime", "type": "int"}, } def __init__( @@ -3387,13 +3828,23 @@ def __init__( lease_time: Optional[int] = None, **kwargs ): - super(WorkloadNetworkDhcpServer, self).__init__(display_name=display_name, revision=revision, **kwargs) - self.dhcp_type = 'SERVER' # type: str + """ + :keyword display_name: Display name of the DHCP entity. + :paramtype display_name: str + :keyword revision: NSX revision number. + :paramtype revision: int + :keyword server_address: DHCP Server Address. + :paramtype server_address: str + :keyword lease_time: DHCP Server Lease Time. + :paramtype lease_time: int + """ + super().__init__(display_name=display_name, revision=revision, **kwargs) + self.dhcp_type = "SERVER" # type: str self.server_address = server_address self.lease_time = lease_time -class WorkloadNetworkDnsService(ProxyResource): +class WorkloadNetworkDnsService(ProxyResource): # pylint: disable=too-many-instance-attributes """NSX DNS Service. Variables are only populated by the server, and will be ignored when sending a request. @@ -3404,47 +3855,47 @@ class WorkloadNetworkDnsService(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param display_name: Display name of the DNS Service. - :type display_name: str - :param dns_service_ip: DNS service IP of the DNS Service. - :type dns_service_ip: str - :param default_dns_zone: Default DNS zone of the DNS Service. - :type default_dns_zone: str - :param fqdn_zones: FQDN zones of the DNS Service. - :type fqdn_zones: list[str] - :param log_level: DNS Service log level. Possible values include: "DEBUG", "INFO", "WARNING", - "ERROR", "FATAL". - :type log_level: str or ~azure.mgmt.avs.models.DnsServiceLogLevelEnum - :ivar status: DNS Service status. Possible values include: "SUCCESS", "FAILURE". + :ivar display_name: Display name of the DNS Service. + :vartype display_name: str + :ivar dns_service_ip: DNS service IP of the DNS Service. + :vartype dns_service_ip: str + :ivar default_dns_zone: Default DNS zone of the DNS Service. + :vartype default_dns_zone: str + :ivar fqdn_zones: FQDN zones of the DNS Service. + :vartype fqdn_zones: list[str] + :ivar log_level: DNS Service log level. Known values are: "DEBUG", "INFO", "WARNING", "ERROR", + and "FATAL". + :vartype log_level: str or ~azure.mgmt.avs.models.DnsServiceLogLevelEnum + :ivar status: DNS Service status. Known values are: "SUCCESS" and "FAILURE". :vartype status: str or ~azure.mgmt.avs.models.DnsServiceStatusEnum - :ivar provisioning_state: The provisioning state. Possible values include: "Succeeded", - "Failed", "Building", "Deleting", "Updating". + :ivar provisioning_state: The provisioning state. Known values are: "Succeeded", "Failed", + "Building", "Deleting", "Updating", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.avs.models.WorkloadNetworkDnsServiceProvisioningState - :param revision: NSX revision number. - :type revision: long + :ivar revision: NSX revision number. + :vartype revision: int """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'status': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "status": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'dns_service_ip': {'key': 'properties.dnsServiceIp', 'type': 'str'}, - 'default_dns_zone': {'key': 'properties.defaultDnsZone', 'type': 'str'}, - 'fqdn_zones': {'key': 'properties.fqdnZones', 'type': '[str]'}, - 'log_level': {'key': 'properties.logLevel', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'revision': {'key': 'properties.revision', 'type': 'long'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "dns_service_ip": {"key": "properties.dnsServiceIp", "type": "str"}, + "default_dns_zone": {"key": "properties.defaultDnsZone", "type": "str"}, + "fqdn_zones": {"key": "properties.fqdnZones", "type": "[str]"}, + "log_level": {"key": "properties.logLevel", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "revision": {"key": "properties.revision", "type": "int"}, } def __init__( @@ -3454,11 +3905,26 @@ def __init__( dns_service_ip: Optional[str] = None, default_dns_zone: Optional[str] = None, fqdn_zones: Optional[List[str]] = None, - log_level: Optional[Union[str, "DnsServiceLogLevelEnum"]] = None, + log_level: Optional[Union[str, "_models.DnsServiceLogLevelEnum"]] = None, revision: Optional[int] = None, **kwargs ): - super(WorkloadNetworkDnsService, self).__init__(**kwargs) + """ + :keyword display_name: Display name of the DNS Service. + :paramtype display_name: str + :keyword dns_service_ip: DNS service IP of the DNS Service. + :paramtype dns_service_ip: str + :keyword default_dns_zone: Default DNS zone of the DNS Service. + :paramtype default_dns_zone: str + :keyword fqdn_zones: FQDN zones of the DNS Service. + :paramtype fqdn_zones: list[str] + :keyword log_level: DNS Service log level. Known values are: "DEBUG", "INFO", "WARNING", + "ERROR", and "FATAL". + :paramtype log_level: str or ~azure.mgmt.avs.models.DnsServiceLogLevelEnum + :keyword revision: NSX revision number. + :paramtype revision: int + """ + super().__init__(**kwargs) self.display_name = display_name self.dns_service_ip = dns_service_ip self.default_dns_zone = default_dns_zone @@ -3469,7 +3935,7 @@ def __init__( self.revision = revision -class WorkloadNetworkDnsServicesList(msrest.serialization.Model): +class WorkloadNetworkDnsServicesList(_serialization.Model): """A list of NSX DNS Services. Variables are only populated by the server, and will be ignored when sending a request. @@ -3481,20 +3947,18 @@ class WorkloadNetworkDnsServicesList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[WorkloadNetworkDnsService]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[WorkloadNetworkDnsService]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(WorkloadNetworkDnsServicesList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None @@ -3510,42 +3974,42 @@ class WorkloadNetworkDnsZone(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param display_name: Display name of the DNS Zone. - :type display_name: str - :param domain: Domain names of the DNS Zone. - :type domain: list[str] - :param dns_server_ips: DNS Server IP array of the DNS Zone. - :type dns_server_ips: list[str] - :param source_ip: Source IP of the DNS Zone. - :type source_ip: str - :param dns_services: Number of DNS Services using the DNS zone. - :type dns_services: long - :ivar provisioning_state: The provisioning state. Possible values include: "Succeeded", - "Failed", "Building", "Deleting", "Updating". + :ivar display_name: Display name of the DNS Zone. + :vartype display_name: str + :ivar domain: Domain names of the DNS Zone. + :vartype domain: list[str] + :ivar dns_server_ips: DNS Server IP array of the DNS Zone. + :vartype dns_server_ips: list[str] + :ivar source_ip: Source IP of the DNS Zone. + :vartype source_ip: str + :ivar dns_services: Number of DNS Services using the DNS zone. + :vartype dns_services: int + :ivar provisioning_state: The provisioning state. Known values are: "Succeeded", "Failed", + "Building", "Deleting", "Updating", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.avs.models.WorkloadNetworkDnsZoneProvisioningState - :param revision: NSX revision number. - :type revision: long + :ivar revision: NSX revision number. + :vartype revision: int """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'domain': {'key': 'properties.domain', 'type': '[str]'}, - 'dns_server_ips': {'key': 'properties.dnsServerIps', 'type': '[str]'}, - 'source_ip': {'key': 'properties.sourceIp', 'type': 'str'}, - 'dns_services': {'key': 'properties.dnsServices', 'type': 'long'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'revision': {'key': 'properties.revision', 'type': 'long'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "domain": {"key": "properties.domain", "type": "[str]"}, + "dns_server_ips": {"key": "properties.dnsServerIps", "type": "[str]"}, + "source_ip": {"key": "properties.sourceIp", "type": "str"}, + "dns_services": {"key": "properties.dnsServices", "type": "int"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "revision": {"key": "properties.revision", "type": "int"}, } def __init__( @@ -3559,7 +4023,21 @@ def __init__( revision: Optional[int] = None, **kwargs ): - super(WorkloadNetworkDnsZone, self).__init__(**kwargs) + """ + :keyword display_name: Display name of the DNS Zone. + :paramtype display_name: str + :keyword domain: Domain names of the DNS Zone. + :paramtype domain: list[str] + :keyword dns_server_ips: DNS Server IP array of the DNS Zone. + :paramtype dns_server_ips: list[str] + :keyword source_ip: Source IP of the DNS Zone. + :paramtype source_ip: str + :keyword dns_services: Number of DNS Services using the DNS zone. + :paramtype dns_services: int + :keyword revision: NSX revision number. + :paramtype revision: int + """ + super().__init__(**kwargs) self.display_name = display_name self.domain = domain self.dns_server_ips = dns_server_ips @@ -3569,7 +4047,7 @@ def __init__( self.revision = revision -class WorkloadNetworkDnsZonesList(msrest.serialization.Model): +class WorkloadNetworkDnsZonesList(_serialization.Model): """A list of NSX DNS Zones. Variables are only populated by the server, and will be ignored when sending a request. @@ -3581,20 +4059,18 @@ class WorkloadNetworkDnsZonesList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[WorkloadNetworkDnsZone]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[WorkloadNetworkDnsZone]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(WorkloadNetworkDnsZonesList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None @@ -3610,39 +4086,38 @@ class WorkloadNetworkGateway(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param display_name: Display name of the DHCP entity. - :type display_name: str + :ivar display_name: Display name of the DHCP entity. + :vartype display_name: str :ivar path: NSX Gateway Path. :vartype path: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'path': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "path": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'path': {'key': 'properties.path', 'type': 'str'}, - } - - def __init__( - self, - *, - display_name: Optional[str] = None, - **kwargs - ): - super(WorkloadNetworkGateway, self).__init__(**kwargs) + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "path": {"key": "properties.path", "type": "str"}, + } + + def __init__(self, *, display_name: Optional[str] = None, **kwargs): + """ + :keyword display_name: Display name of the DHCP entity. + :paramtype display_name: str + """ + super().__init__(**kwargs) self.display_name = display_name self.path = None -class WorkloadNetworkGatewayList(msrest.serialization.Model): +class WorkloadNetworkGatewayList(_serialization.Model): """A list of NSX Gateways. Variables are only populated by the server, and will be ignored when sending a request. @@ -3654,20 +4129,46 @@ class WorkloadNetworkGatewayList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[WorkloadNetworkGateway]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[WorkloadNetworkGateway]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(WorkloadNetworkGatewayList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class WorkloadNetworkList(_serialization.Model): + """A list of workload networks. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The items on the page. + :vartype value: list[~azure.mgmt.avs.models.WorkloadNetwork] + :ivar next_link: URL to get the next page if any. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[WorkloadNetwork]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None @@ -3683,57 +4184,70 @@ class WorkloadNetworkPortMirroring(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param display_name: Display name of the port mirroring profile. - :type display_name: str - :param direction: Direction of port mirroring profile. Possible values include: "INGRESS", - "EGRESS", "BIDIRECTIONAL". - :type direction: str or ~azure.mgmt.avs.models.PortMirroringDirectionEnum - :param source: Source VM Group. - :type source: str - :param destination: Destination VM Group. - :type destination: str - :ivar status: Port Mirroring Status. Possible values include: "SUCCESS", "FAILURE". + :ivar display_name: Display name of the port mirroring profile. + :vartype display_name: str + :ivar direction: Direction of port mirroring profile. Known values are: "INGRESS", "EGRESS", + and "BIDIRECTIONAL". + :vartype direction: str or ~azure.mgmt.avs.models.PortMirroringDirectionEnum + :ivar source: Source VM Group. + :vartype source: str + :ivar destination: Destination VM Group. + :vartype destination: str + :ivar status: Port Mirroring Status. Known values are: "SUCCESS" and "FAILURE". :vartype status: str or ~azure.mgmt.avs.models.PortMirroringStatusEnum - :ivar provisioning_state: The provisioning state. Possible values include: "Succeeded", - "Failed", "Building", "Deleting", "Updating". + :ivar provisioning_state: The provisioning state. Known values are: "Succeeded", "Failed", + "Building", "Deleting", "Updating", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.avs.models.WorkloadNetworkPortMirroringProvisioningState - :param revision: NSX revision number. - :type revision: long + :ivar revision: NSX revision number. + :vartype revision: int """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'status': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "status": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'direction': {'key': 'properties.direction', 'type': 'str'}, - 'source': {'key': 'properties.source', 'type': 'str'}, - 'destination': {'key': 'properties.destination', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'revision': {'key': 'properties.revision', 'type': 'long'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "direction": {"key": "properties.direction", "type": "str"}, + "source": {"key": "properties.source", "type": "str"}, + "destination": {"key": "properties.destination", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "revision": {"key": "properties.revision", "type": "int"}, } def __init__( self, *, display_name: Optional[str] = None, - direction: Optional[Union[str, "PortMirroringDirectionEnum"]] = None, + direction: Optional[Union[str, "_models.PortMirroringDirectionEnum"]] = None, source: Optional[str] = None, destination: Optional[str] = None, revision: Optional[int] = None, **kwargs ): - super(WorkloadNetworkPortMirroring, self).__init__(**kwargs) + """ + :keyword display_name: Display name of the port mirroring profile. + :paramtype display_name: str + :keyword direction: Direction of port mirroring profile. Known values are: "INGRESS", "EGRESS", + and "BIDIRECTIONAL". + :paramtype direction: str or ~azure.mgmt.avs.models.PortMirroringDirectionEnum + :keyword source: Source VM Group. + :paramtype source: str + :keyword destination: Destination VM Group. + :paramtype destination: str + :keyword revision: NSX revision number. + :paramtype revision: int + """ + super().__init__(**kwargs) self.display_name = display_name self.direction = direction self.source = source @@ -3743,7 +4257,7 @@ def __init__( self.revision = revision -class WorkloadNetworkPortMirroringList(msrest.serialization.Model): +class WorkloadNetworkPortMirroringList(_serialization.Model): """A list of NSX Port Mirroring. Variables are only populated by the server, and will be ignored when sending a request. @@ -3755,20 +4269,18 @@ class WorkloadNetworkPortMirroringList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[WorkloadNetworkPortMirroring]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[WorkloadNetworkPortMirroring]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(WorkloadNetworkPortMirroringList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None @@ -3784,51 +4296,51 @@ class WorkloadNetworkPublicIP(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param display_name: Display name of the Public IP Block. - :type display_name: str - :param number_of_public_i_ps: Number of Public IPs requested. - :type number_of_public_i_ps: long + :ivar display_name: Display name of the Public IP Block. + :vartype display_name: str + :ivar number_of_public_i_ps: Number of Public IPs requested. + :vartype number_of_public_i_ps: int :ivar public_ip_block: CIDR Block of the Public IP Block. :vartype public_ip_block: str - :ivar provisioning_state: The provisioning state. Possible values include: "Succeeded", - "Failed", "Building", "Deleting", "Updating". + :ivar provisioning_state: The provisioning state. Known values are: "Succeeded", "Failed", + "Building", "Deleting", "Updating", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.avs.models.WorkloadNetworkPublicIPProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'public_ip_block': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "public_ip_block": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'number_of_public_i_ps': {'key': 'properties.numberOfPublicIPs', 'type': 'long'}, - 'public_ip_block': {'key': 'properties.publicIPBlock', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - *, - display_name: Optional[str] = None, - number_of_public_i_ps: Optional[int] = None, - **kwargs - ): - super(WorkloadNetworkPublicIP, self).__init__(**kwargs) + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "number_of_public_i_ps": {"key": "properties.numberOfPublicIPs", "type": "int"}, + "public_ip_block": {"key": "properties.publicIPBlock", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + } + + def __init__(self, *, display_name: Optional[str] = None, number_of_public_i_ps: Optional[int] = None, **kwargs): + """ + :keyword display_name: Display name of the Public IP Block. + :paramtype display_name: str + :keyword number_of_public_i_ps: Number of Public IPs requested. + :paramtype number_of_public_i_ps: int + """ + super().__init__(**kwargs) self.display_name = display_name self.number_of_public_i_ps = number_of_public_i_ps self.public_ip_block = None self.provisioning_state = None -class WorkloadNetworkPublicIPsList(msrest.serialization.Model): +class WorkloadNetworkPublicIPsList(_serialization.Model): """A list of NSX Public IP Blocks. Variables are only populated by the server, and will be ignored when sending a request. @@ -3840,20 +4352,18 @@ class WorkloadNetworkPublicIPsList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[WorkloadNetworkPublicIP]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[WorkloadNetworkPublicIP]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(WorkloadNetworkPublicIPsList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None @@ -3869,44 +4379,44 @@ class WorkloadNetworkSegment(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param display_name: Display name of the segment. - :type display_name: str - :param connected_gateway: Gateway which to connect segment to. - :type connected_gateway: str - :param subnet: Subnet which to connect segment to. - :type subnet: ~azure.mgmt.avs.models.WorkloadNetworkSegmentSubnet + :ivar display_name: Display name of the segment. + :vartype display_name: str + :ivar connected_gateway: Gateway which to connect segment to. + :vartype connected_gateway: str + :ivar subnet: Subnet which to connect segment to. + :vartype subnet: ~azure.mgmt.avs.models.WorkloadNetworkSegmentSubnet :ivar port_vif: Port Vif which segment is associated with. :vartype port_vif: list[~azure.mgmt.avs.models.WorkloadNetworkSegmentPortVif] - :ivar status: Segment status. Possible values include: "SUCCESS", "FAILURE". + :ivar status: Segment status. Known values are: "SUCCESS" and "FAILURE". :vartype status: str or ~azure.mgmt.avs.models.SegmentStatusEnum - :ivar provisioning_state: The provisioning state. Possible values include: "Succeeded", - "Failed", "Building", "Deleting", "Updating". + :ivar provisioning_state: The provisioning state. Known values are: "Succeeded", "Failed", + "Building", "Deleting", "Updating", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.avs.models.WorkloadNetworkSegmentProvisioningState - :param revision: NSX revision number. - :type revision: long + :ivar revision: NSX revision number. + :vartype revision: int """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'port_vif': {'readonly': True}, - 'status': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "port_vif": {"readonly": True}, + "status": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'connected_gateway': {'key': 'properties.connectedGateway', 'type': 'str'}, - 'subnet': {'key': 'properties.subnet', 'type': 'WorkloadNetworkSegmentSubnet'}, - 'port_vif': {'key': 'properties.portVif', 'type': '[WorkloadNetworkSegmentPortVif]'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'revision': {'key': 'properties.revision', 'type': 'long'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "connected_gateway": {"key": "properties.connectedGateway", "type": "str"}, + "subnet": {"key": "properties.subnet", "type": "WorkloadNetworkSegmentSubnet"}, + "port_vif": {"key": "properties.portVif", "type": "[WorkloadNetworkSegmentPortVif]"}, + "status": {"key": "properties.status", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "revision": {"key": "properties.revision", "type": "int"}, } def __init__( @@ -3914,11 +4424,21 @@ def __init__( *, display_name: Optional[str] = None, connected_gateway: Optional[str] = None, - subnet: Optional["WorkloadNetworkSegmentSubnet"] = None, + subnet: Optional["_models.WorkloadNetworkSegmentSubnet"] = None, revision: Optional[int] = None, **kwargs ): - super(WorkloadNetworkSegment, self).__init__(**kwargs) + """ + :keyword display_name: Display name of the segment. + :paramtype display_name: str + :keyword connected_gateway: Gateway which to connect segment to. + :paramtype connected_gateway: str + :keyword subnet: Subnet which to connect segment to. + :paramtype subnet: ~azure.mgmt.avs.models.WorkloadNetworkSegmentSubnet + :keyword revision: NSX revision number. + :paramtype revision: int + """ + super().__init__(**kwargs) self.display_name = display_name self.connected_gateway = connected_gateway self.subnet = subnet @@ -3928,28 +4448,27 @@ def __init__( self.revision = revision -class WorkloadNetworkSegmentPortVif(msrest.serialization.Model): +class WorkloadNetworkSegmentPortVif(_serialization.Model): """Ports and any VIF attached to segment. - :param port_name: Name of port or VIF attached to segment. - :type port_name: str + :ivar port_name: Name of port or VIF attached to segment. + :vartype port_name: str """ _attribute_map = { - 'port_name': {'key': 'portName', 'type': 'str'}, + "port_name": {"key": "portName", "type": "str"}, } - def __init__( - self, - *, - port_name: Optional[str] = None, - **kwargs - ): - super(WorkloadNetworkSegmentPortVif, self).__init__(**kwargs) + def __init__(self, *, port_name: Optional[str] = None, **kwargs): + """ + :keyword port_name: Name of port or VIF attached to segment. + :paramtype port_name: str + """ + super().__init__(**kwargs) self.port_name = port_name -class WorkloadNetworkSegmentsList(msrest.serialization.Model): +class WorkloadNetworkSegmentsList(_serialization.Model): """A list of NSX Segments. Variables are only populated by the server, and will be ignored when sending a request. @@ -3961,46 +4480,44 @@ class WorkloadNetworkSegmentsList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[WorkloadNetworkSegment]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[WorkloadNetworkSegment]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(WorkloadNetworkSegmentsList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class WorkloadNetworkSegmentSubnet(msrest.serialization.Model): +class WorkloadNetworkSegmentSubnet(_serialization.Model): """Subnet configuration for segment. - :param dhcp_ranges: DHCP Range assigned for subnet. - :type dhcp_ranges: list[str] - :param gateway_address: Gateway address. - :type gateway_address: str + :ivar dhcp_ranges: DHCP Range assigned for subnet. + :vartype dhcp_ranges: list[str] + :ivar gateway_address: Gateway address. + :vartype gateway_address: str """ _attribute_map = { - 'dhcp_ranges': {'key': 'dhcpRanges', 'type': '[str]'}, - 'gateway_address': {'key': 'gatewayAddress', 'type': 'str'}, - } - - def __init__( - self, - *, - dhcp_ranges: Optional[List[str]] = None, - gateway_address: Optional[str] = None, - **kwargs - ): - super(WorkloadNetworkSegmentSubnet, self).__init__(**kwargs) + "dhcp_ranges": {"key": "dhcpRanges", "type": "[str]"}, + "gateway_address": {"key": "gatewayAddress", "type": "str"}, + } + + def __init__(self, *, dhcp_ranges: Optional[List[str]] = None, gateway_address: Optional[str] = None, **kwargs): + """ + :keyword dhcp_ranges: DHCP Range assigned for subnet. + :paramtype dhcp_ranges: list[str] + :keyword gateway_address: Gateway address. + :paramtype gateway_address: str + """ + super().__init__(**kwargs) self.dhcp_ranges = dhcp_ranges self.gateway_address = gateway_address @@ -4016,39 +4533,38 @@ class WorkloadNetworkVirtualMachine(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param display_name: Display name of the VM. - :type display_name: str - :ivar vm_type: Virtual machine type. Possible values include: "REGULAR", "EDGE", "SERVICE". + :ivar display_name: Display name of the VM. + :vartype display_name: str + :ivar vm_type: Virtual machine type. Known values are: "REGULAR", "EDGE", and "SERVICE". :vartype vm_type: str or ~azure.mgmt.avs.models.VMTypeEnum """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'vm_type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "vm_type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'vm_type': {'key': 'properties.vmType', 'type': 'str'}, - } - - def __init__( - self, - *, - display_name: Optional[str] = None, - **kwargs - ): - super(WorkloadNetworkVirtualMachine, self).__init__(**kwargs) + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "vm_type": {"key": "properties.vmType", "type": "str"}, + } + + def __init__(self, *, display_name: Optional[str] = None, **kwargs): + """ + :keyword display_name: Display name of the VM. + :paramtype display_name: str + """ + super().__init__(**kwargs) self.display_name = display_name self.vm_type = None -class WorkloadNetworkVirtualMachinesList(msrest.serialization.Model): +class WorkloadNetworkVirtualMachinesList(_serialization.Model): """A list of NSX Virtual Machines. Variables are only populated by the server, and will be ignored when sending a request. @@ -4060,20 +4576,18 @@ class WorkloadNetworkVirtualMachinesList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[WorkloadNetworkVirtualMachine]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[WorkloadNetworkVirtualMachine]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(WorkloadNetworkVirtualMachinesList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None @@ -4089,37 +4603,37 @@ class WorkloadNetworkVMGroup(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param display_name: Display name of the VM group. - :type display_name: str - :param members: Virtual machine members of this group. - :type members: list[str] - :ivar status: VM Group status. Possible values include: "SUCCESS", "FAILURE". + :ivar display_name: Display name of the VM group. + :vartype display_name: str + :ivar members: Virtual machine members of this group. + :vartype members: list[str] + :ivar status: VM Group status. Known values are: "SUCCESS" and "FAILURE". :vartype status: str or ~azure.mgmt.avs.models.VMGroupStatusEnum - :ivar provisioning_state: The provisioning state. Possible values include: "Succeeded", - "Failed", "Building", "Deleting", "Updating". + :ivar provisioning_state: The provisioning state. Known values are: "Succeeded", "Failed", + "Building", "Deleting", "Updating", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.avs.models.WorkloadNetworkVMGroupProvisioningState - :param revision: NSX revision number. - :type revision: long + :ivar revision: NSX revision number. + :vartype revision: int """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'status': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "status": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'members': {'key': 'properties.members', 'type': '[str]'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'revision': {'key': 'properties.revision', 'type': 'long'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "members": {"key": "properties.members", "type": "[str]"}, + "status": {"key": "properties.status", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "revision": {"key": "properties.revision", "type": "int"}, } def __init__( @@ -4130,7 +4644,15 @@ def __init__( revision: Optional[int] = None, **kwargs ): - super(WorkloadNetworkVMGroup, self).__init__(**kwargs) + """ + :keyword display_name: Display name of the VM group. + :paramtype display_name: str + :keyword members: Virtual machine members of this group. + :paramtype members: list[str] + :keyword revision: NSX revision number. + :paramtype revision: int + """ + super().__init__(**kwargs) self.display_name = display_name self.members = members self.status = None @@ -4138,7 +4660,7 @@ def __init__( self.revision = revision -class WorkloadNetworkVMGroupsList(msrest.serialization.Model): +class WorkloadNetworkVMGroupsList(_serialization.Model): """A list of NSX VM Groups. Variables are only populated by the server, and will be ignored when sending a request. @@ -4150,19 +4672,17 @@ class WorkloadNetworkVMGroupsList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[WorkloadNetworkVMGroup]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[WorkloadNetworkVMGroup]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(WorkloadNetworkVMGroupsList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None diff --git a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/models/_patch.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/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/compute/azure-mgmt-avs/azure/mgmt/avs/operations/__init__.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/__init__.py index d60908801950..f7d8649d903a 100644 --- a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/__init__.py +++ b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/__init__.py @@ -23,21 +23,27 @@ from ._script_cmdlets_operations import ScriptCmdletsOperations from ._script_executions_operations import ScriptExecutionsOperations +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', - 'LocationsOperations', - 'PrivateCloudsOperations', - 'ClustersOperations', - 'DatastoresOperations', - 'HcxEnterpriseSitesOperations', - 'AuthorizationsOperations', - 'GlobalReachConnectionsOperations', - 'WorkloadNetworksOperations', - 'CloudLinksOperations', - 'AddonsOperations', - 'VirtualMachinesOperations', - 'PlacementPoliciesOperations', - 'ScriptPackagesOperations', - 'ScriptCmdletsOperations', - 'ScriptExecutionsOperations', + "Operations", + "LocationsOperations", + "PrivateCloudsOperations", + "ClustersOperations", + "DatastoresOperations", + "HcxEnterpriseSitesOperations", + "AuthorizationsOperations", + "GlobalReachConnectionsOperations", + "WorkloadNetworksOperations", + "CloudLinksOperations", + "AddonsOperations", + "VirtualMachinesOperations", + "PlacementPoliciesOperations", + "ScriptPackagesOperations", + "ScriptCmdletsOperations", + "ScriptExecutionsOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_addons_operations.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_addons_operations.py index 2611dffafbf3..b68c9827277e 100644 --- a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_addons_operations.py +++ b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_addons_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,103 +6,260 @@ # 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 +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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_list_request( + resource_group_name: str, private_cloud_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/addons", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_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_get_request( + resource_group_name: str, private_cloud_name: str, addon_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/addons/{addonName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "addonName": _SERIALIZER.url("addon_name", addon_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_create_or_update_request( + resource_group_name: str, private_cloud_name: str, addon_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-05-01")) # 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.AVS/privateClouds/{privateCloudName}/addons/{addonName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "addonName": _SERIALIZER.url("addon_name", addon_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) -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]] + # 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_delete_request( + resource_group_name: str, private_cloud_name: str, addon_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/addons/{addonName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "addonName": _SERIALIZER.url("addon_name", addon_name, "str"), + } -class AddonsOperations(object): - """AddonsOperations 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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class AddonsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.avs.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.avs.AVSClient`'s + :attr:`addons` 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 list( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AddonList"] + @distributed_trace + def list(self, resource_group_name: str, private_cloud_name: str, **kwargs: Any) -> Iterable["_models.Addon"]: """List addons in a private cloud. List addons in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AddonList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.avs.models.AddonList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Addon or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.avs.models.Addon] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AddonList"] + _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.AddonList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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('AddonList', pipeline_response) + deserialized = self._deserialize("AddonList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,7 +268,9 @@ 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]: @@ -119,118 +279,125 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/addons'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - addon_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Addon" + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/addons"} # type: ignore + + @distributed_trace + def get(self, resource_group_name: str, private_cloud_name: str, addon_name: str, **kwargs: Any) -> _models.Addon: """Get an addon by name in a private cloud. Get an addon by name in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param addon_name: Name of the addon for the private cloud. + :param addon_name: Name of the addon for the private cloud. Required. :type addon_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Addon, or the result of cls(response) + :return: Addon or the result of cls(response) :rtype: ~azure.mgmt.avs.models.Addon - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Addon"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'addonName': self._serialize.url("addon_name", addon_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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.Addon] + + request = build_get_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + addon_name=addon_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 - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Addon', pipeline_response) + deserialized = self._deserialize("Addon", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/addons/{addonName}'} # type: ignore + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/addons/{addonName}"} # type: ignore def _create_or_update_initial( self, - resource_group_name, # type: str - private_cloud_name, # type: str - addon_name, # type: str - addon, # type: "_models.Addon" - **kwargs # type: Any - ): - # type: (...) -> "_models.Addon" - cls = kwargs.pop('cls', None) # type: ClsType["_models.Addon"] + resource_group_name: str, + private_cloud_name: str, + addon_name: str, + addon: Union[_models.Addon, IO], + **kwargs: Any + ) -> _models.Addon: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'addonName': self._serialize.url("addon_name", addon_name, 'str'), - } - url = self._client.format_url(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(addon, 'Addon') - 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) + 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.Addon] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(addon, (IO, bytes)): + _content = addon + else: + _json = self._serialize.body(addon, "Addon") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + addon_name=addon_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]: @@ -238,132 +405,216 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Addon', pipeline_response) + deserialized = self._deserialize("Addon", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Addon', pipeline_response) + deserialized = self._deserialize("Addon", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/addons/{addonName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/addons/{addonName}"} # type: ignore + + @overload def begin_create_or_update( self, - resource_group_name, # type: str - private_cloud_name, # type: str - addon_name, # type: str - addon, # type: "_models.Addon" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Addon"] + resource_group_name: str, + private_cloud_name: str, + addon_name: str, + addon: _models.Addon, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Addon]: """Create or update a addon in a private cloud. Create or update a addon in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: The name of the private cloud. + :param private_cloud_name: The name of the private cloud. Required. :type private_cloud_name: str - :param addon_name: Name of the addon for the private cloud. + :param addon_name: Name of the addon for the private cloud. Required. :type addon_name: str - :param addon: A addon in the private cloud. + :param addon: A addon in the private cloud. Required. :type addon: ~azure.mgmt.avs.models.Addon + :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 Addon or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.Addon] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Addon"] - 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, + private_cloud_name: str, + addon_name: str, + addon: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Addon]: + """Create or update a addon in a private cloud. + + Create or update a addon in a private cloud. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: The name of the private cloud. Required. + :type private_cloud_name: str + :param addon_name: Name of the addon for the private cloud. Required. + :type addon_name: str + :param addon: A addon in the private cloud. Required. + :type addon: 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 Addon or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.Addon] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + private_cloud_name: str, + addon_name: str, + addon: Union[_models.Addon, IO], + **kwargs: Any + ) -> LROPoller[_models.Addon]: + """Create or update a addon in a private cloud. + + Create or update a addon in a private cloud. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: The name of the private cloud. Required. + :type private_cloud_name: str + :param addon_name: Name of the addon for the private cloud. Required. + :type addon_name: str + :param addon: A addon in the private cloud. Is either a model type or a IO type. Required. + :type addon: ~azure.mgmt.avs.models.Addon 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 Addon or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.Addon] + :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.Addon] + 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, private_cloud_name=private_cloud_name, addon_name=addon_name, addon=addon, - 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('Addon', pipeline_response) - + deserialized = self._deserialize("Addon", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'addonName': self._serialize.url("addon_name", addon_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_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/addons/{addonName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def _delete_initial( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - addon_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/addons/{addonName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, private_cloud_name: str, addon_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'addonName': self._serialize.url("addon_name", addon_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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, + private_cloud_name=private_cloud_name, + addon_name=addon_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 - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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]: @@ -373,76 +624,73 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/addons/{addonName}'} # type: ignore + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/addons/{addonName}"} # type: ignore + @distributed_trace def begin_delete( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - addon_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + self, resource_group_name: str, private_cloud_name: str, addon_name: str, **kwargs: Any + ) -> LROPoller[None]: """Delete a addon in a private cloud. Delete a addon in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param addon_name: Name of the addon for the private cloud. + :param addon_name: Name of the addon for the private cloud. Required. :type addon_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, private_cloud_name=private_cloud_name, addon_name=addon_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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'addonName': self._serialize.url("addon_name", addon_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.AVS/privateClouds/{privateCloudName}/addons/{addonName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/addons/{addonName}"} # type: ignore diff --git a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_authorizations_operations.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_authorizations_operations.py index 87ba55b46207..0350303e871f 100644 --- a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_authorizations_operations.py +++ b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_authorizations_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,103 +6,263 @@ # 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 +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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_list_request( + resource_group_name: str, private_cloud_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/authorizations", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_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_get_request( + resource_group_name: str, private_cloud_name: str, authorization_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/authorizations/{authorizationName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "authorizationName": _SERIALIZER.url("authorization_name", authorization_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_create_or_update_request( + resource_group_name: str, private_cloud_name: str, authorization_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-05-01")) # 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.AVS/privateClouds/{privateCloudName}/authorizations/{authorizationName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "authorizationName": _SERIALIZER.url("authorization_name", authorization_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) -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]] + # 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_delete_request( + resource_group_name: str, private_cloud_name: str, authorization_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/authorizations/{authorizationName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "authorizationName": _SERIALIZER.url("authorization_name", authorization_name, "str"), + } -class AuthorizationsOperations(object): - """AuthorizationsOperations 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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class AuthorizationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.avs.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.avs.AVSClient`'s + :attr:`authorizations` 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") + @distributed_trace def list( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ExpressRouteAuthorizationList"] + self, resource_group_name: str, private_cloud_name: str, **kwargs: Any + ) -> Iterable["_models.ExpressRouteAuthorization"]: """List ExpressRoute Circuit Authorizations in a private cloud. List ExpressRoute Circuit Authorizations in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ExpressRouteAuthorizationList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.avs.models.ExpressRouteAuthorizationList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ExpressRouteAuthorization or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.avs.models.ExpressRouteAuthorization] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExpressRouteAuthorizationList"] + _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.ExpressRouteAuthorizationList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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('ExpressRouteAuthorizationList', pipeline_response) + deserialized = self._deserialize("ExpressRouteAuthorizationList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,7 +271,9 @@ 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]: @@ -119,118 +282,128 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/authorizations'} # type: ignore + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/authorizations"} # type: ignore + @distributed_trace def get( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - authorization_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ExpressRouteAuthorization" + self, resource_group_name: str, private_cloud_name: str, authorization_name: str, **kwargs: Any + ) -> _models.ExpressRouteAuthorization: """Get an ExpressRoute Circuit Authorization by name in a private cloud. Get an ExpressRoute Circuit Authorization by name in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :param authorization_name: Name of the ExpressRoute Circuit Authorization in the private cloud. + Required. :type authorization_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ExpressRouteAuthorization, or the result of cls(response) + :return: ExpressRouteAuthorization or the result of cls(response) :rtype: ~azure.mgmt.avs.models.ExpressRouteAuthorization - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExpressRouteAuthorization"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'authorizationName': self._serialize.url("authorization_name", authorization_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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.ExpressRouteAuthorization] + + request = build_get_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + authorization_name=authorization_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 - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ExpressRouteAuthorization', pipeline_response) + deserialized = self._deserialize("ExpressRouteAuthorization", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/authorizations/{authorizationName}'} # type: ignore + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/authorizations/{authorizationName}"} # type: ignore def _create_or_update_initial( self, - resource_group_name, # type: str - private_cloud_name, # type: str - authorization_name, # type: str - authorization, # type: "_models.ExpressRouteAuthorization" - **kwargs # type: Any - ): - # type: (...) -> "_models.ExpressRouteAuthorization" - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExpressRouteAuthorization"] + resource_group_name: str, + private_cloud_name: str, + authorization_name: str, + authorization: Union[_models.ExpressRouteAuthorization, IO], + **kwargs: Any + ) -> _models.ExpressRouteAuthorization: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'authorizationName': self._serialize.url("authorization_name", authorization_name, 'str'), - } - url = self._client.format_url(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(authorization, 'ExpressRouteAuthorization') - 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) + 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.ExpressRouteAuthorization] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(authorization, (IO, bytes)): + _content = authorization + else: + _json = self._serialize.body(authorization, "ExpressRouteAuthorization") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + authorization_name=authorization_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]: @@ -238,132 +411,223 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ExpressRouteAuthorization', pipeline_response) + deserialized = self._deserialize("ExpressRouteAuthorization", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ExpressRouteAuthorization', pipeline_response) + deserialized = self._deserialize("ExpressRouteAuthorization", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/authorizations/{authorizationName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/authorizations/{authorizationName}"} # type: ignore + + @overload def begin_create_or_update( self, - resource_group_name, # type: str - private_cloud_name, # type: str - authorization_name, # type: str - authorization, # type: "_models.ExpressRouteAuthorization" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ExpressRouteAuthorization"] + resource_group_name: str, + private_cloud_name: str, + authorization_name: str, + authorization: _models.ExpressRouteAuthorization, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ExpressRouteAuthorization]: """Create or update an ExpressRoute Circuit Authorization in a private cloud. Create or update an ExpressRoute Circuit Authorization in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: The name of the private cloud. + :param private_cloud_name: The name of the private cloud. Required. :type private_cloud_name: str :param authorization_name: Name of the ExpressRoute Circuit Authorization in the private cloud. + Required. :type authorization_name: str - :param authorization: An ExpressRoute Circuit Authorization. + :param authorization: An ExpressRoute Circuit Authorization. Required. :type authorization: ~azure.mgmt.avs.models.ExpressRouteAuthorization + :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 ExpressRouteAuthorization 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 ExpressRouteAuthorization or the result + of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.ExpressRouteAuthorization] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExpressRouteAuthorization"] - 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, + private_cloud_name: str, + authorization_name: str, + authorization: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ExpressRouteAuthorization]: + """Create or update an ExpressRoute Circuit Authorization in a private cloud. + + Create or update an ExpressRoute Circuit Authorization in a private cloud. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: The name of the private cloud. Required. + :type private_cloud_name: str + :param authorization_name: Name of the ExpressRoute Circuit Authorization in the private cloud. + Required. + :type authorization_name: str + :param authorization: An ExpressRoute Circuit Authorization. Required. + :type authorization: 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 ExpressRouteAuthorization or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.ExpressRouteAuthorization] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + private_cloud_name: str, + authorization_name: str, + authorization: Union[_models.ExpressRouteAuthorization, IO], + **kwargs: Any + ) -> LROPoller[_models.ExpressRouteAuthorization]: + """Create or update an ExpressRoute Circuit Authorization in a private cloud. + + Create or update an ExpressRoute Circuit Authorization in a private cloud. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: The name of the private cloud. Required. + :type private_cloud_name: str + :param authorization_name: Name of the ExpressRoute Circuit Authorization in the private cloud. + Required. + :type authorization_name: str + :param authorization: An ExpressRoute Circuit Authorization. Is either a model type or a IO + type. Required. + :type authorization: ~azure.mgmt.avs.models.ExpressRouteAuthorization 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 ExpressRouteAuthorization or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.ExpressRouteAuthorization] + :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.ExpressRouteAuthorization] + 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, private_cloud_name=private_cloud_name, authorization_name=authorization_name, authorization=authorization, - 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('ExpressRouteAuthorization', pipeline_response) - + deserialized = self._deserialize("ExpressRouteAuthorization", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'authorizationName': self._serialize.url("authorization_name", authorization_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_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/authorizations/{authorizationName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def _delete_initial( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - authorization_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/authorizations/{authorizationName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, private_cloud_name: str, authorization_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'authorizationName': self._serialize.url("authorization_name", authorization_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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, + private_cloud_name=private_cloud_name, + authorization_name=authorization_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 - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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]: @@ -373,76 +637,74 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/authorizations/{authorizationName}'} # type: ignore + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/authorizations/{authorizationName}"} # type: ignore + @distributed_trace def begin_delete( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - authorization_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + self, resource_group_name: str, private_cloud_name: str, authorization_name: str, **kwargs: Any + ) -> LROPoller[None]: """Delete an ExpressRoute Circuit Authorization in a private cloud. Delete an ExpressRoute Circuit Authorization in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :param authorization_name: Name of the ExpressRoute Circuit Authorization in the private cloud. + Required. :type authorization_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, private_cloud_name=private_cloud_name, authorization_name=authorization_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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'authorizationName': self._serialize.url("authorization_name", authorization_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.AVS/privateClouds/{privateCloudName}/authorizations/{authorizationName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/authorizations/{authorizationName}"} # type: ignore diff --git a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_cloud_links_operations.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_cloud_links_operations.py index 36cb04a58572..0878d3d02b04 100644 --- a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_cloud_links_operations.py +++ b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_cloud_links_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,103 +6,260 @@ # 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 +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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_list_request( + resource_group_name: str, private_cloud_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/cloudLinks", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_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_get_request( + resource_group_name: str, private_cloud_name: str, cloud_link_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/cloudLinks/{cloudLinkName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "cloudLinkName": _SERIALIZER.url("cloud_link_name", cloud_link_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_create_or_update_request( + resource_group_name: str, private_cloud_name: str, cloud_link_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-05-01")) # 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.AVS/privateClouds/{privateCloudName}/cloudLinks/{cloudLinkName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "cloudLinkName": _SERIALIZER.url("cloud_link_name", cloud_link_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) -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]] + # 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_delete_request( + resource_group_name: str, private_cloud_name: str, cloud_link_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/cloudLinks/{cloudLinkName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "cloudLinkName": _SERIALIZER.url("cloud_link_name", cloud_link_name, "str"), + } -class CloudLinksOperations(object): - """CloudLinksOperations 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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class CloudLinksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.avs.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.avs.AVSClient`'s + :attr:`cloud_links` 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 list( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.CloudLinkList"] + @distributed_trace + def list(self, resource_group_name: str, private_cloud_name: str, **kwargs: Any) -> Iterable["_models.CloudLink"]: """List cloud link in a private cloud. List cloud link in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CloudLinkList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.avs.models.CloudLinkList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either CloudLink or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.avs.models.CloudLink] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudLinkList"] + _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.CloudLinkList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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('CloudLinkList', pipeline_response) + deserialized = self._deserialize("CloudLinkList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,7 +268,9 @@ 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]: @@ -119,118 +279,127 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/cloudLinks'} # type: ignore + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/cloudLinks"} # type: ignore + @distributed_trace def get( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - cloud_link_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.CloudLink" + self, resource_group_name: str, private_cloud_name: str, cloud_link_name: str, **kwargs: Any + ) -> _models.CloudLink: """Get an cloud link by name in a private cloud. Get an cloud link by name in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param cloud_link_name: Name of the cloud link resource. + :param cloud_link_name: Name of the cloud link resource. Required. :type cloud_link_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CloudLink, or the result of cls(response) + :return: CloudLink or the result of cls(response) :rtype: ~azure.mgmt.avs.models.CloudLink - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudLink"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'cloudLinkName': self._serialize.url("cloud_link_name", cloud_link_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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.CloudLink] + + request = build_get_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + cloud_link_name=cloud_link_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 - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CloudLink', pipeline_response) + deserialized = self._deserialize("CloudLink", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/cloudLinks/{cloudLinkName}'} # type: ignore + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/cloudLinks/{cloudLinkName}"} # type: ignore def _create_or_update_initial( self, - resource_group_name, # type: str - private_cloud_name, # type: str - cloud_link_name, # type: str - cloud_link, # type: "_models.CloudLink" - **kwargs # type: Any - ): - # type: (...) -> "_models.CloudLink" - cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudLink"] + resource_group_name: str, + private_cloud_name: str, + cloud_link_name: str, + cloud_link: Union[_models.CloudLink, IO], + **kwargs: Any + ) -> _models.CloudLink: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'cloudLinkName': self._serialize.url("cloud_link_name", cloud_link_name, 'str'), - } - url = self._client.format_url(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(cloud_link, 'CloudLink') - 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) + 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.CloudLink] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(cloud_link, (IO, bytes)): + _content = cloud_link + else: + _json = self._serialize.body(cloud_link, "CloudLink") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + cloud_link_name=cloud_link_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]: @@ -238,132 +407,217 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CloudLink', pipeline_response) + deserialized = self._deserialize("CloudLink", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CloudLink', pipeline_response) + deserialized = self._deserialize("CloudLink", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/cloudLinks/{cloudLinkName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/cloudLinks/{cloudLinkName}"} # type: ignore + + @overload def begin_create_or_update( self, - resource_group_name, # type: str - private_cloud_name, # type: str - cloud_link_name, # type: str - cloud_link, # type: "_models.CloudLink" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.CloudLink"] + resource_group_name: str, + private_cloud_name: str, + cloud_link_name: str, + cloud_link: _models.CloudLink, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CloudLink]: """Create or update a cloud link in a private cloud. Create or update a cloud link in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: The name of the private cloud. + :param private_cloud_name: The name of the private cloud. Required. :type private_cloud_name: str - :param cloud_link_name: Name of the cloud link resource. + :param cloud_link_name: Name of the cloud link resource. Required. :type cloud_link_name: str - :param cloud_link: A cloud link in the private cloud. + :param cloud_link: A cloud link in the private cloud. Required. :type cloud_link: ~azure.mgmt.avs.models.CloudLink + :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 CloudLink or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.CloudLink] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CloudLink"] - 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, + private_cloud_name: str, + cloud_link_name: str, + cloud_link: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CloudLink]: + """Create or update a cloud link in a private cloud. + + Create or update a cloud link in a private cloud. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: The name of the private cloud. Required. + :type private_cloud_name: str + :param cloud_link_name: Name of the cloud link resource. Required. + :type cloud_link_name: str + :param cloud_link: A cloud link in the private cloud. Required. + :type cloud_link: 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 CloudLink or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.CloudLink] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + private_cloud_name: str, + cloud_link_name: str, + cloud_link: Union[_models.CloudLink, IO], + **kwargs: Any + ) -> LROPoller[_models.CloudLink]: + """Create or update a cloud link in a private cloud. + + Create or update a cloud link in a private cloud. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: The name of the private cloud. Required. + :type private_cloud_name: str + :param cloud_link_name: Name of the cloud link resource. Required. + :type cloud_link_name: str + :param cloud_link: A cloud link in the private cloud. Is either a model type or a IO type. + Required. + :type cloud_link: ~azure.mgmt.avs.models.CloudLink 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 CloudLink or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.CloudLink] + :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.CloudLink] + 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, private_cloud_name=private_cloud_name, cloud_link_name=cloud_link_name, cloud_link=cloud_link, - 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('CloudLink', pipeline_response) - + deserialized = self._deserialize("CloudLink", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'cloudLinkName': self._serialize.url("cloud_link_name", cloud_link_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_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/cloudLinks/{cloudLinkName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def _delete_initial( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - cloud_link_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/cloudLinks/{cloudLinkName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, private_cloud_name: str, cloud_link_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'cloudLinkName': self._serialize.url("cloud_link_name", cloud_link_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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, + private_cloud_name=private_cloud_name, + cloud_link_name=cloud_link_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 - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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]: @@ -373,76 +627,73 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/cloudLinks/{cloudLinkName}'} # type: ignore + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/cloudLinks/{cloudLinkName}"} # type: ignore + @distributed_trace def begin_delete( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - cloud_link_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + self, resource_group_name: str, private_cloud_name: str, cloud_link_name: str, **kwargs: Any + ) -> LROPoller[None]: """Delete a cloud link in a private cloud. Delete a cloud link in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param cloud_link_name: Name of the cloud link resource. + :param cloud_link_name: Name of the cloud link resource. Required. :type cloud_link_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, private_cloud_name=private_cloud_name, cloud_link_name=cloud_link_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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'cloudLinkName': self._serialize.url("cloud_link_name", cloud_link_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.AVS/privateClouds/{privateCloudName}/cloudLinks/{cloudLinkName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/cloudLinks/{cloudLinkName}"} # type: ignore diff --git a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_clusters_operations.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_clusters_operations.py index c8db0db6d520..68c52894cec8 100644 --- a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_clusters_operations.py +++ b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_clusters_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,103 +6,331 @@ # 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 +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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_list_request( + resource_group_name: str, private_cloud_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_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_get_request( + resource_group_name: str, private_cloud_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_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_create_or_update_request( + resource_group_name: str, private_cloud_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-05-01")) # 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.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_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_update_request( + resource_group_name: str, private_cloud_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-05-01")) # 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.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_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, private_cloud_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_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="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_zones_request( + resource_group_name: str, private_cloud_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/listZones", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) -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]] - -class ClustersOperations(object): - """ClustersOperations 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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class ClustersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.avs.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.avs.AVSClient`'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 list( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ClusterList"] + @distributed_trace + def list(self, resource_group_name: str, private_cloud_name: str, **kwargs: Any) -> Iterable["_models.Cluster"]: """List clusters in a private cloud. List clusters in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ClusterList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.avs.models.ClusterList] - :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.avs.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClusterList"] + _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.ClusterList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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('ClusterList', pipeline_response) + deserialized = self._deserialize("ClusterList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,7 +339,9 @@ 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]: @@ -119,118 +350,127 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters'} # type: ignore + return ItemPaged(get_next, extract_data) + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters"} # type: ignore + + @distributed_trace def get( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - cluster_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Cluster" + self, resource_group_name: str, private_cloud_name: str, cluster_name: str, **kwargs: Any + ) -> _models.Cluster: """Get a cluster by name in a private cloud. Get a cluster by name in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param cluster_name: Name of the cluster in the private cloud. + :param cluster_name: Name of the cluster in the private cloud. 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.avs.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 + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_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') + 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, + private_cloud_name=private_cloud_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 - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, 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.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}'} # type: ignore + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}"} # type: ignore def _create_or_update_initial( self, - resource_group_name, # type: str - private_cloud_name, # type: str - cluster_name, # type: str - cluster, # type: "_models.Cluster" - **kwargs # type: Any - ): - # type: (...) -> "_models.Cluster" - cls = kwargs.pop('cls', None) # type: ClsType["_models.Cluster"] + resource_group_name: str, + private_cloud_name: str, + cluster_name: str, + cluster: Union[_models.Cluster, IO], + **kwargs: Any + ) -> _models.Cluster: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_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] - body_content = self._serialize.body(cluster, 'Cluster') - 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) + 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(cluster, (IO, bytes)): + _content = cluster + else: + _json = self._serialize.body(cluster, "Cluster") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_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_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]: @@ -238,138 +478,233 @@ def _create_or_update_initial( raise HttpResponseError(response=response, 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_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}"} # type: ignore + + @overload def begin_create_or_update( self, - resource_group_name, # type: str - private_cloud_name, # type: str - cluster_name, # type: str - cluster, # type: "_models.Cluster" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Cluster"] + resource_group_name: str, + private_cloud_name: str, + cluster_name: str, + cluster: _models.Cluster, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Cluster]: """Create or update a cluster in a private cloud. Create or update a cluster in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: The name of the private cloud. + :param private_cloud_name: The name of the private cloud. Required. :type private_cloud_name: str - :param cluster_name: Name of the cluster in the private cloud. + :param cluster_name: Name of the cluster in the private cloud. Required. :type cluster_name: str - :param cluster: A cluster in the private cloud. + :param cluster: A cluster in the private cloud. Required. :type cluster: ~azure.mgmt.avs.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.avs.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_or_update( + self, + resource_group_name: str, + private_cloud_name: str, + cluster_name: str, + cluster: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Cluster]: + """Create or update a cluster in a private cloud. + + Create or update a cluster in a private cloud. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: The name of the private cloud. Required. + :type private_cloud_name: str + :param cluster_name: Name of the cluster in the private cloud. Required. + :type cluster_name: str + :param cluster: A cluster in the private cloud. Required. + :type cluster: 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.avs.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + private_cloud_name: str, + cluster_name: str, + cluster: Union[_models.Cluster, IO], + **kwargs: Any + ) -> LROPoller[_models.Cluster]: + """Create or update a cluster in a private cloud. + + Create or update a cluster in a private cloud. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: The name of the private cloud. Required. + :type private_cloud_name: str + :param cluster_name: Name of the cluster in the private cloud. Required. + :type cluster_name: str + :param cluster: A cluster in the private cloud. Is either a model type or a IO type. Required. + :type cluster: ~azure.mgmt.avs.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.avs.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_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, private_cloud_name=private_cloud_name, cluster_name=cluster_name, cluster=cluster, - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_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_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}'} # 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.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}"} # type: ignore def _update_initial( self, - resource_group_name, # type: str - private_cloud_name, # type: str - cluster_name, # type: str - cluster_update, # type: "_models.ClusterUpdate" - **kwargs # type: Any - ): - # type: (...) -> "_models.Cluster" - cls = kwargs.pop('cls', None) # type: ClsType["_models.Cluster"] + resource_group_name: str, + private_cloud_name: str, + cluster_name: str, + cluster_update: Union[_models.ClusterUpdate, IO], + **kwargs: Any + ) -> _models.Cluster: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_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] - body_content = self._serialize.body(cluster_update, 'ClusterUpdate') - 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) + 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(cluster_update, (IO, bytes)): + _content = cluster_update + else: + _json = self._serialize.body(cluster_update, "ClusterUpdate") + + request = build_update_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_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_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]: @@ -377,132 +712,217 @@ def _update_initial( raise HttpResponseError(response=response, 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 - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}'} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}"} # type: ignore + + @overload def begin_update( self, - resource_group_name, # type: str - private_cloud_name, # type: str - cluster_name, # type: str - cluster_update, # type: "_models.ClusterUpdate" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Cluster"] + resource_group_name: str, + private_cloud_name: str, + cluster_name: str, + cluster_update: _models.ClusterUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Cluster]: """Update a cluster in a private cloud. Update a cluster in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param cluster_name: Name of the cluster in the private cloud. + :param cluster_name: Name of the cluster in the private cloud. Required. :type cluster_name: str - :param cluster_update: The cluster properties to be updated. + :param cluster_update: The cluster properties to be updated. Required. :type cluster_update: ~azure.mgmt.avs.models.ClusterUpdate + :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.avs.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_update( + self, + resource_group_name: str, + private_cloud_name: str, + cluster_name: str, + cluster_update: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Cluster]: + """Update a cluster in a private cloud. + + Update a cluster in a private cloud. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param cluster_name: Name of the cluster in the private cloud. Required. + :type cluster_name: str + :param cluster_update: The cluster properties to be updated. Required. + :type cluster_update: 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.avs.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + private_cloud_name: str, + cluster_name: str, + cluster_update: Union[_models.ClusterUpdate, IO], + **kwargs: Any + ) -> LROPoller[_models.Cluster]: + """Update a cluster in a private cloud. + + Update a cluster in a private cloud. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param cluster_name: Name of the cluster in the private cloud. Required. + :type cluster_name: str + :param cluster_update: The cluster properties to be updated. Is either a model type or a IO + type. Required. + :type cluster_update: ~azure.mgmt.avs.models.ClusterUpdate 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.avs.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._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, private_cloud_name=private_cloud_name, cluster_name=cluster_name, cluster_update=cluster_update, - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_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_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def _delete_initial( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - cluster_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, private_cloud_name: str, cluster_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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, + private_cloud_name=private_cloud_name, + cluster_name=cluster_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 - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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]: @@ -512,76 +932,139 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}'} # type: ignore + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}"} # type: ignore + @distributed_trace def begin_delete( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - cluster_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + self, resource_group_name: str, private_cloud_name: str, cluster_name: str, **kwargs: Any + ) -> LROPoller[None]: """Delete a cluster in a private cloud. Delete a cluster in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param cluster_name: Name of the cluster in the private cloud. + :param cluster_name: Name of the cluster in the private cloud. Required. :type cluster_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, private_cloud_name=private_cloud_name, cluster_name=cluster_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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_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.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}"} # type: ignore + + @distributed_trace + def list_zones( + self, resource_group_name: str, private_cloud_name: str, cluster_name: str, **kwargs: Any + ) -> _models.ClusterZoneList: + """List hosts by zone in a cluster. + + List hosts by zone in a cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param cluster_name: Name of the cluster in the private cloud. Required. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ClusterZoneList or the result of cls(response) + :rtype: ~azure.mgmt.avs.models.ClusterZoneList + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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.ClusterZoneList] + + request = build_list_zones_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_zones.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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ClusterZoneList", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_zones.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/listZones"} # type: ignore diff --git a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_datastores_operations.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_datastores_operations.py index d06b71646495..69e384752cd9 100644 --- a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_datastores_operations.py +++ b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_datastores_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,107 +6,284 @@ # 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 +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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_list_request( + resource_group_name: str, private_cloud_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/datastores", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_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_get_request( + resource_group_name: str, + private_cloud_name: str, + cluster_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/datastores/{datastoreName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_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_create_or_update_request( + resource_group_name: str, + private_cloud_name: str, + cluster_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-05-01")) # 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.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/datastores/{datastoreName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_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_delete_request( + resource_group_name: str, + private_cloud_name: str, + cluster_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/datastores/{datastoreName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_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="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class DatastoresOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -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]] - -class DatastoresOperations(object): - """DatastoresOperations 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. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.avs.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.avs.AVSClient`'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") + @distributed_trace def list( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - cluster_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DatastoreList"] + self, resource_group_name: str, private_cloud_name: str, cluster_name: str, **kwargs: Any + ) -> Iterable["_models.Datastore"]: """List datastores in a private cloud cluster. List datastores in a private cloud cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param cluster_name: Name of the cluster in the private cloud. + :param cluster_name: Name of the cluster in the private cloud. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DatastoreList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.avs.models.DatastoreList] - :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.avs.models.Datastore] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DatastoreList"] + _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.DatastoreList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + cluster_name=cluster_name, + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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('DatastoreList', pipeline_response) + deserialized = self._deserialize("DatastoreList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -114,7 +292,9 @@ 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]: @@ -123,124 +303,132 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/datastores'} # type: ignore + return ItemPaged(get_next, extract_data) + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/datastores"} # type: ignore + + @distributed_trace def get( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - cluster_name, # type: str - datastore_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Datastore" + self, resource_group_name: str, private_cloud_name: str, cluster_name: str, datastore_name: str, **kwargs: Any + ) -> _models.Datastore: """Get a datastore in a private cloud cluster. Get a datastore in a private cloud cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param cluster_name: Name of the cluster in the private cloud. + :param cluster_name: Name of the cluster in the private cloud. Required. :type cluster_name: str - :param datastore_name: Name of the datastore in the private cloud cluster. + :param datastore_name: Name of the datastore in the private cloud cluster. 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.avs.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 + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_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') + 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, + private_cloud_name=private_cloud_name, + cluster_name=cluster_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 - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, 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.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/datastores/{datastoreName}'} # type: ignore + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/datastores/{datastoreName}"} # type: ignore def _create_or_update_initial( self, - resource_group_name, # type: str - private_cloud_name, # type: str - cluster_name, # type: str - datastore_name, # type: str - datastore, # type: "_models.Datastore" - **kwargs # type: Any - ): - # type: (...) -> "_models.Datastore" - cls = kwargs.pop('cls', None) # type: ClsType["_models.Datastore"] + resource_group_name: str, + private_cloud_name: str, + cluster_name: str, + datastore_name: str, + datastore: Union[_models.Datastore, IO], + **kwargs: Any + ) -> _models.Datastore: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'datastoreName': self._serialize.url("datastore_name", datastore_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(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(datastore, 'Datastore') - 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) + 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(datastore, (IO, bytes)): + _content = datastore + else: + _json = self._serialize.body(datastore, "Datastore") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + cluster_name=cluster_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_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]: @@ -248,139 +436,228 @@ def _create_or_update_initial( raise HttpResponseError(response=response, 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_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/datastores/{datastoreName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/datastores/{datastoreName}"} # type: ignore + + @overload def begin_create_or_update( self, - resource_group_name, # type: str - private_cloud_name, # type: str - cluster_name, # type: str - datastore_name, # type: str - datastore, # type: "_models.Datastore" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Datastore"] + resource_group_name: str, + private_cloud_name: str, + cluster_name: str, + datastore_name: str, + datastore: _models.Datastore, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Datastore]: """Create or update a datastore in a private cloud cluster. Create or update a datastore in a private cloud cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param cluster_name: Name of the cluster in the private cloud. + :param cluster_name: Name of the cluster in the private cloud. Required. :type cluster_name: str - :param datastore_name: Name of the datastore in the private cloud cluster. + :param datastore_name: Name of the datastore in the private cloud cluster. Required. :type datastore_name: str - :param datastore: A datastore in a private cloud cluster. + :param datastore: A datastore in a private cloud cluster. Required. :type datastore: ~azure.mgmt.avs.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.avs.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_or_update( + self, + resource_group_name: str, + private_cloud_name: str, + cluster_name: str, + datastore_name: str, + datastore: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Datastore]: + """Create or update a datastore in a private cloud cluster. + + Create or update a datastore in a private cloud cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param cluster_name: Name of the cluster in the private cloud. Required. + :type cluster_name: str + :param datastore_name: Name of the datastore in the private cloud cluster. Required. + :type datastore_name: str + :param datastore: A datastore in a private cloud cluster. Required. + :type datastore: 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.avs.models.Datastore] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + private_cloud_name: str, + cluster_name: str, + datastore_name: str, + datastore: Union[_models.Datastore, IO], + **kwargs: Any + ) -> LROPoller[_models.Datastore]: + """Create or update a datastore in a private cloud cluster. + + Create or update a datastore in a private cloud cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param cluster_name: Name of the cluster in the private cloud. Required. + :type cluster_name: str + :param datastore_name: Name of the datastore in the private cloud cluster. Required. + :type datastore_name: str + :param datastore: A datastore in a private cloud cluster. Is either a model type or a IO type. + Required. + :type datastore: ~azure.mgmt.avs.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.avs.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_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, private_cloud_name=private_cloud_name, cluster_name=cluster_name, datastore_name=datastore_name, datastore=datastore, - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_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_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/datastores/{datastoreName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def _delete_initial( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - cluster_name, # type: str - datastore_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/datastores/{datastoreName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, private_cloud_name: str, cluster_name: str, datastore_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'datastoreName': self._serialize.url("datastore_name", datastore_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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, + private_cloud_name=private_cloud_name, + cluster_name=cluster_name, + datastore_name=datastore_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 - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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]: @@ -390,81 +667,76 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/datastores/{datastoreName}'} # type: ignore + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/datastores/{datastoreName}"} # type: ignore + @distributed_trace def begin_delete( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - cluster_name, # type: str - datastore_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + self, resource_group_name: str, private_cloud_name: str, cluster_name: str, datastore_name: str, **kwargs: Any + ) -> LROPoller[None]: """Delete a datastore in a private cloud cluster. Delete a datastore in a private cloud cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param cluster_name: Name of the cluster in the private cloud. + :param cluster_name: Name of the cluster in the private cloud. Required. :type cluster_name: str - :param datastore_name: Name of the datastore in the private cloud cluster. + :param datastore_name: Name of the datastore in the private cloud cluster. Required. :type datastore_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, private_cloud_name=private_cloud_name, cluster_name=cluster_name, datastore_name=datastore_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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_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.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/datastores/{datastoreName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/datastores/{datastoreName}"} # type: ignore diff --git a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_global_reach_connections_operations.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_global_reach_connections_operations.py index 5174658a469d..2f31da805981 100644 --- a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_global_reach_connections_operations.py +++ b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_global_reach_connections_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,103 +6,281 @@ # 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 +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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_list_request( + resource_group_name: str, private_cloud_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/globalReachConnections", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_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_get_request( + resource_group_name: str, + private_cloud_name: str, + global_reach_connection_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/globalReachConnections/{globalReachConnectionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "globalReachConnectionName": _SERIALIZER.url( + "global_reach_connection_name", global_reach_connection_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_create_or_update_request( + resource_group_name: str, + private_cloud_name: str, + global_reach_connection_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-05-01")) # 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.AVS/privateClouds/{privateCloudName}/globalReachConnections/{globalReachConnectionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "globalReachConnectionName": _SERIALIZER.url( + "global_reach_connection_name", global_reach_connection_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_delete_request( + resource_group_name: str, + private_cloud_name: str, + global_reach_connection_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/globalReachConnections/{globalReachConnectionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "globalReachConnectionName": _SERIALIZER.url( + "global_reach_connection_name", global_reach_connection_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) + + +class GlobalReachConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -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]] - -class GlobalReachConnectionsOperations(object): - """GlobalReachConnectionsOperations 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. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.avs.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.avs.AVSClient`'s + :attr:`global_reach_connections` 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") + @distributed_trace def list( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.GlobalReachConnectionList"] + self, resource_group_name: str, private_cloud_name: str, **kwargs: Any + ) -> Iterable["_models.GlobalReachConnection"]: """List global reach connections in a private cloud. List global reach connections in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GlobalReachConnectionList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.avs.models.GlobalReachConnectionList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either GlobalReachConnection or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.avs.models.GlobalReachConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GlobalReachConnectionList"] + _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.GlobalReachConnectionList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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('GlobalReachConnectionList', pipeline_response) + deserialized = self._deserialize("GlobalReachConnectionList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,7 +289,9 @@ 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]: @@ -119,118 +300,128 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/globalReachConnections'} # type: ignore + return ItemPaged(get_next, extract_data) + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/globalReachConnections"} # type: ignore + + @distributed_trace def get( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - global_reach_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.GlobalReachConnection" + self, resource_group_name: str, private_cloud_name: str, global_reach_connection_name: str, **kwargs: Any + ) -> _models.GlobalReachConnection: """Get a global reach connection by name in a private cloud. Get a global reach connection by name in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :param global_reach_connection_name: Name of the global reach connection in the private cloud. + Required. :type global_reach_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GlobalReachConnection, or the result of cls(response) + :return: GlobalReachConnection or the result of cls(response) :rtype: ~azure.mgmt.avs.models.GlobalReachConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GlobalReachConnection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'globalReachConnectionName': self._serialize.url("global_reach_connection_name", global_reach_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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.GlobalReachConnection] + + request = build_get_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + global_reach_connection_name=global_reach_connection_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 - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('GlobalReachConnection', pipeline_response) + deserialized = self._deserialize("GlobalReachConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/globalReachConnections/{globalReachConnectionName}'} # type: ignore + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/globalReachConnections/{globalReachConnectionName}"} # type: ignore def _create_or_update_initial( self, - resource_group_name, # type: str - private_cloud_name, # type: str - global_reach_connection_name, # type: str - global_reach_connection, # type: "_models.GlobalReachConnection" - **kwargs # type: Any - ): - # type: (...) -> "_models.GlobalReachConnection" - cls = kwargs.pop('cls', None) # type: ClsType["_models.GlobalReachConnection"] + resource_group_name: str, + private_cloud_name: str, + global_reach_connection_name: str, + global_reach_connection: Union[_models.GlobalReachConnection, IO], + **kwargs: Any + ) -> _models.GlobalReachConnection: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'globalReachConnectionName': self._serialize.url("global_reach_connection_name", global_reach_connection_name, 'str'), - } - url = self._client.format_url(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(global_reach_connection, 'GlobalReachConnection') - 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) + 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.GlobalReachConnection] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(global_reach_connection, (IO, bytes)): + _content = global_reach_connection + else: + _json = self._serialize.body(global_reach_connection, "GlobalReachConnection") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + global_reach_connection_name=global_reach_connection_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]: @@ -238,132 +429,223 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('GlobalReachConnection', pipeline_response) + deserialized = self._deserialize("GlobalReachConnection", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('GlobalReachConnection', pipeline_response) + deserialized = self._deserialize("GlobalReachConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/globalReachConnections/{globalReachConnectionName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/globalReachConnections/{globalReachConnectionName}"} # type: ignore + + @overload def begin_create_or_update( self, - resource_group_name, # type: str - private_cloud_name, # type: str - global_reach_connection_name, # type: str - global_reach_connection, # type: "_models.GlobalReachConnection" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.GlobalReachConnection"] + resource_group_name: str, + private_cloud_name: str, + global_reach_connection_name: str, + global_reach_connection: _models.GlobalReachConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GlobalReachConnection]: """Create or update a global reach connection in a private cloud. Create or update a global reach connection in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: The name of the private cloud. + :param private_cloud_name: The name of the private cloud. Required. :type private_cloud_name: str :param global_reach_connection_name: Name of the global reach connection in the private cloud. + Required. :type global_reach_connection_name: str - :param global_reach_connection: A global reach connection in the private cloud. + :param global_reach_connection: A global reach connection in the private cloud. Required. :type global_reach_connection: ~azure.mgmt.avs.models.GlobalReachConnection + :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 GlobalReachConnection 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 GlobalReachConnection or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.GlobalReachConnection] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.GlobalReachConnection"] - 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, + private_cloud_name: str, + global_reach_connection_name: str, + global_reach_connection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.GlobalReachConnection]: + """Create or update a global reach connection in a private cloud. + + Create or update a global reach connection in a private cloud. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: The name of the private cloud. Required. + :type private_cloud_name: str + :param global_reach_connection_name: Name of the global reach connection in the private cloud. + Required. + :type global_reach_connection_name: str + :param global_reach_connection: A global reach connection in the private cloud. Required. + :type global_reach_connection: 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 GlobalReachConnection or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.GlobalReachConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + private_cloud_name: str, + global_reach_connection_name: str, + global_reach_connection: Union[_models.GlobalReachConnection, IO], + **kwargs: Any + ) -> LROPoller[_models.GlobalReachConnection]: + """Create or update a global reach connection in a private cloud. + + Create or update a global reach connection in a private cloud. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: The name of the private cloud. Required. + :type private_cloud_name: str + :param global_reach_connection_name: Name of the global reach connection in the private cloud. + Required. + :type global_reach_connection_name: str + :param global_reach_connection: A global reach connection in the private cloud. Is either a + model type or a IO type. Required. + :type global_reach_connection: ~azure.mgmt.avs.models.GlobalReachConnection 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 GlobalReachConnection or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.GlobalReachConnection] + :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.GlobalReachConnection] + 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, private_cloud_name=private_cloud_name, global_reach_connection_name=global_reach_connection_name, global_reach_connection=global_reach_connection, - 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('GlobalReachConnection', pipeline_response) - + deserialized = self._deserialize("GlobalReachConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'globalReachConnectionName': self._serialize.url("global_reach_connection_name", global_reach_connection_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_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/globalReachConnections/{globalReachConnectionName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def _delete_initial( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - global_reach_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/globalReachConnections/{globalReachConnectionName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, private_cloud_name: str, global_reach_connection_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'globalReachConnectionName': self._serialize.url("global_reach_connection_name", global_reach_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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, + private_cloud_name=private_cloud_name, + global_reach_connection_name=global_reach_connection_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 - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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]: @@ -373,76 +655,74 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/globalReachConnections/{globalReachConnectionName}'} # type: ignore + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/globalReachConnections/{globalReachConnectionName}"} # type: ignore + @distributed_trace def begin_delete( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - global_reach_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + self, resource_group_name: str, private_cloud_name: str, global_reach_connection_name: str, **kwargs: Any + ) -> LROPoller[None]: """Delete a global reach connection in a private cloud. Delete a global reach connection in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :param global_reach_connection_name: Name of the global reach connection in the private cloud. + Required. :type global_reach_connection_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, private_cloud_name=private_cloud_name, global_reach_connection_name=global_reach_connection_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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'globalReachConnectionName': self._serialize.url("global_reach_connection_name", global_reach_connection_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.AVS/privateClouds/{privateCloudName}/globalReachConnections/{globalReachConnectionName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/globalReachConnections/{globalReachConnectionName}"} # type: ignore diff --git a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_hcx_enterprise_sites_operations.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_hcx_enterprise_sites_operations.py index 4d2296c144a8..4984285a3451 100644 --- a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_hcx_enterprise_sites_operations.py +++ b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_hcx_enterprise_sites_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,101 +6,272 @@ # 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 +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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_list_request( + resource_group_name: str, private_cloud_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/hcxEnterpriseSites", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_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_get_request( + resource_group_name: str, + private_cloud_name: str, + hcx_enterprise_site_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/hcxEnterpriseSites/{hcxEnterpriseSiteName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "hcxEnterpriseSiteName": _SERIALIZER.url("hcx_enterprise_site_name", hcx_enterprise_site_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_create_or_update_request( + resource_group_name: str, + private_cloud_name: str, + hcx_enterprise_site_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-05-01")) # 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.AVS/privateClouds/{privateCloudName}/hcxEnterpriseSites/{hcxEnterpriseSiteName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "hcxEnterpriseSiteName": _SERIALIZER.url("hcx_enterprise_site_name", hcx_enterprise_site_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_delete_request( + resource_group_name: str, + private_cloud_name: str, + hcx_enterprise_site_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/hcxEnterpriseSites/{hcxEnterpriseSiteName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "hcxEnterpriseSiteName": _SERIALIZER.url("hcx_enterprise_site_name", hcx_enterprise_site_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) + + +class HcxEnterpriseSitesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -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]] - -class HcxEnterpriseSitesOperations(object): - """HcxEnterpriseSitesOperations 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. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.avs.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.avs.AVSClient`'s + :attr:`hcx_enterprise_sites` 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") + @distributed_trace def list( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.HcxEnterpriseSiteList"] + self, resource_group_name: str, private_cloud_name: str, **kwargs: Any + ) -> Iterable["_models.HcxEnterpriseSite"]: """List HCX Enterprise Sites in a private cloud. List HCX Enterprise Sites in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either HcxEnterpriseSiteList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.avs.models.HcxEnterpriseSiteList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either HcxEnterpriseSite or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.avs.models.HcxEnterpriseSite] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.HcxEnterpriseSiteList"] + _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.HcxEnterpriseSiteList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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('HcxEnterpriseSiteList', pipeline_response) + deserialized = self._deserialize("HcxEnterpriseSiteList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -108,7 +280,9 @@ 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]: @@ -117,135 +291,220 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/hcxEnterpriseSites'} # type: ignore + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/hcxEnterpriseSites"} # type: ignore + @distributed_trace def get( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - hcx_enterprise_site_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.HcxEnterpriseSite" + self, resource_group_name: str, private_cloud_name: str, hcx_enterprise_site_name: str, **kwargs: Any + ) -> _models.HcxEnterpriseSite: """Get an HCX Enterprise Site by name in a private cloud. Get an HCX Enterprise Site by name in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :param hcx_enterprise_site_name: Name of the HCX Enterprise Site in the private cloud. + Required. :type hcx_enterprise_site_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: HcxEnterpriseSite, or the result of cls(response) + :return: HcxEnterpriseSite or the result of cls(response) :rtype: ~azure.mgmt.avs.models.HcxEnterpriseSite - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.HcxEnterpriseSite"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'hcxEnterpriseSiteName': self._serialize.url("hcx_enterprise_site_name", hcx_enterprise_site_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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.HcxEnterpriseSite] + + request = build_get_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + hcx_enterprise_site_name=hcx_enterprise_site_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 - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('HcxEnterpriseSite', pipeline_response) + deserialized = self._deserialize("HcxEnterpriseSite", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/hcxEnterpriseSites/{hcxEnterpriseSiteName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/hcxEnterpriseSites/{hcxEnterpriseSiteName}"} # type: ignore + + @overload def create_or_update( self, - resource_group_name, # type: str - private_cloud_name, # type: str - hcx_enterprise_site_name, # type: str - hcx_enterprise_site, # type: "_models.HcxEnterpriseSite" - **kwargs # type: Any - ): - # type: (...) -> "_models.HcxEnterpriseSite" + resource_group_name: str, + private_cloud_name: str, + hcx_enterprise_site_name: str, + hcx_enterprise_site: _models.HcxEnterpriseSite, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.HcxEnterpriseSite: """Create or update an HCX Enterprise Site in a private cloud. Create or update an HCX Enterprise Site in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: The name of the private cloud. + :param private_cloud_name: The name of the private cloud. Required. :type private_cloud_name: str :param hcx_enterprise_site_name: Name of the HCX Enterprise Site in the private cloud. + Required. :type hcx_enterprise_site_name: str - :param hcx_enterprise_site: The HCX Enterprise Site. + :param hcx_enterprise_site: The HCX Enterprise Site. Required. :type hcx_enterprise_site: ~azure.mgmt.avs.models.HcxEnterpriseSite + :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: HcxEnterpriseSite, or the result of cls(response) + :return: HcxEnterpriseSite or the result of cls(response) :rtype: ~azure.mgmt.avs.models.HcxEnterpriseSite - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + private_cloud_name: str, + hcx_enterprise_site_name: str, + hcx_enterprise_site: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.HcxEnterpriseSite: + """Create or update an HCX Enterprise Site in a private cloud. + + Create or update an HCX Enterprise Site in a private cloud. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: The name of the private cloud. Required. + :type private_cloud_name: str + :param hcx_enterprise_site_name: Name of the HCX Enterprise Site in the private cloud. + Required. + :type hcx_enterprise_site_name: str + :param hcx_enterprise_site: The HCX Enterprise Site. Required. + :type hcx_enterprise_site: 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: HcxEnterpriseSite or the result of cls(response) + :rtype: ~azure.mgmt.avs.models.HcxEnterpriseSite + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + private_cloud_name: str, + hcx_enterprise_site_name: str, + hcx_enterprise_site: Union[_models.HcxEnterpriseSite, IO], + **kwargs: Any + ) -> _models.HcxEnterpriseSite: + """Create or update an HCX Enterprise Site in a private cloud. + + Create or update an HCX Enterprise Site in a private cloud. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: The name of the private cloud. Required. + :type private_cloud_name: str + :param hcx_enterprise_site_name: Name of the HCX Enterprise Site in the private cloud. + Required. + :type hcx_enterprise_site_name: str + :param hcx_enterprise_site: The HCX Enterprise Site. Is either a model type or a IO type. + Required. + :type hcx_enterprise_site: ~azure.mgmt.avs.models.HcxEnterpriseSite 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: HcxEnterpriseSite or the result of cls(response) + :rtype: ~azure.mgmt.avs.models.HcxEnterpriseSite + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.HcxEnterpriseSite"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'hcxEnterpriseSiteName': self._serialize.url("hcx_enterprise_site_name", hcx_enterprise_site_name, 'str'), - } - url = self._client.format_url(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(hcx_enterprise_site, 'HcxEnterpriseSite') - 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) + 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.HcxEnterpriseSite] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(hcx_enterprise_site, (IO, bytes)): + _content = hcx_enterprise_site + else: + _json = self._serialize.body(hcx_enterprise_site, "HcxEnterpriseSite") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + hcx_enterprise_site_name=hcx_enterprise_site_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.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]: @@ -253,68 +512,70 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('HcxEnterpriseSite', pipeline_response) + deserialized = self._deserialize("HcxEnterpriseSite", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('HcxEnterpriseSite', pipeline_response) + deserialized = self._deserialize("HcxEnterpriseSite", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/hcxEnterpriseSites/{hcxEnterpriseSiteName}'} # type: ignore - def delete( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - hcx_enterprise_site_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/hcxEnterpriseSites/{hcxEnterpriseSiteName}"} # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, private_cloud_name: str, hcx_enterprise_site_name: str, **kwargs: Any + ) -> None: """Delete an HCX Enterprise Site in a private cloud. Delete an HCX Enterprise Site in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :param hcx_enterprise_site_name: Name of the HCX Enterprise Site in the private cloud. + Required. :type hcx_enterprise_site_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 = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'hcxEnterpriseSiteName': self._serialize.url("hcx_enterprise_site_name", hcx_enterprise_site_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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, + private_cloud_name=private_cloud_name, + hcx_enterprise_site_name=hcx_enterprise_site_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 - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -324,4 +585,4 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/hcxEnterpriseSites/{hcxEnterpriseSiteName}'} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/hcxEnterpriseSites/{hcxEnterpriseSiteName}"} # type: ignore diff --git a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_locations_operations.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_locations_operations.py index 2228c4fa769c..f53e4b20fb28 100644 --- a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_locations_operations.py +++ b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_locations_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,151 +6,279 @@ # 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 typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) 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 -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False -class LocationsOperations(object): - """LocationsOperations 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_check_trial_availability_request(location: str, 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.avs.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-05-01")) # 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}/providers/Microsoft.AVS/locations/{location}/checkTrialAvailability", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "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_check_quota_availability_request(location: 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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.AVS/locations/{location}/checkQuotaAvailability", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "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) + + +class LocationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.avs.AVSClient`'s + :attr:`locations` 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 check_trial_availability( - self, - location, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Trial" + self, location: str, sku: Optional[_models.Sku] = None, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.Trial: """Return trial status for subscription by region. - :param location: Azure region. + :param location: Azure region. Required. :type location: str + :param sku: The sku to check for trial availability. Default value is None. + :type sku: ~azure.mgmt.avs.models.Sku + :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: Trial, or the result of cls(response) + :return: Trial or the result of cls(response) :rtype: ~azure.mgmt.avs.models.Trial - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_trial_availability( + self, location: str, sku: Optional[IO] = None, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.Trial: + """Return trial status for subscription by region. + + :param location: Azure region. Required. + :type location: str + :param sku: The sku to check for trial availability. Default value is None. + :type sku: 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: Trial or the result of cls(response) + :rtype: ~azure.mgmt.avs.models.Trial + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_trial_availability( + self, location: str, sku: Optional[Union[_models.Sku, IO]] = None, **kwargs: Any + ) -> _models.Trial: + """Return trial status for subscription by region. + + :param location: Azure region. Required. + :type location: str + :param sku: The sku to check for trial availability. Is either a model type or a IO type. + Default value is None. + :type sku: ~azure.mgmt.avs.models.Sku 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: Trial or the result of cls(response) + :rtype: ~azure.mgmt.avs.models.Trial + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Trial"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.check_trial_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'location': self._serialize.url("location", location, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + 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.Trial] - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(sku, (IO, bytes)): + _content = sku + else: + if sku is not None: + _json = self._serialize.body(sku, "Sku") + else: + _json = None - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_check_trial_availability_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.check_trial_availability.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 + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Trial', pipeline_response) + deserialized = self._deserialize("Trial", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_trial_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.AVS/locations/{location}/checkTrialAvailability'} # type: ignore - - def check_quota_availability( - self, - location, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Quota" + + check_trial_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AVS/locations/{location}/checkTrialAvailability"} # type: ignore + + @distributed_trace + def check_quota_availability(self, location: str, **kwargs: Any) -> _models.Quota: """Return quota for subscription by region. - :param location: Azure region. + :param location: Azure region. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Quota, or the result of cls(response) + :return: Quota or the result of cls(response) :rtype: ~azure.mgmt.avs.models.Quota - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Quota"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.check_quota_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'location': self._serialize.url("location", location, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, '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.Quota] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_check_quota_availability_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.check_quota_availability.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 + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Quota', pipeline_response) + deserialized = self._deserialize("Quota", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_quota_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.AVS/locations/{location}/checkQuotaAvailability'} # type: ignore + + check_quota_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AVS/locations/{location}/checkQuotaAvailability"} # type: ignore diff --git a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_operations.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_operations.py index 3eac2fb43b68..7871df56a898 100644 --- a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_operations.py +++ b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/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,129 @@ # 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 +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") -class Operations(object): - """Operations operations. + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.AVS/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.avs.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.avs.AVSClient`'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.OperationList"] + 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"]: """Lists all of the available operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.avs.models.OperationList] - :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.avs.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationList"] + _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.OperationList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - request = 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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('OperationList', pipeline_response) + deserialized = self._deserialize("OperationList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -94,7 +137,9 @@ 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]: @@ -103,7 +148,6 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.AVS/operations'} # type: ignore + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.AVS/operations"} # type: ignore diff --git a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_patch.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/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/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_placement_policies_operations.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_placement_policies_operations.py index 29456e8a91cc..d5110c51b55b 100644 --- a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_placement_policies_operations.py +++ b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_placement_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,107 +6,327 @@ # 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 +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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_list_request( + resource_group_name: str, private_cloud_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/placementPolicies", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_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_get_request( + resource_group_name: str, + private_cloud_name: str, + cluster_name: str, + placement_policy_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/placementPolicies/{placementPolicyName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "placementPolicyName": _SERIALIZER.url("placement_policy_name", placement_policy_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_create_or_update_request( + resource_group_name: str, + private_cloud_name: str, + cluster_name: str, + placement_policy_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-05-01")) # 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.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/placementPolicies/{placementPolicyName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "placementPolicyName": _SERIALIZER.url("placement_policy_name", placement_policy_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, + private_cloud_name: str, + cluster_name: str, + placement_policy_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-05-01")) # 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.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/placementPolicies/{placementPolicyName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "placementPolicyName": _SERIALIZER.url("placement_policy_name", placement_policy_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, + private_cloud_name: str, + cluster_name: str, + placement_policy_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/placementPolicies/{placementPolicyName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "placementPolicyName": _SERIALIZER.url("placement_policy_name", placement_policy_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) + + +class PlacementPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -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]] - -class PlacementPoliciesOperations(object): - """PlacementPoliciesOperations 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. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.avs.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.avs.AVSClient`'s + :attr:`placement_policies` 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") + @distributed_trace def list( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - cluster_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PlacementPoliciesList"] + self, resource_group_name: str, private_cloud_name: str, cluster_name: str, **kwargs: Any + ) -> Iterable["_models.PlacementPolicy"]: """List placement policies in a private cloud cluster. List placement policies in a private cloud cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param cluster_name: Name of the cluster in the private cloud. + :param cluster_name: Name of the cluster in the private cloud. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PlacementPoliciesList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.avs.models.PlacementPoliciesList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either PlacementPolicy or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.avs.models.PlacementPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PlacementPoliciesList"] + _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.PlacementPoliciesList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + cluster_name=cluster_name, + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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('PlacementPoliciesList', pipeline_response) + deserialized = self._deserialize("PlacementPoliciesList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -114,7 +335,9 @@ 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]: @@ -123,125 +346,138 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/placementPolicies'} # type: ignore + return ItemPaged(get_next, extract_data) + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/placementPolicies"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - private_cloud_name, # type: str - cluster_name, # type: str - placement_policy_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PlacementPolicy" + resource_group_name: str, + private_cloud_name: str, + cluster_name: str, + placement_policy_name: str, + **kwargs: Any + ) -> _models.PlacementPolicy: """Get a placement policy by name in a private cloud cluster. Get a placement policy by name in a private cloud cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param cluster_name: Name of the cluster in the private cloud. + :param cluster_name: Name of the cluster in the private cloud. Required. :type cluster_name: str :param placement_policy_name: Name of the VMware vSphere Distributed Resource Scheduler (DRS) - placement policy. + placement policy. Required. :type placement_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PlacementPolicy, or the result of cls(response) + :return: PlacementPolicy or the result of cls(response) :rtype: ~azure.mgmt.avs.models.PlacementPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PlacementPolicy"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'placementPolicyName': self._serialize.url("placement_policy_name", placement_policy_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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.PlacementPolicy] + + request = build_get_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + cluster_name=cluster_name, + placement_policy_name=placement_policy_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 - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PlacementPolicy', pipeline_response) + deserialized = self._deserialize("PlacementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/placementPolicies/{placementPolicyName}'} # type: ignore + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/placementPolicies/{placementPolicyName}"} # type: ignore def _create_or_update_initial( self, - resource_group_name, # type: str - private_cloud_name, # type: str - cluster_name, # type: str - placement_policy_name, # type: str - placement_policy, # type: "_models.PlacementPolicy" - **kwargs # type: Any - ): - # type: (...) -> "_models.PlacementPolicy" - cls = kwargs.pop('cls', None) # type: ClsType["_models.PlacementPolicy"] + resource_group_name: str, + private_cloud_name: str, + cluster_name: str, + placement_policy_name: str, + placement_policy: Union[_models.PlacementPolicy, IO], + **kwargs: Any + ) -> _models.PlacementPolicy: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'placementPolicyName': self._serialize.url("placement_policy_name", placement_policy_name, 'str'), - } - url = self._client.format_url(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(placement_policy, 'PlacementPolicy') - 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) + 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.PlacementPolicy] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(placement_policy, (IO, bytes)): + _content = placement_policy + else: + _json = self._serialize.body(placement_policy, "PlacementPolicy") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + cluster_name=cluster_name, + placement_policy_name=placement_policy_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]: @@ -249,146 +485,252 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PlacementPolicy', pipeline_response) + deserialized = self._deserialize("PlacementPolicy", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PlacementPolicy', pipeline_response) + deserialized = self._deserialize("PlacementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/placementPolicies/{placementPolicyName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/placementPolicies/{placementPolicyName}"} # type: ignore + + @overload def begin_create_or_update( self, - resource_group_name, # type: str - private_cloud_name, # type: str - cluster_name, # type: str - placement_policy_name, # type: str - placement_policy, # type: "_models.PlacementPolicy" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.PlacementPolicy"] + resource_group_name: str, + private_cloud_name: str, + cluster_name: str, + placement_policy_name: str, + placement_policy: _models.PlacementPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PlacementPolicy]: """Create or update a placement policy in a private cloud cluster. Create or update a placement policy in a private cloud cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param cluster_name: Name of the cluster in the private cloud. + :param cluster_name: Name of the cluster in the private cloud. Required. :type cluster_name: str :param placement_policy_name: Name of the VMware vSphere Distributed Resource Scheduler (DRS) - placement policy. + placement policy. Required. :type placement_policy_name: str - :param placement_policy: A placement policy in the private cloud cluster. + :param placement_policy: A placement policy in the private cloud cluster. Required. :type placement_policy: ~azure.mgmt.avs.models.PlacementPolicy + :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 PlacementPolicy 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 PlacementPolicy or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.PlacementPolicy] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PlacementPolicy"] - 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, + private_cloud_name: str, + cluster_name: str, + placement_policy_name: str, + placement_policy: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PlacementPolicy]: + """Create or update a placement policy in a private cloud cluster. + + Create or update a placement policy in a private cloud cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param cluster_name: Name of the cluster in the private cloud. Required. + :type cluster_name: str + :param placement_policy_name: Name of the VMware vSphere Distributed Resource Scheduler (DRS) + placement policy. Required. + :type placement_policy_name: str + :param placement_policy: A placement policy in the private cloud cluster. Required. + :type placement_policy: 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 PlacementPolicy or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.PlacementPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + private_cloud_name: str, + cluster_name: str, + placement_policy_name: str, + placement_policy: Union[_models.PlacementPolicy, IO], + **kwargs: Any + ) -> LROPoller[_models.PlacementPolicy]: + """Create or update a placement policy in a private cloud cluster. + + Create or update a placement policy in a private cloud cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param cluster_name: Name of the cluster in the private cloud. Required. + :type cluster_name: str + :param placement_policy_name: Name of the VMware vSphere Distributed Resource Scheduler (DRS) + placement policy. Required. + :type placement_policy_name: str + :param placement_policy: A placement policy in the private cloud cluster. Is either a model + type or a IO type. Required. + :type placement_policy: ~azure.mgmt.avs.models.PlacementPolicy 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 PlacementPolicy or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.PlacementPolicy] + :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.PlacementPolicy] + 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, private_cloud_name=private_cloud_name, cluster_name=cluster_name, placement_policy_name=placement_policy_name, placement_policy=placement_policy, - 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('PlacementPolicy', pipeline_response) - + deserialized = self._deserialize("PlacementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'placementPolicyName': self._serialize.url("placement_policy_name", placement_policy_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_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/placementPolicies/{placementPolicyName}'} # 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.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/placementPolicies/{placementPolicyName}"} # type: ignore def _update_initial( self, - resource_group_name, # type: str - private_cloud_name, # type: str - cluster_name, # type: str - placement_policy_name, # type: str - placement_policy_update, # type: "_models.PlacementPolicyUpdate" - **kwargs # type: Any - ): - # type: (...) -> "_models.PlacementPolicy" - cls = kwargs.pop('cls', None) # type: ClsType["_models.PlacementPolicy"] + resource_group_name: str, + private_cloud_name: str, + cluster_name: str, + placement_policy_name: str, + placement_policy_update: Union[_models.PlacementPolicyUpdate, IO], + **kwargs: Any + ) -> _models.PlacementPolicy: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'placementPolicyName': self._serialize.url("placement_policy_name", placement_policy_name, 'str'), - } - url = self._client.format_url(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(placement_policy_update, 'PlacementPolicyUpdate') - 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) + 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.PlacementPolicy] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(placement_policy_update, (IO, bytes)): + _content = placement_policy_update + else: + _json = self._serialize.body(placement_policy_update, "PlacementPolicyUpdate") + + request = build_update_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + cluster_name=cluster_name, + placement_policy_name=placement_policy_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, 202]: @@ -396,140 +738,239 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PlacementPolicy', pipeline_response) + deserialized = self._deserialize("PlacementPolicy", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('PlacementPolicy', pipeline_response) + deserialized = self._deserialize("PlacementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/placementPolicies/{placementPolicyName}'} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/placementPolicies/{placementPolicyName}"} # type: ignore + + @overload def begin_update( self, - resource_group_name, # type: str - private_cloud_name, # type: str - cluster_name, # type: str - placement_policy_name, # type: str - placement_policy_update, # type: "_models.PlacementPolicyUpdate" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.PlacementPolicy"] + resource_group_name: str, + private_cloud_name: str, + cluster_name: str, + placement_policy_name: str, + placement_policy_update: _models.PlacementPolicyUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PlacementPolicy]: """Update a placement policy in a private cloud cluster. Update a placement policy in a private cloud cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param cluster_name: Name of the cluster in the private cloud. + :param cluster_name: Name of the cluster in the private cloud. Required. :type cluster_name: str :param placement_policy_name: Name of the VMware vSphere Distributed Resource Scheduler (DRS) - placement policy. + placement policy. Required. :type placement_policy_name: str - :param placement_policy_update: The placement policy properties that may be updated. + :param placement_policy_update: The placement policy properties that may be updated. Required. :type placement_policy_update: ~azure.mgmt.avs.models.PlacementPolicyUpdate + :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 PlacementPolicy 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 PlacementPolicy or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.PlacementPolicy] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PlacementPolicy"] - 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, + private_cloud_name: str, + cluster_name: str, + placement_policy_name: str, + placement_policy_update: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PlacementPolicy]: + """Update a placement policy in a private cloud cluster. + + Update a placement policy in a private cloud cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param cluster_name: Name of the cluster in the private cloud. Required. + :type cluster_name: str + :param placement_policy_name: Name of the VMware vSphere Distributed Resource Scheduler (DRS) + placement policy. Required. + :type placement_policy_name: str + :param placement_policy_update: The placement policy properties that may be updated. Required. + :type placement_policy_update: 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 PlacementPolicy or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.PlacementPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + private_cloud_name: str, + cluster_name: str, + placement_policy_name: str, + placement_policy_update: Union[_models.PlacementPolicyUpdate, IO], + **kwargs: Any + ) -> LROPoller[_models.PlacementPolicy]: + """Update a placement policy in a private cloud cluster. + + Update a placement policy in a private cloud cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param cluster_name: Name of the cluster in the private cloud. Required. + :type cluster_name: str + :param placement_policy_name: Name of the VMware vSphere Distributed Resource Scheduler (DRS) + placement policy. Required. + :type placement_policy_name: str + :param placement_policy_update: The placement policy properties that may be updated. Is either + a model type or a IO type. Required. + :type placement_policy_update: ~azure.mgmt.avs.models.PlacementPolicyUpdate 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 PlacementPolicy or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.PlacementPolicy] + :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.PlacementPolicy] + 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, private_cloud_name=private_cloud_name, cluster_name=cluster_name, placement_policy_name=placement_policy_name, placement_policy_update=placement_policy_update, - 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('PlacementPolicy', pipeline_response) - + deserialized = self._deserialize("PlacementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'placementPolicyName': self._serialize.url("placement_policy_name", placement_policy_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.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/placementPolicies/{placementPolicyName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def _delete_initial( + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/placementPolicies/{placementPolicyName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - private_cloud_name, # type: str - cluster_name, # type: str - placement_policy_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + resource_group_name: str, + private_cloud_name: str, + cluster_name: str, + placement_policy_name: str, + **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'placementPolicyName': self._serialize.url("placement_policy_name", placement_policy_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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, + private_cloud_name=private_cloud_name, + cluster_name=cluster_name, + placement_policy_name=placement_policy_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 - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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]: @@ -539,82 +980,82 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/placementPolicies/{placementPolicyName}'} # type: ignore + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/placementPolicies/{placementPolicyName}"} # type: ignore + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - private_cloud_name, # type: str - cluster_name, # type: str - placement_policy_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + private_cloud_name: str, + cluster_name: str, + placement_policy_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Delete a placement policy in a private cloud cluster. Delete a placement policy in a private cloud cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param cluster_name: Name of the cluster in the private cloud. + :param cluster_name: Name of the cluster in the private cloud. Required. :type cluster_name: str :param placement_policy_name: Name of the VMware vSphere Distributed Resource Scheduler (DRS) - placement policy. + placement policy. Required. :type placement_policy_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, private_cloud_name=private_cloud_name, cluster_name=cluster_name, placement_policy_name=placement_policy_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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'placementPolicyName': self._serialize.url("placement_policy_name", placement_policy_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.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/placementPolicies/{placementPolicyName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/placementPolicies/{placementPolicyName}"} # type: ignore diff --git a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_private_clouds_operations.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_private_clouds_operations.py index 3085e8a1d2a7..f897147cd403 100644 --- a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_private_clouds_operations.py +++ b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_private_clouds_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,99 +6,410 @@ # 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 +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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_list_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _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_in_subscription_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AVS/privateClouds") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _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_get_request( + resource_group_name: str, private_cloud_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_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_create_or_update_request( + resource_group_name: str, private_cloud_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-05-01")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[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.AVS/privateClouds/{privateCloudName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_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") -class PrivateCloudsOperations(object): - """PrivateCloudsOperations operations. + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) - 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. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.avs.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_update_request( + resource_group_name: str, private_cloud_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-05-01")) # 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.AVS/privateClouds/{privateCloudName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_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, private_cloud_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_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_rotate_vcenter_password_request( + resource_group_name: str, private_cloud_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/rotateVcenterPassword", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_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_rotate_nsxt_password_request( + resource_group_name: str, private_cloud_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/rotateNsxtPassword", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_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_admin_credentials_request( + resource_group_name: str, private_cloud_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/listAdminCredentials", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_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) + + +class PrivateCloudsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.avs.AVSClient`'s + :attr:`private_clouds` 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 list( - self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PrivateCloudList"] + @distributed_trace + def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.PrivateCloud"]: """List private clouds in a resource group. List private clouds in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 PrivateCloudList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.avs.models.PrivateCloudList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either PrivateCloud or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.avs.models.PrivateCloud] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateCloudList"] + _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.PrivateCloudList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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('PrivateCloudList', pipeline_response) + deserialized = self._deserialize("PrivateCloudList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -106,7 +418,9 @@ 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]: @@ -115,58 +429,68 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds'} # type: ignore + return ItemPaged(get_next, extract_data) - def list_in_subscription( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PrivateCloudList"] + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds"} # type: ignore + + @distributed_trace + def list_in_subscription(self, **kwargs: Any) -> Iterable["_models.PrivateCloud"]: """List private clouds in a subscription. List private clouds 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 PrivateCloudList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.avs.models.PrivateCloudList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either PrivateCloud or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.avs.models.PrivateCloud] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateCloudList"] + _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.PrivateCloudList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_in_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_in_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_in_subscription.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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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('PrivateCloudList', pipeline_response) + deserialized = self._deserialize("PrivateCloudList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -175,7 +499,9 @@ 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]: @@ -184,112 +510,120 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_in_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.AVS/privateClouds'} # type: ignore + return ItemPaged(get_next, extract_data) - def get( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PrivateCloud" + list_in_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AVS/privateClouds"} # type: ignore + + @distributed_trace + def get(self, resource_group_name: str, private_cloud_name: str, **kwargs: Any) -> _models.PrivateCloud: """Get a private cloud. Get a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateCloud, or the result of cls(response) + :return: PrivateCloud or the result of cls(response) :rtype: ~azure.mgmt.avs.models.PrivateCloud - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateCloud"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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.PrivateCloud] + + request = build_get_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_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 - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateCloud', pipeline_response) + deserialized = self._deserialize("PrivateCloud", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}'} # type: ignore + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}"} # type: ignore def _create_or_update_initial( self, - resource_group_name, # type: str - private_cloud_name, # type: str - private_cloud, # type: "_models.PrivateCloud" - **kwargs # type: Any - ): - # type: (...) -> "_models.PrivateCloud" - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateCloud"] + resource_group_name: str, + private_cloud_name: str, + private_cloud: Union[_models.PrivateCloud, IO], + **kwargs: Any + ) -> _models.PrivateCloud: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(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(private_cloud, 'PrivateCloud') - 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) + 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.PrivateCloud] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_cloud, (IO, bytes)): + _content = private_cloud + else: + _json = self._serialize.body(private_cloud, "PrivateCloud") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_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]: @@ -297,131 +631,224 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateCloud', pipeline_response) + deserialized = self._deserialize("PrivateCloud", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateCloud', pipeline_response) + deserialized = self._deserialize("PrivateCloud", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}"} # type: ignore + + @overload def begin_create_or_update( self, - resource_group_name, # type: str - private_cloud_name, # type: str - private_cloud, # type: "_models.PrivateCloud" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.PrivateCloud"] + resource_group_name: str, + private_cloud_name: str, + private_cloud: _models.PrivateCloud, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateCloud]: """Create or update a private cloud. Create or update a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param private_cloud: The private cloud. + :param private_cloud: The private cloud. Required. :type private_cloud: ~azure.mgmt.avs.models.PrivateCloud + :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 PrivateCloud 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 PrivateCloud or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.PrivateCloud] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateCloud"] - 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, + private_cloud_name: str, + private_cloud: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateCloud]: + """Create or update a private cloud. + + Create or update a private cloud. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param private_cloud: The private cloud. Required. + :type private_cloud: 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 PrivateCloud or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.PrivateCloud] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + private_cloud_name: str, + private_cloud: Union[_models.PrivateCloud, IO], + **kwargs: Any + ) -> LROPoller[_models.PrivateCloud]: + """Create or update a private cloud. + + Create or update a private cloud. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param private_cloud: The private cloud. Is either a model type or a IO type. Required. + :type private_cloud: ~azure.mgmt.avs.models.PrivateCloud 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 PrivateCloud or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.PrivateCloud] + :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.PrivateCloud] + 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, private_cloud_name=private_cloud_name, private_cloud=private_cloud, - 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('PrivateCloud', pipeline_response) - + deserialized = self._deserialize("PrivateCloud", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_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_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}'} # 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.AVS/privateClouds/{privateCloudName}"} # type: ignore def _update_initial( self, - resource_group_name, # type: str - private_cloud_name, # type: str - private_cloud_update, # type: "_models.PrivateCloudUpdate" - **kwargs # type: Any - ): - # type: (...) -> "_models.PrivateCloud" - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateCloud"] + resource_group_name: str, + private_cloud_name: str, + private_cloud_update: Union[_models.PrivateCloudUpdate, IO], + **kwargs: Any + ) -> _models.PrivateCloud: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(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(private_cloud_update, 'PrivateCloudUpdate') - 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) + 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.PrivateCloud] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_cloud_update, (IO, bytes)): + _content = private_cloud_update + else: + _json = self._serialize.body(private_cloud_update, "PrivateCloudUpdate") + + request = build_update_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_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]: @@ -429,125 +856,209 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateCloud', pipeline_response) + deserialized = self._deserialize("PrivateCloud", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateCloud', pipeline_response) + deserialized = self._deserialize("PrivateCloud", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}'} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}"} # type: ignore + + @overload def begin_update( self, - resource_group_name, # type: str - private_cloud_name, # type: str - private_cloud_update, # type: "_models.PrivateCloudUpdate" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.PrivateCloud"] + resource_group_name: str, + private_cloud_name: str, + private_cloud_update: _models.PrivateCloudUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateCloud]: """Update a private cloud. Update a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param private_cloud_update: The private cloud properties to be updated. + :param private_cloud_update: The private cloud properties to be updated. Required. :type private_cloud_update: ~azure.mgmt.avs.models.PrivateCloudUpdate + :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 PrivateCloud 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 PrivateCloud or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.PrivateCloud] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateCloud"] - 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, + private_cloud_name: str, + private_cloud_update: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateCloud]: + """Update a private cloud. + + Update a private cloud. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param private_cloud_update: The private cloud properties to be updated. Required. + :type private_cloud_update: 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 PrivateCloud or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.PrivateCloud] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + private_cloud_name: str, + private_cloud_update: Union[_models.PrivateCloudUpdate, IO], + **kwargs: Any + ) -> LROPoller[_models.PrivateCloud]: + """Update a private cloud. + + Update a private cloud. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param private_cloud_update: The private cloud properties to be updated. Is either a model type + or a IO type. Required. + :type private_cloud_update: ~azure.mgmt.avs.models.PrivateCloudUpdate 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 PrivateCloud or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.PrivateCloud] + :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.PrivateCloud] + 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, private_cloud_name=private_cloud_name, private_cloud_update=private_cloud_update, - 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('PrivateCloud', pipeline_response) - + deserialized = self._deserialize("PrivateCloud", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_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.AVS/privateClouds/{privateCloudName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def _delete_initial( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, private_cloud_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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, + private_cloud_name=private_cloud_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 - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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]: @@ -557,109 +1068,105 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}'} # type: ignore + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}"} # type: ignore - def begin_delete( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, resource_group_name: str, private_cloud_name: str, **kwargs: Any) -> LROPoller[None]: """Delete a private cloud. Delete a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_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, private_cloud_name=private_cloud_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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_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.AVS/privateClouds/{privateCloudName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def _rotate_vcenter_password_initial( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}"} # type: ignore + + def _rotate_vcenter_password_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, private_cloud_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self._rotate_vcenter_password_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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_rotate_vcenter_password_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._rotate_vcenter_password_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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 [202, 204]: @@ -669,109 +1176,107 @@ def _rotate_vcenter_password_initial( if cls: return cls(pipeline_response, None, {}) - _rotate_vcenter_password_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/rotateVcenterPassword'} # type: ignore + _rotate_vcenter_password_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/rotateVcenterPassword"} # type: ignore + @distributed_trace def begin_rotate_vcenter_password( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + self, resource_group_name: str, private_cloud_name: str, **kwargs: Any + ) -> LROPoller[None]: """Rotate the vCenter password. Rotate the vCenter password. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_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._rotate_vcenter_password_initial( + raw_result = self._rotate_vcenter_password_initial( # type: ignore resource_group_name=resource_group_name, private_cloud_name=private_cloud_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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_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_rotate_vcenter_password.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/rotateVcenterPassword'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def _rotate_nsxt_password_initial( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_rotate_vcenter_password.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/rotateVcenterPassword"} # type: ignore + + def _rotate_nsxt_password_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, private_cloud_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self._rotate_nsxt_password_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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_rotate_nsxt_password_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._rotate_nsxt_password_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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 [202, 204]: @@ -781,132 +1286,133 @@ def _rotate_nsxt_password_initial( if cls: return cls(pipeline_response, None, {}) - _rotate_nsxt_password_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/rotateNsxtPassword'} # type: ignore + _rotate_nsxt_password_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/rotateNsxtPassword"} # type: ignore + @distributed_trace def begin_rotate_nsxt_password( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + self, resource_group_name: str, private_cloud_name: str, **kwargs: Any + ) -> LROPoller[None]: """Rotate the NSX-T Manager password. Rotate the NSX-T Manager password. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_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._rotate_nsxt_password_initial( + raw_result = self._rotate_nsxt_password_initial( # type: ignore resource_group_name=resource_group_name, private_cloud_name=private_cloud_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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_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_rotate_nsxt_password.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/rotateNsxtPassword'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_rotate_nsxt_password.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/rotateNsxtPassword"} # type: ignore + @distributed_trace def list_admin_credentials( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AdminCredentials" + self, resource_group_name: str, private_cloud_name: str, **kwargs: Any + ) -> _models.AdminCredentials: """List the admin credentials for the private cloud. List the admin credentials for the private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AdminCredentials, or the result of cls(response) + :return: AdminCredentials or the result of cls(response) :rtype: ~azure.mgmt.avs.models.AdminCredentials - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AdminCredentials"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.list_admin_credentials.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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.AdminCredentials] + + request = build_list_admin_credentials_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_admin_credentials.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('AdminCredentials', pipeline_response) + deserialized = self._deserialize("AdminCredentials", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_admin_credentials.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/listAdminCredentials'} # type: ignore + + list_admin_credentials.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/listAdminCredentials"} # type: ignore diff --git a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_script_cmdlets_operations.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_script_cmdlets_operations.py index 554fa942fbbd..f4089d9c4d67 100644 --- a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_script_cmdlets_operations.py +++ b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_script_cmdlets_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,104 +6,198 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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 -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False -class ScriptCmdletsOperations(object): - """ScriptCmdletsOperations 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( + resource_group_name: str, private_cloud_name: str, script_package_name: str, 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.avs.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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptPackages/{scriptPackageName}/scriptCmdlets", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "scriptPackageName": _SERIALIZER.url("script_package_name", script_package_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_get_request( + resource_group_name: str, + private_cloud_name: str, + script_package_name: str, + script_cmdlet_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptPackages/{scriptPackageName}/scriptCmdlets/{scriptCmdletName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "scriptPackageName": _SERIALIZER.url("script_package_name", script_package_name, "str"), + "scriptCmdletName": _SERIALIZER.url("script_cmdlet_name", script_cmdlet_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 ScriptCmdletsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.avs.AVSClient`'s + :attr:`script_cmdlets` 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") + @distributed_trace def list( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - script_package_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ScriptCmdletsList"] + self, resource_group_name: str, private_cloud_name: str, script_package_name: str, **kwargs: Any + ) -> Iterable["_models.ScriptCmdlet"]: """List script cmdlet resources available for a private cloud to create a script execution resource on a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param script_package_name: Name of the script package in the private cloud. + :param script_package_name: Name of the script package in the private cloud. Required. :type script_package_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ScriptCmdletsList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.avs.models.ScriptCmdletsList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ScriptCmdlet or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.avs.models.ScriptCmdlet] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScriptCmdletsList"] + _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.ScriptCmdletsList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'scriptPackageName': self._serialize.url("script_package_name", script_package_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + script_package_name=script_package_name, + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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('ScriptCmdletsList', pipeline_response) + deserialized = self._deserialize("ScriptCmdletsList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -111,7 +206,9 @@ 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]: @@ -120,75 +217,79 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptPackages/{scriptPackageName}/scriptCmdlets'} # type: ignore + return ItemPaged(get_next, extract_data) + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptPackages/{scriptPackageName}/scriptCmdlets"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - private_cloud_name, # type: str - script_package_name, # type: str - script_cmdlet_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ScriptCmdlet" + resource_group_name: str, + private_cloud_name: str, + script_package_name: str, + script_cmdlet_name: str, + **kwargs: Any + ) -> _models.ScriptCmdlet: """Return information about a script cmdlet resource in a specific package on a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param script_package_name: Name of the script package in the private cloud. + :param script_package_name: Name of the script package in the private cloud. Required. :type script_package_name: str :param script_cmdlet_name: Name of the script cmdlet resource in the script package in the - private cloud. + private cloud. Required. :type script_cmdlet_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScriptCmdlet, or the result of cls(response) + :return: ScriptCmdlet or the result of cls(response) :rtype: ~azure.mgmt.avs.models.ScriptCmdlet - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScriptCmdlet"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'scriptPackageName': self._serialize.url("script_package_name", script_package_name, 'str'), - 'scriptCmdletName': self._serialize.url("script_cmdlet_name", script_cmdlet_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # 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.ScriptCmdlet] + + request = build_get_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + script_package_name=script_package_name, + script_cmdlet_name=script_cmdlet_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 + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ScriptCmdlet', pipeline_response) + deserialized = self._deserialize("ScriptCmdlet", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptPackages/{scriptPackageName}/scriptCmdlets/{scriptCmdletName}'} # type: ignore + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptPackages/{scriptPackageName}/scriptCmdlets/{scriptCmdletName}"} # type: ignore diff --git a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_script_executions_operations.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_script_executions_operations.py index 25318db5a893..7804c82d678d 100644 --- a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_script_executions_operations.py +++ b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_script_executions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,103 +6,299 @@ # 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, List, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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_list_request( + resource_group_name: str, private_cloud_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptExecutions", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_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_get_request( + resource_group_name: str, private_cloud_name: str, script_execution_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptExecutions/{scriptExecutionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "scriptExecutionName": _SERIALIZER.url("script_execution_name", script_execution_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_create_or_update_request( + resource_group_name: str, private_cloud_name: str, script_execution_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-05-01")) # 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.AVS/privateClouds/{privateCloudName}/scriptExecutions/{scriptExecutionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "scriptExecutionName": _SERIALIZER.url("script_execution_name", script_execution_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_delete_request( + resource_group_name: str, private_cloud_name: str, script_execution_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptExecutions/{scriptExecutionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "scriptExecutionName": _SERIALIZER.url("script_execution_name", script_execution_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_execution_logs_request( + resource_group_name: str, private_cloud_name: str, script_execution_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-05-01")) # 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.AVS/privateClouds/{privateCloudName}/scriptExecutions/{scriptExecutionName}/getExecutionLogs", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "scriptExecutionName": _SERIALIZER.url("script_execution_name", script_execution_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) + + +class ScriptExecutionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class ScriptExecutionsOperations(object): - """ScriptExecutionsOperations 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. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.avs.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.avs.AVSClient`'s + :attr:`script_executions` 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") + @distributed_trace def list( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ScriptExecutionsList"] + self, resource_group_name: str, private_cloud_name: str, **kwargs: Any + ) -> Iterable["_models.ScriptExecution"]: """List script executions in a private cloud. List script executions in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ScriptExecutionsList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.avs.models.ScriptExecutionsList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ScriptExecution or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.avs.models.ScriptExecution] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScriptExecutionsList"] + _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.ScriptExecutionsList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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('ScriptExecutionsList', pipeline_response) + deserialized = self._deserialize("ScriptExecutionsList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,7 +307,9 @@ 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]: @@ -119,118 +318,127 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptExecutions'} # type: ignore + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptExecutions"} # type: ignore + @distributed_trace def get( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - script_execution_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ScriptExecution" + self, resource_group_name: str, private_cloud_name: str, script_execution_name: str, **kwargs: Any + ) -> _models.ScriptExecution: """Get an script execution by name in a private cloud. Get an script execution by name in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param script_execution_name: Name of the user-invoked script execution resource. + :param script_execution_name: Name of the user-invoked script execution resource. Required. :type script_execution_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScriptExecution, or the result of cls(response) + :return: ScriptExecution or the result of cls(response) :rtype: ~azure.mgmt.avs.models.ScriptExecution - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScriptExecution"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'scriptExecutionName': self._serialize.url("script_execution_name", script_execution_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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.ScriptExecution] + + request = build_get_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + script_execution_name=script_execution_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 - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ScriptExecution', pipeline_response) + deserialized = self._deserialize("ScriptExecution", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptExecutions/{scriptExecutionName}'} # type: ignore + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptExecutions/{scriptExecutionName}"} # type: ignore def _create_or_update_initial( self, - resource_group_name, # type: str - private_cloud_name, # type: str - script_execution_name, # type: str - script_execution, # type: "_models.ScriptExecution" - **kwargs # type: Any - ): - # type: (...) -> "_models.ScriptExecution" - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScriptExecution"] + resource_group_name: str, + private_cloud_name: str, + script_execution_name: str, + script_execution: Union[_models.ScriptExecution, IO], + **kwargs: Any + ) -> _models.ScriptExecution: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'scriptExecutionName': self._serialize.url("script_execution_name", script_execution_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(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(script_execution, 'ScriptExecution') - 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) + 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.ScriptExecution] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(script_execution, (IO, bytes)): + _content = script_execution + else: + _json = self._serialize.body(script_execution, "ScriptExecution") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + script_execution_name=script_execution_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]: @@ -238,132 +446,220 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ScriptExecution', pipeline_response) + deserialized = self._deserialize("ScriptExecution", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ScriptExecution', pipeline_response) + deserialized = self._deserialize("ScriptExecution", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptExecutions/{scriptExecutionName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptExecutions/{scriptExecutionName}"} # type: ignore + + @overload def begin_create_or_update( self, - resource_group_name, # type: str - private_cloud_name, # type: str - script_execution_name, # type: str - script_execution, # type: "_models.ScriptExecution" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ScriptExecution"] + resource_group_name: str, + private_cloud_name: str, + script_execution_name: str, + script_execution: _models.ScriptExecution, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ScriptExecution]: """Create or update a script execution in a private cloud. Create or update a script execution in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: The name of the private cloud. + :param private_cloud_name: The name of the private cloud. Required. :type private_cloud_name: str - :param script_execution_name: Name of the user-invoked script execution resource. + :param script_execution_name: Name of the user-invoked script execution resource. Required. :type script_execution_name: str - :param script_execution: A script running in the private cloud. + :param script_execution: A script running in the private cloud. Required. :type script_execution: ~azure.mgmt.avs.models.ScriptExecution + :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 ScriptExecution 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 ScriptExecution or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.ScriptExecution] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScriptExecution"] - 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, + private_cloud_name: str, + script_execution_name: str, + script_execution: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ScriptExecution]: + """Create or update a script execution in a private cloud. + + Create or update a script execution in a private cloud. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: The name of the private cloud. Required. + :type private_cloud_name: str + :param script_execution_name: Name of the user-invoked script execution resource. Required. + :type script_execution_name: str + :param script_execution: A script running in the private cloud. Required. + :type script_execution: 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 ScriptExecution or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.ScriptExecution] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + private_cloud_name: str, + script_execution_name: str, + script_execution: Union[_models.ScriptExecution, IO], + **kwargs: Any + ) -> LROPoller[_models.ScriptExecution]: + """Create or update a script execution in a private cloud. + + Create or update a script execution in a private cloud. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: The name of the private cloud. Required. + :type private_cloud_name: str + :param script_execution_name: Name of the user-invoked script execution resource. Required. + :type script_execution_name: str + :param script_execution: A script running in the private cloud. Is either a model type or a IO + type. Required. + :type script_execution: ~azure.mgmt.avs.models.ScriptExecution 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 ScriptExecution or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.ScriptExecution] + :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.ScriptExecution] + 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, private_cloud_name=private_cloud_name, script_execution_name=script_execution_name, script_execution=script_execution, - 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('ScriptExecution', pipeline_response) - + deserialized = self._deserialize("ScriptExecution", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'scriptExecutionName': self._serialize.url("script_execution_name", script_execution_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_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptExecutions/{scriptExecutionName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def _delete_initial( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - script_execution_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptExecutions/{scriptExecutionName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, private_cloud_name: str, script_execution_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'scriptExecutionName': self._serialize.url("script_execution_name", script_execution_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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, + private_cloud_name=private_cloud_name, + script_execution_name=script_execution_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 - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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]: @@ -373,151 +669,229 @@ def _delete_initial( if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptExecutions/{scriptExecutionName}'} # type: ignore + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptExecutions/{scriptExecutionName}"} # type: ignore + @distributed_trace def begin_delete( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - script_execution_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + self, resource_group_name: str, private_cloud_name: str, script_execution_name: str, **kwargs: Any + ) -> LROPoller[None]: """Cancel a ScriptExecution in a private cloud. Cancel a ScriptExecution in a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param script_execution_name: Name of the user-invoked script execution resource. + :param script_execution_name: Name of the user-invoked script execution resource. Required. :type script_execution_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, private_cloud_name=private_cloud_name, script_execution_name=script_execution_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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'scriptExecutionName': self._serialize.url("script_execution_name", script_execution_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.AVS/privateClouds/{privateCloudName}/scriptExecutions/{scriptExecutionName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptExecutions/{scriptExecutionName}"} # type: ignore + @overload def get_execution_logs( self, - resource_group_name, # type: str - private_cloud_name, # type: str - script_execution_name, # type: str - script_output_stream_type=None, # type: Optional[List[Union[str, "_models.ScriptOutputStreamType"]]] - **kwargs # type: Any - ): - # type: (...) -> "_models.ScriptExecution" + resource_group_name: str, + private_cloud_name: str, + script_execution_name: str, + script_output_stream_type: Optional[List[Union[str, _models.ScriptOutputStreamType]]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ScriptExecution: """Return the logs for a script execution resource. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param script_execution_name: Name of the user-invoked script execution resource. + :param script_execution_name: Name of the user-invoked script execution resource. Required. :type script_execution_name: str :param script_output_stream_type: Name of the desired output stream to return. If not provided, - will return all. An empty array will return nothing. + will return all. An empty array will return nothing. Default value is None. :type script_output_stream_type: list[str or ~azure.mgmt.avs.models.ScriptOutputStreamType] + :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: ScriptExecution or the result of cls(response) + :rtype: ~azure.mgmt.avs.models.ScriptExecution + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def get_execution_logs( + self, + resource_group_name: str, + private_cloud_name: str, + script_execution_name: str, + script_output_stream_type: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ScriptExecution: + """Return the logs for a script execution resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param script_execution_name: Name of the user-invoked script execution resource. Required. + :type script_execution_name: str + :param script_output_stream_type: Name of the desired output stream to return. If not provided, + will return all. An empty array will return nothing. Default value is None. + :type script_output_stream_type: 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: ScriptExecution, or the result of cls(response) + :return: ScriptExecution or the result of cls(response) :rtype: ~azure.mgmt.avs.models.ScriptExecution - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def get_execution_logs( + self, + resource_group_name: str, + private_cloud_name: str, + script_execution_name: str, + script_output_stream_type: Optional[Union[List[Union[str, _models.ScriptOutputStreamType]], IO]] = None, + **kwargs: Any + ) -> _models.ScriptExecution: + """Return the logs for a script execution resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param script_execution_name: Name of the user-invoked script execution resource. Required. + :type script_execution_name: str + :param script_output_stream_type: Name of the desired output stream to return. If not provided, + will return all. An empty array will return nothing. Is either a list type or a IO type. + Default value is None. + :type script_output_stream_type: list[str or ~azure.mgmt.avs.models.ScriptOutputStreamType] 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: ScriptExecution or the result of cls(response) + :rtype: ~azure.mgmt.avs.models.ScriptExecution + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScriptExecution"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.get_execution_logs.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'scriptExecutionName': self._serialize.url("script_execution_name", script_execution_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # 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') + 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.ScriptExecution] - body_content_kwargs = {} # type: Dict[str, Any] - if script_output_stream_type is not None: - body_content = self._serialize.body(script_output_stream_type, '[str]') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(script_output_stream_type, (IO, bytes)): + _content = script_output_stream_type 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 script_output_stream_type is not None: + _json = self._serialize.body(script_output_stream_type, "[str]") + else: + _json = None + + request = build_get_execution_logs_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + script_execution_name=script_execution_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.get_execution_logs.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) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ScriptExecution', pipeline_response) + deserialized = self._deserialize("ScriptExecution", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_execution_logs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptExecutions/{scriptExecutionName}/getExecutionLogs'} # type: ignore + + get_execution_logs.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptExecutions/{scriptExecutionName}/getExecutionLogs"} # type: ignore diff --git a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_script_packages_operations.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_script_packages_operations.py index 3b6f1cc8d54b..d66b165a24f2 100644 --- a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_script_packages_operations.py +++ b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_script_packages_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,99 +6,187 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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 -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False -class ScriptPackagesOperations(object): - """ScriptPackagesOperations 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( + resource_group_name: str, private_cloud_name: str, 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.avs.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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptPackages", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_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_get_request( + resource_group_name: str, private_cloud_name: str, script_package_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptPackages/{scriptPackageName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "scriptPackageName": _SERIALIZER.url("script_package_name", script_package_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 ScriptPackagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.avs.AVSClient`'s + :attr:`script_packages` 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") + @distributed_trace def list( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ScriptPackagesList"] + self, resource_group_name: str, private_cloud_name: str, **kwargs: Any + ) -> Iterable["_models.ScriptPackage"]: """List script packages available to run on the private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ScriptPackagesList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.avs.models.ScriptPackagesList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ScriptPackage or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.avs.models.ScriptPackage] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScriptPackagesList"] + _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.ScriptPackagesList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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('ScriptPackagesList', pipeline_response) + deserialized = self._deserialize("ScriptPackagesList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -106,7 +195,9 @@ 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]: @@ -115,70 +206,70 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptPackages'} # type: ignore + return ItemPaged(get_next, extract_data) + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptPackages"} # type: ignore + + @distributed_trace def get( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - script_package_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ScriptPackage" + self, resource_group_name: str, private_cloud_name: str, script_package_name: str, **kwargs: Any + ) -> _models.ScriptPackage: """Get a script package available to run on a private cloud. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param script_package_name: Name of the script package in the private cloud. + :param script_package_name: Name of the script package in the private cloud. Required. :type script_package_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ScriptPackage, or the result of cls(response) + :return: ScriptPackage or the result of cls(response) :rtype: ~azure.mgmt.avs.models.ScriptPackage - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScriptPackage"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'scriptPackageName': self._serialize.url("script_package_name", script_package_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) + error_map.update(kwargs.pop("error_map", {}) or {}) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - # 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.ScriptPackage] + + request = build_get_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + script_package_name=script_package_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 + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ScriptPackage', pipeline_response) + deserialized = self._deserialize("ScriptPackage", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptPackages/{scriptPackageName}'} # type: ignore + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/scriptPackages/{scriptPackageName}"} # type: ignore diff --git a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_virtual_machines_operations.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_virtual_machines_operations.py index 3ce349e773f2..fe41270a07a1 100644 --- a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_virtual_machines_operations.py +++ b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/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,107 +6,244 @@ # 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 +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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_list_request( + resource_group_name: str, private_cloud_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/virtualMachines", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_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_get_request( + resource_group_name: str, + private_cloud_name: str, + cluster_name: str, + virtual_machine_id: 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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/virtualMachines/{virtualMachineId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "virtualMachineId": _SERIALIZER.url("virtual_machine_id", virtual_machine_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_restrict_movement_request( + resource_group_name: str, + private_cloud_name: str, + cluster_name: str, + virtual_machine_id: 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-05-01")) # 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.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/virtualMachines/{virtualMachineId}/restrictMovement", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "virtualMachineId": _SERIALIZER.url("virtual_machine_id", virtual_machine_id, "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) + + +class VirtualMachinesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -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]] - -class VirtualMachinesOperations(object): - """VirtualMachinesOperations 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. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.avs.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.avs.AVSClient`'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") + @distributed_trace def list( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - cluster_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.VirtualMachinesList"] + self, resource_group_name: str, private_cloud_name: str, cluster_name: str, **kwargs: Any + ) -> Iterable["_models.VirtualMachine"]: """List of virtual machines in a private cloud cluster. List of virtual machines in a private cloud cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param cluster_name: Name of the cluster in the private cloud. + :param cluster_name: Name of the cluster in the private cloud. Required. :type cluster_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.avs.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.avs.models.VirtualMachine] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VirtualMachinesList"] + _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.VirtualMachinesList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + cluster_name=cluster_name, + 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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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) @@ -114,7 +252,9 @@ 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]: @@ -123,124 +263,137 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/virtualMachines'} # type: ignore + return ItemPaged(get_next, extract_data) + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/virtualMachines"} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - private_cloud_name, # type: str - cluster_name, # type: str - virtual_machine_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.VirtualMachine" + resource_group_name: str, + private_cloud_name: str, + cluster_name: str, + virtual_machine_id: str, + **kwargs: Any + ) -> _models.VirtualMachine: """Get a virtual machine by id in a private cloud cluster. Get a virtual machine by id in a private cloud cluster. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param cluster_name: Name of the cluster in the private cloud. + :param cluster_name: Name of the cluster in the private cloud. Required. :type cluster_name: str - :param virtual_machine_id: Virtual Machine identifier. + :param virtual_machine_id: Virtual Machine identifier. Required. :type virtual_machine_id: 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.avs.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 = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'virtualMachineId': self._serialize.url("virtual_machine_id", virtual_machine_id, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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, + private_cloud_name=private_cloud_name, + cluster_name=cluster_name, + virtual_machine_id=virtual_machine_id, + 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 - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, 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.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/virtualMachines/{virtualMachineId}'} # type: ignore - def _restrict_movement_initial( + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/virtualMachines/{virtualMachineId}"} # type: ignore + + def _restrict_movement_initial( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - private_cloud_name, # type: str - cluster_name, # type: str - virtual_machine_id, # type: str - restrict_movement, # type: "_models.VirtualMachineRestrictMovement" - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + resource_group_name: str, + private_cloud_name: str, + cluster_name: str, + virtual_machine_id: str, + restrict_movement: Union[_models.VirtualMachineRestrictMovement, IO], + **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._restrict_movement_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'virtualMachineId': self._serialize.url("virtual_machine_id", virtual_machine_id, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(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(restrict_movement, 'VirtualMachineRestrictMovement') - 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) + 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(restrict_movement, (IO, bytes)): + _content = restrict_movement + else: + _json = self._serialize.body(restrict_movement, "VirtualMachineRestrictMovement") + + request = build_restrict_movement_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + cluster_name=cluster_name, + virtual_machine_id=virtual_machine_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._restrict_movement_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 [202]: @@ -250,86 +403,179 @@ def _restrict_movement_initial( if cls: return cls(pipeline_response, None, {}) - _restrict_movement_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/virtualMachines/{virtualMachineId}/restrictMovement'} # type: ignore + _restrict_movement_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/virtualMachines/{virtualMachineId}/restrictMovement"} # type: ignore + @overload def begin_restrict_movement( self, - resource_group_name, # type: str - private_cloud_name, # type: str - cluster_name, # type: str - virtual_machine_id, # type: str - restrict_movement, # type: "_models.VirtualMachineRestrictMovement" - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + private_cloud_name: str, + cluster_name: str, + virtual_machine_id: str, + restrict_movement: _models.VirtualMachineRestrictMovement, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: """Enable or disable DRS-driven VM movement restriction. Enable or disable DRS-driven VM movement restriction. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param cluster_name: Name of the cluster in the private cloud. + :param cluster_name: Name of the cluster in the private cloud. Required. :type cluster_name: str - :param virtual_machine_id: Virtual Machine identifier. + :param virtual_machine_id: Virtual Machine identifier. Required. :type virtual_machine_id: str :param restrict_movement: Whether VM DRS-driven movement is restricted (Enabled) or not - (Disabled). + (Disabled). Required. :type restrict_movement: ~azure.mgmt.avs.models.VirtualMachineRestrictMovement + :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_restrict_movement( + self, + resource_group_name: str, + private_cloud_name: str, + cluster_name: str, + virtual_machine_id: str, + restrict_movement: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Enable or disable DRS-driven VM movement restriction. + + Enable or disable DRS-driven VM movement restriction. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param cluster_name: Name of the cluster in the private cloud. Required. + :type cluster_name: str + :param virtual_machine_id: Virtual Machine identifier. Required. + :type virtual_machine_id: str + :param restrict_movement: Whether VM DRS-driven movement is restricted (Enabled) or not + (Disabled). Required. + :type restrict_movement: 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_restrict_movement( + self, + resource_group_name: str, + private_cloud_name: str, + cluster_name: str, + virtual_machine_id: str, + restrict_movement: Union[_models.VirtualMachineRestrictMovement, IO], + **kwargs: Any + ) -> LROPoller[None]: + """Enable or disable DRS-driven VM movement restriction. + + Enable or disable DRS-driven VM movement restriction. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param cluster_name: Name of the cluster in the private cloud. Required. + :type cluster_name: str + :param virtual_machine_id: Virtual Machine identifier. Required. + :type virtual_machine_id: str + :param restrict_movement: Whether VM DRS-driven movement is restricted (Enabled) or not + (Disabled). Is either a model type or a IO type. Required. + :type restrict_movement: ~azure.mgmt.avs.models.VirtualMachineRestrictMovement 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._restrict_movement_initial( + raw_result = self._restrict_movement_initial( # type: ignore resource_group_name=resource_group_name, private_cloud_name=private_cloud_name, cluster_name=cluster_name, virtual_machine_id=virtual_machine_id, restrict_movement=restrict_movement, - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'virtualMachineId': self._serialize.url("virtual_machine_id", virtual_machine_id, '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_restrict_movement.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/virtualMachines/{virtualMachineId}/restrictMovement'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_restrict_movement.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/clusters/{clusterName}/virtualMachines/{virtualMachineId}/restrictMovement"} # type: ignore diff --git a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_workload_networks_operations.py b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_workload_networks_operations.py index 7e21bcbc2c7f..2dbc3b125ab3 100644 --- a/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_workload_networks_operations.py +++ b/sdk/compute/azure-mgmt-avs/azure/mgmt/avs/operations/_workload_networks_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,103 +6,1679 @@ # 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 +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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_get_request( + resource_group_name: str, + private_cloud_name: str, + workload_network_name: Union[str, _models.WorkloadNetworkName], + 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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/{workloadNetworkName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "workloadNetworkName": _SERIALIZER.url("workload_network_name", workload_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_list_request( + resource_group_name: str, private_cloud_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_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_list_segments_request( + resource_group_name: str, private_cloud_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/segments", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_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_get_segment_request( + resource_group_name: str, private_cloud_name: str, segment_id: 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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/segments/{segmentId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "segmentId": _SERIALIZER.url("segment_id", segment_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_create_segments_request( + resource_group_name: str, private_cloud_name: str, segment_id: 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-05-01")) # 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.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/segments/{segmentId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "segmentId": _SERIALIZER.url("segment_id", segment_id, "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_segments_request( + resource_group_name: str, private_cloud_name: str, segment_id: 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-05-01")) # 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.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/segments/{segmentId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "segmentId": _SERIALIZER.url("segment_id", segment_id, "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_segment_request( + resource_group_name: str, private_cloud_name: str, segment_id: 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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/segments/{segmentId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "segmentId": _SERIALIZER.url("segment_id", segment_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="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_dhcp_request( + resource_group_name: str, private_cloud_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dhcpConfigurations", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_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_get_dhcp_request( + resource_group_name: str, dhcp_id: str, private_cloud_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dhcpConfigurations/{dhcpId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "dhcpId": _SERIALIZER.url("dhcp_id", dhcp_id, "str"), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_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_create_dhcp_request( + resource_group_name: str, private_cloud_name: str, dhcp_id: 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-05-01")) # 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.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dhcpConfigurations/{dhcpId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "dhcpId": _SERIALIZER.url("dhcp_id", dhcp_id, "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_dhcp_request( + resource_group_name: str, private_cloud_name: str, dhcp_id: 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-05-01")) # 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.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dhcpConfigurations/{dhcpId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "dhcpId": _SERIALIZER.url("dhcp_id", dhcp_id, "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_dhcp_request( + resource_group_name: str, private_cloud_name: str, dhcp_id: 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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dhcpConfigurations/{dhcpId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "dhcpId": _SERIALIZER.url("dhcp_id", dhcp_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="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_gateways_request( + resource_group_name: str, private_cloud_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/gateways", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_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_get_gateway_request( + resource_group_name: str, private_cloud_name: str, gateway_id: 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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/gateways/{gatewayId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "gatewayId": _SERIALIZER.url("gateway_id", gateway_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_port_mirroring_request( + resource_group_name: str, private_cloud_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/portMirroringProfiles", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_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_get_port_mirroring_request( + resource_group_name: str, private_cloud_name: str, port_mirroring_id: 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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/portMirroringProfiles/{portMirroringId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "portMirroringId": _SERIALIZER.url("port_mirroring_id", port_mirroring_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_create_port_mirroring_request( + resource_group_name: str, private_cloud_name: str, port_mirroring_id: 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-05-01")) # 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.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/portMirroringProfiles/{portMirroringId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "portMirroringId": _SERIALIZER.url("port_mirroring_id", port_mirroring_id, "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_port_mirroring_request( + resource_group_name: str, private_cloud_name: str, port_mirroring_id: 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-05-01")) # 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.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/portMirroringProfiles/{portMirroringId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "portMirroringId": _SERIALIZER.url("port_mirroring_id", port_mirroring_id, "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_port_mirroring_request( + resource_group_name: str, port_mirroring_id: str, private_cloud_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/portMirroringProfiles/{portMirroringId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "portMirroringId": _SERIALIZER.url("port_mirroring_id", port_mirroring_id, "str"), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_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_vm_groups_request( + resource_group_name: str, private_cloud_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/vmGroups", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_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_get_vm_group_request( + resource_group_name: str, private_cloud_name: str, vm_group_id: 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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/vmGroups/{vmGroupId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "vmGroupId": _SERIALIZER.url("vm_group_id", vm_group_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_create_vm_group_request( + resource_group_name: str, private_cloud_name: str, vm_group_id: 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-05-01")) # 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.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/vmGroups/{vmGroupId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "vmGroupId": _SERIALIZER.url("vm_group_id", vm_group_id, "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_vm_group_request( + resource_group_name: str, private_cloud_name: str, vm_group_id: 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-05-01")) # 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.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/vmGroups/{vmGroupId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "vmGroupId": _SERIALIZER.url("vm_group_id", vm_group_id, "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_vm_group_request( + resource_group_name: str, vm_group_id: str, private_cloud_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/vmGroups/{vmGroupId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "vmGroupId": _SERIALIZER.url("vm_group_id", vm_group_id, "str"), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_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_virtual_machines_request( + resource_group_name: str, private_cloud_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/virtualMachines", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_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_get_virtual_machine_request( + resource_group_name: str, private_cloud_name: str, virtual_machine_id: 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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/virtualMachines/{virtualMachineId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "virtualMachineId": _SERIALIZER.url("virtual_machine_id", virtual_machine_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_dns_services_request( + resource_group_name: str, private_cloud_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsServices", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_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_get_dns_service_request( + resource_group_name: str, private_cloud_name: str, dns_service_id: 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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsServices/{dnsServiceId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "dnsServiceId": _SERIALIZER.url("dns_service_id", dns_service_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_create_dns_service_request( + resource_group_name: str, private_cloud_name: str, dns_service_id: 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-05-01")) # 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.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsServices/{dnsServiceId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "dnsServiceId": _SERIALIZER.url("dns_service_id", dns_service_id, "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_dns_service_request( + resource_group_name: str, private_cloud_name: str, dns_service_id: 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-05-01")) # 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.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsServices/{dnsServiceId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "dnsServiceId": _SERIALIZER.url("dns_service_id", dns_service_id, "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_dns_service_request( + resource_group_name: str, dns_service_id: str, private_cloud_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsServices/{dnsServiceId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "dnsServiceId": _SERIALIZER.url("dns_service_id", dns_service_id, "str"), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_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_dns_zones_request( + resource_group_name: str, private_cloud_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsZones", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_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_get_dns_zone_request( + resource_group_name: str, private_cloud_name: str, dns_zone_id: 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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsZones/{dnsZoneId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "dnsZoneId": _SERIALIZER.url("dns_zone_id", dns_zone_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_create_dns_zone_request( + resource_group_name: str, private_cloud_name: str, dns_zone_id: 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-05-01")) # 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.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsZones/{dnsZoneId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "dnsZoneId": _SERIALIZER.url("dns_zone_id", dns_zone_id, "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_dns_zone_request( + resource_group_name: str, private_cloud_name: str, dns_zone_id: 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-05-01")) # 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.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsZones/{dnsZoneId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "dnsZoneId": _SERIALIZER.url("dns_zone_id", dns_zone_id, "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_dns_zone_request( + resource_group_name: str, dns_zone_id: str, private_cloud_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsZones/{dnsZoneId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "dnsZoneId": _SERIALIZER.url("dns_zone_id", dns_zone_id, "str"), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_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_public_i_ps_request( + resource_group_name: str, private_cloud_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/publicIPs", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_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_get_public_ip_request( + resource_group_name: str, private_cloud_name: str, public_ip_id: 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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/publicIPs/{publicIPId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "publicIPId": _SERIALIZER.url("public_ip_id", public_ip_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_create_public_ip_request( + resource_group_name: str, private_cloud_name: str, public_ip_id: 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-05-01")) # 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.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/publicIPs/{publicIPId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + "publicIPId": _SERIALIZER.url("public_ip_id", public_ip_id, "str"), + } -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + _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") + + # 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_delete_public_ip_request( + resource_group_name: str, public_ip_id: str, private_cloud_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-05-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/publicIPs/{publicIPId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "publicIPId": _SERIALIZER.url("public_ip_id", public_ip_id, "str"), + "privateCloudName": _SERIALIZER.url("private_cloud_name", private_cloud_name, "str"), + } -class WorkloadNetworksOperations(object): - """WorkloadNetworksOperations 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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class WorkloadNetworksOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.avs.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.avs.AVSClient`'s + :attr:`workload_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 list_segments( + @distributed_trace + def get( self, - resource_group_name, # type: str - private_cloud_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.WorkloadNetworkSegmentsList"] + resource_group_name: str, + private_cloud_name: str, + workload_network_name: Union[str, _models.WorkloadNetworkName], + **kwargs: Any + ) -> _models.WorkloadNetwork: + """Get a private cloud workload network. + + Get a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param workload_network_name: Name for the workload network in the private cloud. "default" + Required. + :type workload_network_name: str or ~azure.mgmt.avs.models.WorkloadNetworkName + :keyword callable cls: A custom type or function that will be passed the direct response + :return: WorkloadNetwork or the result of cls(response) + :rtype: ~azure.mgmt.avs.models.WorkloadNetwork + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + 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.WorkloadNetwork] + + request = build_get_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + workload_network_name=workload_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("WorkloadNetwork", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/{workloadNetworkName}"} # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, private_cloud_name: str, **kwargs: Any + ) -> Iterable["_models.WorkloadNetwork"]: + """List of workload networks in a private cloud. + + List of workload networks in a private cloud. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either WorkloadNetwork or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.avs.models.WorkloadNetwork] + :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.WorkloadNetworkList] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + 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: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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("WorkloadNetworkList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks"} # type: ignore + + @distributed_trace + def list_segments( + self, resource_group_name: str, private_cloud_name: str, **kwargs: Any + ) -> Iterable["_models.WorkloadNetworkSegment"]: """List of segments in a private cloud workload network. List of segments in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WorkloadNetworkSegmentsList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.avs.models.WorkloadNetworkSegmentsList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either WorkloadNetworkSegment or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.avs.models.WorkloadNetworkSegment] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkSegmentsList"] + _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.WorkloadNetworkSegmentsList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_segments.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - } - url = self._client.format_url(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_segments_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_segments.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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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('WorkloadNetworkSegmentsList', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkSegmentsList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,7 +1687,9 @@ 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]: @@ -119,118 +1698,128 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_segments.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/segments'} # type: ignore + return ItemPaged(get_next, extract_data) + list_segments.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/segments"} # type: ignore + + @distributed_trace def get_segment( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - segment_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.WorkloadNetworkSegment" + self, resource_group_name: str, private_cloud_name: str, segment_id: str, **kwargs: Any + ) -> _models.WorkloadNetworkSegment: """Get a segment by id in a private cloud workload network. Get a segment by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :param segment_id: NSX Segment identifier. Generally the same as the Segment's display name. + Required. :type segment_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: WorkloadNetworkSegment, or the result of cls(response) + :return: WorkloadNetworkSegment or the result of cls(response) :rtype: ~azure.mgmt.avs.models.WorkloadNetworkSegment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkSegment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.get_segment.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'segmentId': self._serialize.url("segment_id", segment_id, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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.WorkloadNetworkSegment] + + request = build_get_segment_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + segment_id=segment_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_segment.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('WorkloadNetworkSegment', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkSegment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_segment.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/segments/{segmentId}'} # type: ignore + + get_segment.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/segments/{segmentId}"} # type: ignore def _create_segments_initial( self, - resource_group_name, # type: str - private_cloud_name, # type: str - segment_id, # type: str - workload_network_segment, # type: "_models.WorkloadNetworkSegment" - **kwargs # type: Any - ): - # type: (...) -> "_models.WorkloadNetworkSegment" - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkSegment"] + resource_group_name: str, + private_cloud_name: str, + segment_id: str, + workload_network_segment: Union[_models.WorkloadNetworkSegment, IO], + **kwargs: Any + ) -> _models.WorkloadNetworkSegment: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_segments_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'segmentId': self._serialize.url("segment_id", segment_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') - - # 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(workload_network_segment, 'WorkloadNetworkSegment') - 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) + 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.WorkloadNetworkSegment] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(workload_network_segment, (IO, bytes)): + _content = workload_network_segment + else: + _json = self._serialize.body(workload_network_segment, "WorkloadNetworkSegment") + + request = build_create_segments_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + segment_id=segment_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_segments_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]: @@ -238,138 +1827,239 @@ def _create_segments_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('WorkloadNetworkSegment', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkSegment", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('WorkloadNetworkSegment', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkSegment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_segments_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/segments/{segmentId}'} # type: ignore + _create_segments_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/segments/{segmentId}"} # type: ignore + + @overload def begin_create_segments( self, - resource_group_name, # type: str - private_cloud_name, # type: str - segment_id, # type: str - workload_network_segment, # type: "_models.WorkloadNetworkSegment" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.WorkloadNetworkSegment"] + resource_group_name: str, + private_cloud_name: str, + segment_id: str, + workload_network_segment: _models.WorkloadNetworkSegment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WorkloadNetworkSegment]: """Create a segment by id in a private cloud workload network. Create a segment by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :param segment_id: NSX Segment identifier. Generally the same as the Segment's display name. + Required. :type segment_id: str - :param workload_network_segment: NSX Segment. + :param workload_network_segment: NSX Segment. Required. :type workload_network_segment: ~azure.mgmt.avs.models.WorkloadNetworkSegment + :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 WorkloadNetworkSegment 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 WorkloadNetworkSegment or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.WorkloadNetworkSegment] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkSegment"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_segments( + self, + resource_group_name: str, + private_cloud_name: str, + segment_id: str, + workload_network_segment: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WorkloadNetworkSegment]: + """Create a segment by id in a private cloud workload network. + + Create a segment by id in a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param segment_id: NSX Segment identifier. Generally the same as the Segment's display name. + Required. + :type segment_id: str + :param workload_network_segment: NSX Segment. Required. + :type workload_network_segment: 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 WorkloadNetworkSegment or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.WorkloadNetworkSegment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_segments( + self, + resource_group_name: str, + private_cloud_name: str, + segment_id: str, + workload_network_segment: Union[_models.WorkloadNetworkSegment, IO], + **kwargs: Any + ) -> LROPoller[_models.WorkloadNetworkSegment]: + """Create a segment by id in a private cloud workload network. + + Create a segment by id in a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param segment_id: NSX Segment identifier. Generally the same as the Segment's display name. + Required. + :type segment_id: str + :param workload_network_segment: NSX Segment. Is either a model type or a IO type. Required. + :type workload_network_segment: ~azure.mgmt.avs.models.WorkloadNetworkSegment 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 WorkloadNetworkSegment or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.WorkloadNetworkSegment] + :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.WorkloadNetworkSegment] + 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_segments_initial( + raw_result = self._create_segments_initial( # type: ignore resource_group_name=resource_group_name, private_cloud_name=private_cloud_name, segment_id=segment_id, workload_network_segment=workload_network_segment, - 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('WorkloadNetworkSegment', pipeline_response) - + deserialized = self._deserialize("WorkloadNetworkSegment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'segmentId': self._serialize.url("segment_id", segment_id, '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_create_segments.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/segments/{segmentId}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_segments.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/segments/{segmentId}"} # type: ignore def _update_segments_initial( self, - resource_group_name, # type: str - private_cloud_name, # type: str - segment_id, # type: str - workload_network_segment, # type: "_models.WorkloadNetworkSegment" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.WorkloadNetworkSegment"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WorkloadNetworkSegment"]] + resource_group_name: str, + private_cloud_name: str, + segment_id: str, + workload_network_segment: Union[_models.WorkloadNetworkSegment, IO], + **kwargs: Any + ) -> Optional[_models.WorkloadNetworkSegment]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_segments_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'segmentId': self._serialize.url("segment_id", segment_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') - - # 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(workload_network_segment, 'WorkloadNetworkSegment') - 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) + 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.WorkloadNetworkSegment]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(workload_network_segment, (IO, bytes)): + _content = workload_network_segment + else: + _json = self._serialize.body(workload_network_segment, "WorkloadNetworkSegment") + + request = build_update_segments_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + segment_id=segment_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_segments_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]: @@ -378,129 +2068,219 @@ def _update_segments_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('WorkloadNetworkSegment', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkSegment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_segments_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/segments/{segmentId}'} # type: ignore + _update_segments_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/segments/{segmentId}"} # type: ignore + + @overload def begin_update_segments( self, - resource_group_name, # type: str - private_cloud_name, # type: str - segment_id, # type: str - workload_network_segment, # type: "_models.WorkloadNetworkSegment" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.WorkloadNetworkSegment"] + resource_group_name: str, + private_cloud_name: str, + segment_id: str, + workload_network_segment: _models.WorkloadNetworkSegment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WorkloadNetworkSegment]: """Create or update a segment by id in a private cloud workload network. Create or update a segment by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :param segment_id: NSX Segment identifier. Generally the same as the Segment's display name. + Required. :type segment_id: str - :param workload_network_segment: NSX Segment. + :param workload_network_segment: NSX Segment. Required. :type workload_network_segment: ~azure.mgmt.avs.models.WorkloadNetworkSegment + :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 WorkloadNetworkSegment 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 WorkloadNetworkSegment or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.WorkloadNetworkSegment] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkSegment"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_update_segments( + self, + resource_group_name: str, + private_cloud_name: str, + segment_id: str, + workload_network_segment: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WorkloadNetworkSegment]: + """Create or update a segment by id in a private cloud workload network. + + Create or update a segment by id in a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param segment_id: NSX Segment identifier. Generally the same as the Segment's display name. + Required. + :type segment_id: str + :param workload_network_segment: NSX Segment. Required. + :type workload_network_segment: 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 WorkloadNetworkSegment or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.WorkloadNetworkSegment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_segments( + self, + resource_group_name: str, + private_cloud_name: str, + segment_id: str, + workload_network_segment: Union[_models.WorkloadNetworkSegment, IO], + **kwargs: Any + ) -> LROPoller[_models.WorkloadNetworkSegment]: + """Create or update a segment by id in a private cloud workload network. + + Create or update a segment by id in a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param segment_id: NSX Segment identifier. Generally the same as the Segment's display name. + Required. + :type segment_id: str + :param workload_network_segment: NSX Segment. Is either a model type or a IO type. Required. + :type workload_network_segment: ~azure.mgmt.avs.models.WorkloadNetworkSegment 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 WorkloadNetworkSegment or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.WorkloadNetworkSegment] + :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.WorkloadNetworkSegment] + 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_segments_initial( + raw_result = self._update_segments_initial( # type: ignore resource_group_name=resource_group_name, private_cloud_name=private_cloud_name, segment_id=segment_id, workload_network_segment=workload_network_segment, - 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('WorkloadNetworkSegment', pipeline_response) - + deserialized = self._deserialize("WorkloadNetworkSegment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'segmentId': self._serialize.url("segment_id", segment_id, '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_segments.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/segments/{segmentId}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def _delete_segment_initial( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - segment_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_update_segments.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/segments/{segmentId}"} # type: ignore + + def _delete_segment_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, private_cloud_name: str, segment_id: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_segment_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'segmentId': self._serialize.url("segment_id", segment_id, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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_segment_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + segment_id=segment_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_segment_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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]: @@ -510,135 +2290,145 @@ def _delete_segment_initial( if cls: return cls(pipeline_response, None, {}) - _delete_segment_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/segments/{segmentId}'} # type: ignore + _delete_segment_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/segments/{segmentId}"} # type: ignore + @distributed_trace def begin_delete_segment( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - segment_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + self, resource_group_name: str, private_cloud_name: str, segment_id: str, **kwargs: Any + ) -> LROPoller[None]: """Delete a segment by id in a private cloud workload network. Delete a segment by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :param segment_id: NSX Segment identifier. Generally the same as the Segment's display name. + Required. :type segment_id: 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_segment_initial( + raw_result = self._delete_segment_initial( # type: ignore resource_group_name=resource_group_name, private_cloud_name=private_cloud_name, segment_id=segment_id, - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'segmentId': self._serialize.url("segment_id", segment_id, '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_segment.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/segments/{segmentId}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_segment.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/segments/{segmentId}"} # type: ignore + @distributed_trace def list_dhcp( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.WorkloadNetworkDhcpList"] + self, resource_group_name: str, private_cloud_name: str, **kwargs: Any + ) -> Iterable["_models.WorkloadNetworkDhcp"]: """List dhcp in a private cloud workload network. List dhcp in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WorkloadNetworkDhcpList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.avs.models.WorkloadNetworkDhcpList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either WorkloadNetworkDhcp or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.avs.models.WorkloadNetworkDhcp] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkDhcpList"] + _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.WorkloadNetworkDhcpList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_dhcp.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - } - url = self._client.format_url(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_dhcp_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_dhcp.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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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('WorkloadNetworkDhcpList', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkDhcpList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -647,7 +2437,9 @@ 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]: @@ -656,118 +2448,127 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_dhcp.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dhcpConfigurations'} # type: ignore + return ItemPaged(get_next, extract_data) + + list_dhcp.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dhcpConfigurations"} # type: ignore + @distributed_trace def get_dhcp( - self, - resource_group_name, # type: str - dhcp_id, # type: str - private_cloud_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.WorkloadNetworkDhcp" + self, resource_group_name: str, dhcp_id: str, private_cloud_name: str, **kwargs: Any + ) -> _models.WorkloadNetworkDhcp: """Get dhcp by id in a private cloud workload network. Get dhcp by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param dhcp_id: NSX DHCP identifier. Generally the same as the DHCP display name. + :param dhcp_id: NSX DHCP identifier. Generally the same as the DHCP display name. Required. :type dhcp_id: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: WorkloadNetworkDhcp, or the result of cls(response) + :return: WorkloadNetworkDhcp or the result of cls(response) :rtype: ~azure.mgmt.avs.models.WorkloadNetworkDhcp - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkDhcp"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.get_dhcp.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'dhcpId': self._serialize.url("dhcp_id", dhcp_id, 'str'), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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.WorkloadNetworkDhcp] + + request = build_get_dhcp_request( + resource_group_name=resource_group_name, + dhcp_id=dhcp_id, + private_cloud_name=private_cloud_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_dhcp.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('WorkloadNetworkDhcp', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkDhcp", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_dhcp.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dhcpConfigurations/{dhcpId}'} # type: ignore + + get_dhcp.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dhcpConfigurations/{dhcpId}"} # type: ignore def _create_dhcp_initial( self, - resource_group_name, # type: str - private_cloud_name, # type: str - dhcp_id, # type: str - workload_network_dhcp, # type: "_models.WorkloadNetworkDhcp" - **kwargs # type: Any - ): - # type: (...) -> "_models.WorkloadNetworkDhcp" - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkDhcp"] + resource_group_name: str, + private_cloud_name: str, + dhcp_id: str, + workload_network_dhcp: Union[_models.WorkloadNetworkDhcp, IO], + **kwargs: Any + ) -> _models.WorkloadNetworkDhcp: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_dhcp_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'dhcpId': self._serialize.url("dhcp_id", dhcp_id, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(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(workload_network_dhcp, 'WorkloadNetworkDhcp') - 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) + 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.WorkloadNetworkDhcp] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(workload_network_dhcp, (IO, bytes)): + _content = workload_network_dhcp + else: + _json = self._serialize.body(workload_network_dhcp, "WorkloadNetworkDhcp") + + request = build_create_dhcp_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + dhcp_id=dhcp_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_dhcp_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]: @@ -775,138 +2576,236 @@ def _create_dhcp_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('WorkloadNetworkDhcp', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkDhcp", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('WorkloadNetworkDhcp', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkDhcp", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_dhcp_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dhcpConfigurations/{dhcpId}'} # type: ignore + _create_dhcp_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dhcpConfigurations/{dhcpId}"} # type: ignore + + @overload def begin_create_dhcp( self, - resource_group_name, # type: str - private_cloud_name, # type: str - dhcp_id, # type: str - workload_network_dhcp, # type: "_models.WorkloadNetworkDhcp" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.WorkloadNetworkDhcp"] + resource_group_name: str, + private_cloud_name: str, + dhcp_id: str, + workload_network_dhcp: _models.WorkloadNetworkDhcp, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WorkloadNetworkDhcp]: """Create dhcp by id in a private cloud workload network. Create dhcp by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param dhcp_id: NSX DHCP identifier. Generally the same as the DHCP display name. + :param dhcp_id: NSX DHCP identifier. Generally the same as the DHCP display name. Required. :type dhcp_id: str - :param workload_network_dhcp: NSX DHCP. + :param workload_network_dhcp: NSX DHCP. Required. :type workload_network_dhcp: ~azure.mgmt.avs.models.WorkloadNetworkDhcp + :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 WorkloadNetworkDhcp 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 WorkloadNetworkDhcp or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.WorkloadNetworkDhcp] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkDhcp"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_dhcp( + self, + resource_group_name: str, + private_cloud_name: str, + dhcp_id: str, + workload_network_dhcp: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WorkloadNetworkDhcp]: + """Create dhcp by id in a private cloud workload network. + + Create dhcp by id in a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param dhcp_id: NSX DHCP identifier. Generally the same as the DHCP display name. Required. + :type dhcp_id: str + :param workload_network_dhcp: NSX DHCP. Required. + :type workload_network_dhcp: 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 WorkloadNetworkDhcp or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.WorkloadNetworkDhcp] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_dhcp( + self, + resource_group_name: str, + private_cloud_name: str, + dhcp_id: str, + workload_network_dhcp: Union[_models.WorkloadNetworkDhcp, IO], + **kwargs: Any + ) -> LROPoller[_models.WorkloadNetworkDhcp]: + """Create dhcp by id in a private cloud workload network. + + Create dhcp by id in a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param dhcp_id: NSX DHCP identifier. Generally the same as the DHCP display name. Required. + :type dhcp_id: str + :param workload_network_dhcp: NSX DHCP. Is either a model type or a IO type. Required. + :type workload_network_dhcp: ~azure.mgmt.avs.models.WorkloadNetworkDhcp 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 WorkloadNetworkDhcp or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.WorkloadNetworkDhcp] + :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.WorkloadNetworkDhcp] + 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_dhcp_initial( + raw_result = self._create_dhcp_initial( # type: ignore resource_group_name=resource_group_name, private_cloud_name=private_cloud_name, dhcp_id=dhcp_id, workload_network_dhcp=workload_network_dhcp, - 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('WorkloadNetworkDhcp', pipeline_response) - + deserialized = self._deserialize("WorkloadNetworkDhcp", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'dhcpId': self._serialize.url("dhcp_id", dhcp_id, '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_create_dhcp.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dhcpConfigurations/{dhcpId}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_dhcp.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dhcpConfigurations/{dhcpId}"} # type: ignore def _update_dhcp_initial( self, - resource_group_name, # type: str - private_cloud_name, # type: str - dhcp_id, # type: str - workload_network_dhcp, # type: "_models.WorkloadNetworkDhcp" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.WorkloadNetworkDhcp"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WorkloadNetworkDhcp"]] + resource_group_name: str, + private_cloud_name: str, + dhcp_id: str, + workload_network_dhcp: Union[_models.WorkloadNetworkDhcp, IO], + **kwargs: Any + ) -> Optional[_models.WorkloadNetworkDhcp]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_dhcp_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'dhcpId': self._serialize.url("dhcp_id", dhcp_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') - - # 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(workload_network_dhcp, 'WorkloadNetworkDhcp') - 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) + 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.WorkloadNetworkDhcp]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(workload_network_dhcp, (IO, bytes)): + _content = workload_network_dhcp + else: + _json = self._serialize.body(workload_network_dhcp, "WorkloadNetworkDhcp") + + request = build_update_dhcp_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + dhcp_id=dhcp_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_dhcp_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]: @@ -915,129 +2814,216 @@ def _update_dhcp_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('WorkloadNetworkDhcp', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkDhcp", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_dhcp_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dhcpConfigurations/{dhcpId}'} # type: ignore + _update_dhcp_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dhcpConfigurations/{dhcpId}"} # type: ignore + + @overload def begin_update_dhcp( self, - resource_group_name, # type: str - private_cloud_name, # type: str - dhcp_id, # type: str - workload_network_dhcp, # type: "_models.WorkloadNetworkDhcp" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.WorkloadNetworkDhcp"] + resource_group_name: str, + private_cloud_name: str, + dhcp_id: str, + workload_network_dhcp: _models.WorkloadNetworkDhcp, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WorkloadNetworkDhcp]: """Create or update dhcp by id in a private cloud workload network. Create or update dhcp by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param dhcp_id: NSX DHCP identifier. Generally the same as the DHCP display name. + :param dhcp_id: NSX DHCP identifier. Generally the same as the DHCP display name. Required. :type dhcp_id: str - :param workload_network_dhcp: NSX DHCP. + :param workload_network_dhcp: NSX DHCP. Required. :type workload_network_dhcp: ~azure.mgmt.avs.models.WorkloadNetworkDhcp + :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 WorkloadNetworkDhcp 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 WorkloadNetworkDhcp or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.WorkloadNetworkDhcp] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkDhcp"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_update_dhcp( + self, + resource_group_name: str, + private_cloud_name: str, + dhcp_id: str, + workload_network_dhcp: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WorkloadNetworkDhcp]: + """Create or update dhcp by id in a private cloud workload network. + + Create or update dhcp by id in a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param dhcp_id: NSX DHCP identifier. Generally the same as the DHCP display name. Required. + :type dhcp_id: str + :param workload_network_dhcp: NSX DHCP. Required. + :type workload_network_dhcp: 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 WorkloadNetworkDhcp or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.WorkloadNetworkDhcp] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_dhcp( + self, + resource_group_name: str, + private_cloud_name: str, + dhcp_id: str, + workload_network_dhcp: Union[_models.WorkloadNetworkDhcp, IO], + **kwargs: Any + ) -> LROPoller[_models.WorkloadNetworkDhcp]: + """Create or update dhcp by id in a private cloud workload network. + + Create or update dhcp by id in a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param dhcp_id: NSX DHCP identifier. Generally the same as the DHCP display name. Required. + :type dhcp_id: str + :param workload_network_dhcp: NSX DHCP. Is either a model type or a IO type. Required. + :type workload_network_dhcp: ~azure.mgmt.avs.models.WorkloadNetworkDhcp 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 WorkloadNetworkDhcp or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.WorkloadNetworkDhcp] + :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.WorkloadNetworkDhcp] + 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_dhcp_initial( + raw_result = self._update_dhcp_initial( # type: ignore resource_group_name=resource_group_name, private_cloud_name=private_cloud_name, dhcp_id=dhcp_id, workload_network_dhcp=workload_network_dhcp, - 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('WorkloadNetworkDhcp', pipeline_response) - + deserialized = self._deserialize("WorkloadNetworkDhcp", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'dhcpId': self._serialize.url("dhcp_id", dhcp_id, '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_dhcp.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dhcpConfigurations/{dhcpId}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def _delete_dhcp_initial( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - dhcp_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_update_dhcp.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dhcpConfigurations/{dhcpId}"} # type: ignore + + def _delete_dhcp_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, private_cloud_name: str, dhcp_id: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_dhcp_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'dhcpId': self._serialize.url("dhcp_id", dhcp_id, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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_dhcp_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + dhcp_id=dhcp_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_dhcp_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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]: @@ -1047,135 +3033,145 @@ def _delete_dhcp_initial( if cls: return cls(pipeline_response, None, {}) - _delete_dhcp_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dhcpConfigurations/{dhcpId}'} # type: ignore + _delete_dhcp_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dhcpConfigurations/{dhcpId}"} # type: ignore + @distributed_trace def begin_delete_dhcp( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - dhcp_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + self, resource_group_name: str, private_cloud_name: str, dhcp_id: str, **kwargs: Any + ) -> LROPoller[None]: """Delete dhcp by id in a private cloud workload network. Delete dhcp by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param dhcp_id: NSX DHCP identifier. Generally the same as the DHCP display name. + :param dhcp_id: NSX DHCP identifier. Generally the same as the DHCP display name. Required. :type dhcp_id: 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_dhcp_initial( + raw_result = self._delete_dhcp_initial( # type: ignore resource_group_name=resource_group_name, private_cloud_name=private_cloud_name, dhcp_id=dhcp_id, - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'dhcpId': self._serialize.url("dhcp_id", dhcp_id, '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_dhcp.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dhcpConfigurations/{dhcpId}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_dhcp.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dhcpConfigurations/{dhcpId}"} # type: ignore + @distributed_trace def list_gateways( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.WorkloadNetworkGatewayList"] + self, resource_group_name: str, private_cloud_name: str, **kwargs: Any + ) -> Iterable["_models.WorkloadNetworkGateway"]: """List of gateways in a private cloud workload network. List of gateways in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WorkloadNetworkGatewayList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.avs.models.WorkloadNetworkGatewayList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either WorkloadNetworkGateway or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.avs.models.WorkloadNetworkGateway] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkGatewayList"] + _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.WorkloadNetworkGatewayList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_gateways.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - } - url = self._client.format_url(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_gateways_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_gateways.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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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('WorkloadNetworkGatewayList', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkGatewayList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1184,7 +3180,9 @@ 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]: @@ -1193,131 +3191,145 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_gateways.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/gateways'} # type: ignore + return ItemPaged(get_next, extract_data) + + list_gateways.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/gateways"} # type: ignore + @distributed_trace def get_gateway( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - gateway_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.WorkloadNetworkGateway" + self, resource_group_name: str, private_cloud_name: str, gateway_id: str, **kwargs: Any + ) -> _models.WorkloadNetworkGateway: """Get a gateway by id in a private cloud workload network. Get a gateway by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :param gateway_id: NSX Gateway identifier. Generally the same as the Gateway's display name. + Required. :type gateway_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: WorkloadNetworkGateway, or the result of cls(response) + :return: WorkloadNetworkGateway or the result of cls(response) :rtype: ~azure.mgmt.avs.models.WorkloadNetworkGateway - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkGateway"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.get_gateway.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'gatewayId': self._serialize.url("gateway_id", gateway_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') + 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.WorkloadNetworkGateway] + + request = build_get_gateway_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + gateway_id=gateway_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_gateway.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('WorkloadNetworkGateway', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkGateway", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_gateway.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/gateways/{gatewayId}'} # type: ignore + get_gateway.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/gateways/{gatewayId}"} # type: ignore + + @distributed_trace def list_port_mirroring( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.WorkloadNetworkPortMirroringList"] + self, resource_group_name: str, private_cloud_name: str, **kwargs: Any + ) -> Iterable["_models.WorkloadNetworkPortMirroring"]: """List of port mirroring profiles in a private cloud workload network. List of port mirroring profiles in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WorkloadNetworkPortMirroringList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.avs.models.WorkloadNetworkPortMirroringList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either WorkloadNetworkPortMirroring or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.avs.models.WorkloadNetworkPortMirroring] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkPortMirroringList"] + _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.WorkloadNetworkPortMirroringList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_port_mirroring.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - } - url = self._client.format_url(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_port_mirroring_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_port_mirroring.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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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('WorkloadNetworkPortMirroringList', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkPortMirroringList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1326,7 +3338,9 @@ 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]: @@ -1335,119 +3349,128 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_port_mirroring.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/portMirroringProfiles'} # type: ignore + return ItemPaged(get_next, extract_data) + list_port_mirroring.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/portMirroringProfiles"} # type: ignore + + @distributed_trace def get_port_mirroring( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - port_mirroring_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.WorkloadNetworkPortMirroring" + self, resource_group_name: str, private_cloud_name: str, port_mirroring_id: str, **kwargs: Any + ) -> _models.WorkloadNetworkPortMirroring: """Get a port mirroring profile by id in a private cloud workload network. Get a port mirroring profile by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :param port_mirroring_id: NSX Port Mirroring identifier. Generally the same as the Port - Mirroring display name. + Mirroring display name. Required. :type port_mirroring_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: WorkloadNetworkPortMirroring, or the result of cls(response) + :return: WorkloadNetworkPortMirroring or the result of cls(response) :rtype: ~azure.mgmt.avs.models.WorkloadNetworkPortMirroring - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkPortMirroring"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.get_port_mirroring.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'portMirroringId': self._serialize.url("port_mirroring_id", port_mirroring_id, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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.WorkloadNetworkPortMirroring] + + request = build_get_port_mirroring_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + port_mirroring_id=port_mirroring_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_port_mirroring.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('WorkloadNetworkPortMirroring', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkPortMirroring", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_port_mirroring.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/portMirroringProfiles/{portMirroringId}'} # type: ignore + + get_port_mirroring.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/portMirroringProfiles/{portMirroringId}"} # type: ignore def _create_port_mirroring_initial( self, - resource_group_name, # type: str - private_cloud_name, # type: str - port_mirroring_id, # type: str - workload_network_port_mirroring, # type: "_models.WorkloadNetworkPortMirroring" - **kwargs # type: Any - ): - # type: (...) -> "_models.WorkloadNetworkPortMirroring" - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkPortMirroring"] + resource_group_name: str, + private_cloud_name: str, + port_mirroring_id: str, + workload_network_port_mirroring: Union[_models.WorkloadNetworkPortMirroring, IO], + **kwargs: Any + ) -> _models.WorkloadNetworkPortMirroring: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_port_mirroring_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'portMirroringId': self._serialize.url("port_mirroring_id", port_mirroring_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') - - # 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(workload_network_port_mirroring, 'WorkloadNetworkPortMirroring') - 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) + 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.WorkloadNetworkPortMirroring] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(workload_network_port_mirroring, (IO, bytes)): + _content = workload_network_port_mirroring + else: + _json = self._serialize.body(workload_network_port_mirroring, "WorkloadNetworkPortMirroring") + + request = build_create_port_mirroring_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + port_mirroring_id=port_mirroring_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_port_mirroring_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]: @@ -1455,139 +3478,241 @@ def _create_port_mirroring_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('WorkloadNetworkPortMirroring', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkPortMirroring", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('WorkloadNetworkPortMirroring', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkPortMirroring", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_port_mirroring_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/portMirroringProfiles/{portMirroringId}'} # type: ignore + _create_port_mirroring_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/portMirroringProfiles/{portMirroringId}"} # type: ignore + + @overload def begin_create_port_mirroring( self, - resource_group_name, # type: str - private_cloud_name, # type: str - port_mirroring_id, # type: str - workload_network_port_mirroring, # type: "_models.WorkloadNetworkPortMirroring" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.WorkloadNetworkPortMirroring"] + resource_group_name: str, + private_cloud_name: str, + port_mirroring_id: str, + workload_network_port_mirroring: _models.WorkloadNetworkPortMirroring, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WorkloadNetworkPortMirroring]: """Create a port mirroring profile by id in a private cloud workload network. Create a port mirroring profile by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :param port_mirroring_id: NSX Port Mirroring identifier. Generally the same as the Port - Mirroring display name. + Mirroring display name. Required. :type port_mirroring_id: str - :param workload_network_port_mirroring: NSX port mirroring. + :param workload_network_port_mirroring: NSX port mirroring. Required. :type workload_network_port_mirroring: ~azure.mgmt.avs.models.WorkloadNetworkPortMirroring + :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 WorkloadNetworkPortMirroring 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 WorkloadNetworkPortMirroring or the + result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.WorkloadNetworkPortMirroring] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkPortMirroring"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_port_mirroring( + self, + resource_group_name: str, + private_cloud_name: str, + port_mirroring_id: str, + workload_network_port_mirroring: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WorkloadNetworkPortMirroring]: + """Create a port mirroring profile by id in a private cloud workload network. + + Create a port mirroring profile by id in a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param port_mirroring_id: NSX Port Mirroring identifier. Generally the same as the Port + Mirroring display name. Required. + :type port_mirroring_id: str + :param workload_network_port_mirroring: NSX port mirroring. Required. + :type workload_network_port_mirroring: 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 WorkloadNetworkPortMirroring or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.WorkloadNetworkPortMirroring] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_port_mirroring( + self, + resource_group_name: str, + private_cloud_name: str, + port_mirroring_id: str, + workload_network_port_mirroring: Union[_models.WorkloadNetworkPortMirroring, IO], + **kwargs: Any + ) -> LROPoller[_models.WorkloadNetworkPortMirroring]: + """Create a port mirroring profile by id in a private cloud workload network. + + Create a port mirroring profile by id in a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param port_mirroring_id: NSX Port Mirroring identifier. Generally the same as the Port + Mirroring display name. Required. + :type port_mirroring_id: str + :param workload_network_port_mirroring: NSX port mirroring. Is either a model type or a IO + type. Required. + :type workload_network_port_mirroring: ~azure.mgmt.avs.models.WorkloadNetworkPortMirroring 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 WorkloadNetworkPortMirroring or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.WorkloadNetworkPortMirroring] + :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.WorkloadNetworkPortMirroring] + 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_port_mirroring_initial( + raw_result = self._create_port_mirroring_initial( # type: ignore resource_group_name=resource_group_name, private_cloud_name=private_cloud_name, port_mirroring_id=port_mirroring_id, workload_network_port_mirroring=workload_network_port_mirroring, - 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('WorkloadNetworkPortMirroring', pipeline_response) - + deserialized = self._deserialize("WorkloadNetworkPortMirroring", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'portMirroringId': self._serialize.url("port_mirroring_id", port_mirroring_id, '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_create_port_mirroring.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/portMirroringProfiles/{portMirroringId}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_port_mirroring.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/portMirroringProfiles/{portMirroringId}"} # type: ignore def _update_port_mirroring_initial( self, - resource_group_name, # type: str - private_cloud_name, # type: str - port_mirroring_id, # type: str - workload_network_port_mirroring, # type: "_models.WorkloadNetworkPortMirroring" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.WorkloadNetworkPortMirroring"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WorkloadNetworkPortMirroring"]] + resource_group_name: str, + private_cloud_name: str, + port_mirroring_id: str, + workload_network_port_mirroring: Union[_models.WorkloadNetworkPortMirroring, IO], + **kwargs: Any + ) -> Optional[_models.WorkloadNetworkPortMirroring]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_port_mirroring_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'portMirroringId': self._serialize.url("port_mirroring_id", port_mirroring_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') - - # 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(workload_network_port_mirroring, 'WorkloadNetworkPortMirroring') - 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) + 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.WorkloadNetworkPortMirroring]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(workload_network_port_mirroring, (IO, bytes)): + _content = workload_network_port_mirroring + else: + _json = self._serialize.body(workload_network_port_mirroring, "WorkloadNetworkPortMirroring") + + request = build_update_port_mirroring_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + port_mirroring_id=port_mirroring_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_port_mirroring_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]: @@ -1596,130 +3721,221 @@ def _update_port_mirroring_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('WorkloadNetworkPortMirroring', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkPortMirroring", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_port_mirroring_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/portMirroringProfiles/{portMirroringId}'} # type: ignore + _update_port_mirroring_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/portMirroringProfiles/{portMirroringId}"} # type: ignore + + @overload def begin_update_port_mirroring( self, - resource_group_name, # type: str - private_cloud_name, # type: str - port_mirroring_id, # type: str - workload_network_port_mirroring, # type: "_models.WorkloadNetworkPortMirroring" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.WorkloadNetworkPortMirroring"] + resource_group_name: str, + private_cloud_name: str, + port_mirroring_id: str, + workload_network_port_mirroring: _models.WorkloadNetworkPortMirroring, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WorkloadNetworkPortMirroring]: """Create or update a port mirroring profile by id in a private cloud workload network. Create or update a port mirroring profile by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :param port_mirroring_id: NSX Port Mirroring identifier. Generally the same as the Port - Mirroring display name. + Mirroring display name. Required. :type port_mirroring_id: str - :param workload_network_port_mirroring: NSX port mirroring. + :param workload_network_port_mirroring: NSX port mirroring. Required. :type workload_network_port_mirroring: ~azure.mgmt.avs.models.WorkloadNetworkPortMirroring + :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 WorkloadNetworkPortMirroring 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 WorkloadNetworkPortMirroring or the + result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.WorkloadNetworkPortMirroring] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkPortMirroring"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_update_port_mirroring( + self, + resource_group_name: str, + private_cloud_name: str, + port_mirroring_id: str, + workload_network_port_mirroring: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WorkloadNetworkPortMirroring]: + """Create or update a port mirroring profile by id in a private cloud workload network. + + Create or update a port mirroring profile by id in a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param port_mirroring_id: NSX Port Mirroring identifier. Generally the same as the Port + Mirroring display name. Required. + :type port_mirroring_id: str + :param workload_network_port_mirroring: NSX port mirroring. Required. + :type workload_network_port_mirroring: 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 WorkloadNetworkPortMirroring or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.WorkloadNetworkPortMirroring] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_port_mirroring( + self, + resource_group_name: str, + private_cloud_name: str, + port_mirroring_id: str, + workload_network_port_mirroring: Union[_models.WorkloadNetworkPortMirroring, IO], + **kwargs: Any + ) -> LROPoller[_models.WorkloadNetworkPortMirroring]: + """Create or update a port mirroring profile by id in a private cloud workload network. + + Create or update a port mirroring profile by id in a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param port_mirroring_id: NSX Port Mirroring identifier. Generally the same as the Port + Mirroring display name. Required. + :type port_mirroring_id: str + :param workload_network_port_mirroring: NSX port mirroring. Is either a model type or a IO + type. Required. + :type workload_network_port_mirroring: ~azure.mgmt.avs.models.WorkloadNetworkPortMirroring 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 WorkloadNetworkPortMirroring or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.WorkloadNetworkPortMirroring] + :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.WorkloadNetworkPortMirroring] + 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_port_mirroring_initial( + raw_result = self._update_port_mirroring_initial( # type: ignore resource_group_name=resource_group_name, private_cloud_name=private_cloud_name, port_mirroring_id=port_mirroring_id, workload_network_port_mirroring=workload_network_port_mirroring, - 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('WorkloadNetworkPortMirroring', pipeline_response) - + deserialized = self._deserialize("WorkloadNetworkPortMirroring", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'portMirroringId': self._serialize.url("port_mirroring_id", port_mirroring_id, '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_port_mirroring.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/portMirroringProfiles/{portMirroringId}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def _delete_port_mirroring_initial( - self, - resource_group_name, # type: str - port_mirroring_id, # type: str - private_cloud_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_update_port_mirroring.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/portMirroringProfiles/{portMirroringId}"} # type: ignore + + def _delete_port_mirroring_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, port_mirroring_id: str, private_cloud_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_port_mirroring_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'portMirroringId': self._serialize.url("port_mirroring_id", port_mirroring_id, 'str'), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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_port_mirroring_request( + resource_group_name=resource_group_name, + port_mirroring_id=port_mirroring_id, + private_cloud_name=private_cloud_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_port_mirroring_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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]: @@ -1729,136 +3945,146 @@ def _delete_port_mirroring_initial( if cls: return cls(pipeline_response, None, {}) - _delete_port_mirroring_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/portMirroringProfiles/{portMirroringId}'} # type: ignore + _delete_port_mirroring_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/portMirroringProfiles/{portMirroringId}"} # type: ignore + @distributed_trace def begin_delete_port_mirroring( - self, - resource_group_name, # type: str - port_mirroring_id, # type: str - private_cloud_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + self, resource_group_name: str, port_mirroring_id: str, private_cloud_name: str, **kwargs: Any + ) -> LROPoller[None]: """Delete a port mirroring profile by id in a private cloud workload network. Delete a port mirroring profile by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param port_mirroring_id: NSX Port Mirroring identifier. Generally the same as the Port - Mirroring display name. + Mirroring display name. Required. :type port_mirroring_id: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_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_port_mirroring_initial( + raw_result = self._delete_port_mirroring_initial( # type: ignore resource_group_name=resource_group_name, port_mirroring_id=port_mirroring_id, private_cloud_name=private_cloud_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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'portMirroringId': self._serialize.url("port_mirroring_id", port_mirroring_id, 'str'), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_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_port_mirroring.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/portMirroringProfiles/{portMirroringId}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_port_mirroring.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/portMirroringProfiles/{portMirroringId}"} # type: ignore + @distributed_trace def list_vm_groups( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.WorkloadNetworkVMGroupsList"] + self, resource_group_name: str, private_cloud_name: str, **kwargs: Any + ) -> Iterable["_models.WorkloadNetworkVMGroup"]: """List of vm groups in a private cloud workload network. List of vm groups in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WorkloadNetworkVMGroupsList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.avs.models.WorkloadNetworkVMGroupsList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either WorkloadNetworkVMGroup or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.avs.models.WorkloadNetworkVMGroup] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkVMGroupsList"] + _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.WorkloadNetworkVMGroupsList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_vm_groups.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - } - url = self._client.format_url(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_vm_groups_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_vm_groups.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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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('WorkloadNetworkVMGroupsList', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkVMGroupsList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1867,7 +4093,9 @@ 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]: @@ -1876,118 +4104,128 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_vm_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/vmGroups'} # type: ignore + return ItemPaged(get_next, extract_data) + + list_vm_groups.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/vmGroups"} # type: ignore + @distributed_trace def get_vm_group( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - vm_group_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.WorkloadNetworkVMGroup" + self, resource_group_name: str, private_cloud_name: str, vm_group_id: str, **kwargs: Any + ) -> _models.WorkloadNetworkVMGroup: """Get a vm group by id in a private cloud workload network. Get a vm group by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :param vm_group_id: NSX VM Group identifier. Generally the same as the VM Group's display name. + Required. :type vm_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: WorkloadNetworkVMGroup, or the result of cls(response) + :return: WorkloadNetworkVMGroup or the result of cls(response) :rtype: ~azure.mgmt.avs.models.WorkloadNetworkVMGroup - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkVMGroup"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.get_vm_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'vmGroupId': self._serialize.url("vm_group_id", vm_group_id, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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.WorkloadNetworkVMGroup] + + request = build_get_vm_group_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + vm_group_id=vm_group_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_vm_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('WorkloadNetworkVMGroup', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkVMGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_vm_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/vmGroups/{vmGroupId}'} # type: ignore + + get_vm_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/vmGroups/{vmGroupId}"} # type: ignore def _create_vm_group_initial( self, - resource_group_name, # type: str - private_cloud_name, # type: str - vm_group_id, # type: str - workload_network_vm_group, # type: "_models.WorkloadNetworkVMGroup" - **kwargs # type: Any - ): - # type: (...) -> "_models.WorkloadNetworkVMGroup" - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkVMGroup"] + resource_group_name: str, + private_cloud_name: str, + vm_group_id: str, + workload_network_vm_group: Union[_models.WorkloadNetworkVMGroup, IO], + **kwargs: Any + ) -> _models.WorkloadNetworkVMGroup: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_vm_group_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'vmGroupId': self._serialize.url("vm_group_id", vm_group_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') - - # 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(workload_network_vm_group, 'WorkloadNetworkVMGroup') - 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) + 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.WorkloadNetworkVMGroup] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(workload_network_vm_group, (IO, bytes)): + _content = workload_network_vm_group + else: + _json = self._serialize.body(workload_network_vm_group, "WorkloadNetworkVMGroup") + + request = build_create_vm_group_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + vm_group_id=vm_group_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_vm_group_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]: @@ -1995,138 +4233,239 @@ def _create_vm_group_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('WorkloadNetworkVMGroup', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkVMGroup", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('WorkloadNetworkVMGroup', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkVMGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_vm_group_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/vmGroups/{vmGroupId}'} # type: ignore + _create_vm_group_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/vmGroups/{vmGroupId}"} # type: ignore + + @overload def begin_create_vm_group( self, - resource_group_name, # type: str - private_cloud_name, # type: str - vm_group_id, # type: str - workload_network_vm_group, # type: "_models.WorkloadNetworkVMGroup" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.WorkloadNetworkVMGroup"] + resource_group_name: str, + private_cloud_name: str, + vm_group_id: str, + workload_network_vm_group: _models.WorkloadNetworkVMGroup, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WorkloadNetworkVMGroup]: """Create a vm group by id in a private cloud workload network. Create a vm group by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :param vm_group_id: NSX VM Group identifier. Generally the same as the VM Group's display name. + Required. :type vm_group_id: str - :param workload_network_vm_group: NSX VM Group. + :param workload_network_vm_group: NSX VM Group. Required. :type workload_network_vm_group: ~azure.mgmt.avs.models.WorkloadNetworkVMGroup + :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 WorkloadNetworkVMGroup 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 WorkloadNetworkVMGroup or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.WorkloadNetworkVMGroup] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkVMGroup"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_vm_group( + self, + resource_group_name: str, + private_cloud_name: str, + vm_group_id: str, + workload_network_vm_group: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WorkloadNetworkVMGroup]: + """Create a vm group by id in a private cloud workload network. + + Create a vm group by id in a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param vm_group_id: NSX VM Group identifier. Generally the same as the VM Group's display name. + Required. + :type vm_group_id: str + :param workload_network_vm_group: NSX VM Group. Required. + :type workload_network_vm_group: 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 WorkloadNetworkVMGroup or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.WorkloadNetworkVMGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_vm_group( + self, + resource_group_name: str, + private_cloud_name: str, + vm_group_id: str, + workload_network_vm_group: Union[_models.WorkloadNetworkVMGroup, IO], + **kwargs: Any + ) -> LROPoller[_models.WorkloadNetworkVMGroup]: + """Create a vm group by id in a private cloud workload network. + + Create a vm group by id in a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param vm_group_id: NSX VM Group identifier. Generally the same as the VM Group's display name. + Required. + :type vm_group_id: str + :param workload_network_vm_group: NSX VM Group. Is either a model type or a IO type. Required. + :type workload_network_vm_group: ~azure.mgmt.avs.models.WorkloadNetworkVMGroup 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 WorkloadNetworkVMGroup or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.WorkloadNetworkVMGroup] + :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.WorkloadNetworkVMGroup] + 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_vm_group_initial( + raw_result = self._create_vm_group_initial( # type: ignore resource_group_name=resource_group_name, private_cloud_name=private_cloud_name, vm_group_id=vm_group_id, workload_network_vm_group=workload_network_vm_group, - 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('WorkloadNetworkVMGroup', pipeline_response) - + deserialized = self._deserialize("WorkloadNetworkVMGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'vmGroupId': self._serialize.url("vm_group_id", vm_group_id, '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_create_vm_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/vmGroups/{vmGroupId}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_vm_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/vmGroups/{vmGroupId}"} # type: ignore def _update_vm_group_initial( self, - resource_group_name, # type: str - private_cloud_name, # type: str - vm_group_id, # type: str - workload_network_vm_group, # type: "_models.WorkloadNetworkVMGroup" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.WorkloadNetworkVMGroup"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WorkloadNetworkVMGroup"]] + resource_group_name: str, + private_cloud_name: str, + vm_group_id: str, + workload_network_vm_group: Union[_models.WorkloadNetworkVMGroup, IO], + **kwargs: Any + ) -> Optional[_models.WorkloadNetworkVMGroup]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_vm_group_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'vmGroupId': self._serialize.url("vm_group_id", vm_group_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') - - # 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(workload_network_vm_group, 'WorkloadNetworkVMGroup') - 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) + 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.WorkloadNetworkVMGroup]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(workload_network_vm_group, (IO, bytes)): + _content = workload_network_vm_group + else: + _json = self._serialize.body(workload_network_vm_group, "WorkloadNetworkVMGroup") + + request = build_update_vm_group_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + vm_group_id=vm_group_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_vm_group_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]: @@ -2135,129 +4474,219 @@ def _update_vm_group_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('WorkloadNetworkVMGroup', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkVMGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_vm_group_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/vmGroups/{vmGroupId}'} # type: ignore + _update_vm_group_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/vmGroups/{vmGroupId}"} # type: ignore + + @overload def begin_update_vm_group( self, - resource_group_name, # type: str - private_cloud_name, # type: str - vm_group_id, # type: str - workload_network_vm_group, # type: "_models.WorkloadNetworkVMGroup" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.WorkloadNetworkVMGroup"] + resource_group_name: str, + private_cloud_name: str, + vm_group_id: str, + workload_network_vm_group: _models.WorkloadNetworkVMGroup, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WorkloadNetworkVMGroup]: """Create or update a vm group by id in a private cloud workload network. Create or update a vm group by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :param vm_group_id: NSX VM Group identifier. Generally the same as the VM Group's display name. + Required. :type vm_group_id: str - :param workload_network_vm_group: NSX VM Group. + :param workload_network_vm_group: NSX VM Group. Required. :type workload_network_vm_group: ~azure.mgmt.avs.models.WorkloadNetworkVMGroup + :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 WorkloadNetworkVMGroup 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 WorkloadNetworkVMGroup or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.WorkloadNetworkVMGroup] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkVMGroup"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_update_vm_group( + self, + resource_group_name: str, + private_cloud_name: str, + vm_group_id: str, + workload_network_vm_group: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WorkloadNetworkVMGroup]: + """Create or update a vm group by id in a private cloud workload network. + + Create or update a vm group by id in a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param vm_group_id: NSX VM Group identifier. Generally the same as the VM Group's display name. + Required. + :type vm_group_id: str + :param workload_network_vm_group: NSX VM Group. Required. + :type workload_network_vm_group: 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 WorkloadNetworkVMGroup or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.WorkloadNetworkVMGroup] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_vm_group( + self, + resource_group_name: str, + private_cloud_name: str, + vm_group_id: str, + workload_network_vm_group: Union[_models.WorkloadNetworkVMGroup, IO], + **kwargs: Any + ) -> LROPoller[_models.WorkloadNetworkVMGroup]: + """Create or update a vm group by id in a private cloud workload network. + + Create or update a vm group by id in a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param vm_group_id: NSX VM Group identifier. Generally the same as the VM Group's display name. + Required. + :type vm_group_id: str + :param workload_network_vm_group: NSX VM Group. Is either a model type or a IO type. Required. + :type workload_network_vm_group: ~azure.mgmt.avs.models.WorkloadNetworkVMGroup 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 WorkloadNetworkVMGroup or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.WorkloadNetworkVMGroup] + :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.WorkloadNetworkVMGroup] + 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_vm_group_initial( + raw_result = self._update_vm_group_initial( # type: ignore resource_group_name=resource_group_name, private_cloud_name=private_cloud_name, vm_group_id=vm_group_id, workload_network_vm_group=workload_network_vm_group, - 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('WorkloadNetworkVMGroup', pipeline_response) - + deserialized = self._deserialize("WorkloadNetworkVMGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'vmGroupId': self._serialize.url("vm_group_id", vm_group_id, '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_vm_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/vmGroups/{vmGroupId}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def _delete_vm_group_initial( - self, - resource_group_name, # type: str - vm_group_id, # type: str - private_cloud_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_update_vm_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/vmGroups/{vmGroupId}"} # type: ignore + + def _delete_vm_group_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, vm_group_id: str, private_cloud_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_vm_group_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'vmGroupId': self._serialize.url("vm_group_id", vm_group_id, 'str'), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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_vm_group_request( + resource_group_name=resource_group_name, + vm_group_id=vm_group_id, + private_cloud_name=private_cloud_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_vm_group_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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]: @@ -2267,135 +4696,146 @@ def _delete_vm_group_initial( if cls: return cls(pipeline_response, None, {}) - _delete_vm_group_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/vmGroups/{vmGroupId}'} # type: ignore + _delete_vm_group_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/vmGroups/{vmGroupId}"} # type: ignore + @distributed_trace def begin_delete_vm_group( - self, - resource_group_name, # type: str - vm_group_id, # type: str - private_cloud_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + self, resource_group_name: str, vm_group_id: str, private_cloud_name: str, **kwargs: Any + ) -> LROPoller[None]: """Delete a vm group by id in a private cloud workload network. Delete a vm group by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param vm_group_id: NSX VM Group identifier. Generally the same as the VM Group's display name. + Required. :type vm_group_id: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_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_vm_group_initial( + raw_result = self._delete_vm_group_initial( # type: ignore resource_group_name=resource_group_name, vm_group_id=vm_group_id, private_cloud_name=private_cloud_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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'vmGroupId': self._serialize.url("vm_group_id", vm_group_id, 'str'), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_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_vm_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/vmGroups/{vmGroupId}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_vm_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/vmGroups/{vmGroupId}"} # type: ignore + @distributed_trace def list_virtual_machines( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.WorkloadNetworkVirtualMachinesList"] + self, resource_group_name: str, private_cloud_name: str, **kwargs: Any + ) -> Iterable["_models.WorkloadNetworkVirtualMachine"]: """List of virtual machines in a private cloud workload network. List of virtual machines in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WorkloadNetworkVirtualMachinesList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.avs.models.WorkloadNetworkVirtualMachinesList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either WorkloadNetworkVirtualMachine or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.avs.models.WorkloadNetworkVirtualMachine] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkVirtualMachinesList"] + _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.WorkloadNetworkVirtualMachinesList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_virtual_machines.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - } - url = self._client.format_url(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_virtual_machines_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_virtual_machines.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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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('WorkloadNetworkVirtualMachinesList', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkVirtualMachinesList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -2404,7 +4844,9 @@ 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]: @@ -2413,131 +4855,144 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_virtual_machines.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/virtualMachines'} # type: ignore + return ItemPaged(get_next, extract_data) + + list_virtual_machines.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/virtualMachines"} # type: ignore + @distributed_trace def get_virtual_machine( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - virtual_machine_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.WorkloadNetworkVirtualMachine" + self, resource_group_name: str, private_cloud_name: str, virtual_machine_id: str, **kwargs: Any + ) -> _models.WorkloadNetworkVirtualMachine: """Get a virtual machine by id in a private cloud workload network. Get a virtual machine by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str - :param virtual_machine_id: Virtual Machine identifier. + :param virtual_machine_id: Virtual Machine identifier. Required. :type virtual_machine_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: WorkloadNetworkVirtualMachine, or the result of cls(response) + :return: WorkloadNetworkVirtualMachine or the result of cls(response) :rtype: ~azure.mgmt.avs.models.WorkloadNetworkVirtualMachine - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkVirtualMachine"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.get_virtual_machine.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'virtualMachineId': self._serialize.url("virtual_machine_id", virtual_machine_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') + 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.WorkloadNetworkVirtualMachine] + + request = build_get_virtual_machine_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + virtual_machine_id=virtual_machine_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_virtual_machine.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('WorkloadNetworkVirtualMachine', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkVirtualMachine", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_virtual_machine.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/virtualMachines/{virtualMachineId}'} # type: ignore + get_virtual_machine.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/virtualMachines/{virtualMachineId}"} # type: ignore + + @distributed_trace def list_dns_services( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.WorkloadNetworkDnsServicesList"] + self, resource_group_name: str, private_cloud_name: str, **kwargs: Any + ) -> Iterable["_models.WorkloadNetworkDnsService"]: """List of DNS services in a private cloud workload network. List of DNS services in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WorkloadNetworkDnsServicesList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.avs.models.WorkloadNetworkDnsServicesList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either WorkloadNetworkDnsService or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.avs.models.WorkloadNetworkDnsService] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkDnsServicesList"] + _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.WorkloadNetworkDnsServicesList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_dns_services.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - } - url = self._client.format_url(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_dns_services_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_dns_services.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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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('WorkloadNetworkDnsServicesList', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkDnsServicesList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -2546,7 +5001,9 @@ 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]: @@ -2555,119 +5012,128 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_dns_services.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsServices'} # type: ignore + return ItemPaged(get_next, extract_data) + list_dns_services.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsServices"} # type: ignore + + @distributed_trace def get_dns_service( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - dns_service_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.WorkloadNetworkDnsService" + self, resource_group_name: str, private_cloud_name: str, dns_service_id: str, **kwargs: Any + ) -> _models.WorkloadNetworkDnsService: """Get a DNS service by id in a private cloud workload network. Get a DNS service by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :param dns_service_id: NSX DNS Service identifier. Generally the same as the DNS Service's - display name. + display name. Required. :type dns_service_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: WorkloadNetworkDnsService, or the result of cls(response) + :return: WorkloadNetworkDnsService or the result of cls(response) :rtype: ~azure.mgmt.avs.models.WorkloadNetworkDnsService - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkDnsService"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.get_dns_service.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'dnsServiceId': self._serialize.url("dns_service_id", dns_service_id, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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.WorkloadNetworkDnsService] + + request = build_get_dns_service_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + dns_service_id=dns_service_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_dns_service.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('WorkloadNetworkDnsService', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkDnsService", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_dns_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsServices/{dnsServiceId}'} # type: ignore + + get_dns_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsServices/{dnsServiceId}"} # type: ignore def _create_dns_service_initial( self, - resource_group_name, # type: str - private_cloud_name, # type: str - dns_service_id, # type: str - workload_network_dns_service, # type: "_models.WorkloadNetworkDnsService" - **kwargs # type: Any - ): - # type: (...) -> "_models.WorkloadNetworkDnsService" - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkDnsService"] + resource_group_name: str, + private_cloud_name: str, + dns_service_id: str, + workload_network_dns_service: Union[_models.WorkloadNetworkDnsService, IO], + **kwargs: Any + ) -> _models.WorkloadNetworkDnsService: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_dns_service_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'dnsServiceId': self._serialize.url("dns_service_id", dns_service_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') - - # 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(workload_network_dns_service, 'WorkloadNetworkDnsService') - 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) + 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.WorkloadNetworkDnsService] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(workload_network_dns_service, (IO, bytes)): + _content = workload_network_dns_service + else: + _json = self._serialize.body(workload_network_dns_service, "WorkloadNetworkDnsService") + + request = build_create_dns_service_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + dns_service_id=dns_service_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_dns_service_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]: @@ -2675,139 +5141,240 @@ def _create_dns_service_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('WorkloadNetworkDnsService', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkDnsService", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('WorkloadNetworkDnsService', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkDnsService", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_dns_service_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsServices/{dnsServiceId}'} # type: ignore + _create_dns_service_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsServices/{dnsServiceId}"} # type: ignore + + @overload def begin_create_dns_service( self, - resource_group_name, # type: str - private_cloud_name, # type: str - dns_service_id, # type: str - workload_network_dns_service, # type: "_models.WorkloadNetworkDnsService" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.WorkloadNetworkDnsService"] + resource_group_name: str, + private_cloud_name: str, + dns_service_id: str, + workload_network_dns_service: _models.WorkloadNetworkDnsService, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WorkloadNetworkDnsService]: """Create a DNS service by id in a private cloud workload network. Create a DNS service by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :param dns_service_id: NSX DNS Service identifier. Generally the same as the DNS Service's - display name. + display name. Required. :type dns_service_id: str - :param workload_network_dns_service: NSX DNS Service. + :param workload_network_dns_service: NSX DNS Service. Required. :type workload_network_dns_service: ~azure.mgmt.avs.models.WorkloadNetworkDnsService + :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 WorkloadNetworkDnsService 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 WorkloadNetworkDnsService or the result + of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.WorkloadNetworkDnsService] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkDnsService"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_dns_service( + self, + resource_group_name: str, + private_cloud_name: str, + dns_service_id: str, + workload_network_dns_service: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WorkloadNetworkDnsService]: + """Create a DNS service by id in a private cloud workload network. + + Create a DNS service by id in a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param dns_service_id: NSX DNS Service identifier. Generally the same as the DNS Service's + display name. Required. + :type dns_service_id: str + :param workload_network_dns_service: NSX DNS Service. Required. + :type workload_network_dns_service: 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 WorkloadNetworkDnsService or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.WorkloadNetworkDnsService] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_dns_service( + self, + resource_group_name: str, + private_cloud_name: str, + dns_service_id: str, + workload_network_dns_service: Union[_models.WorkloadNetworkDnsService, IO], + **kwargs: Any + ) -> LROPoller[_models.WorkloadNetworkDnsService]: + """Create a DNS service by id in a private cloud workload network. + + Create a DNS service by id in a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param dns_service_id: NSX DNS Service identifier. Generally the same as the DNS Service's + display name. Required. + :type dns_service_id: str + :param workload_network_dns_service: NSX DNS Service. Is either a model type or a IO type. + Required. + :type workload_network_dns_service: ~azure.mgmt.avs.models.WorkloadNetworkDnsService 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 WorkloadNetworkDnsService or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.WorkloadNetworkDnsService] + :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.WorkloadNetworkDnsService] + 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_dns_service_initial( + raw_result = self._create_dns_service_initial( # type: ignore resource_group_name=resource_group_name, private_cloud_name=private_cloud_name, dns_service_id=dns_service_id, workload_network_dns_service=workload_network_dns_service, - 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('WorkloadNetworkDnsService', pipeline_response) - + deserialized = self._deserialize("WorkloadNetworkDnsService", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'dnsServiceId': self._serialize.url("dns_service_id", dns_service_id, '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_create_dns_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsServices/{dnsServiceId}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_dns_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsServices/{dnsServiceId}"} # type: ignore def _update_dns_service_initial( self, - resource_group_name, # type: str - private_cloud_name, # type: str - dns_service_id, # type: str - workload_network_dns_service, # type: "_models.WorkloadNetworkDnsService" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.WorkloadNetworkDnsService"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WorkloadNetworkDnsService"]] + resource_group_name: str, + private_cloud_name: str, + dns_service_id: str, + workload_network_dns_service: Union[_models.WorkloadNetworkDnsService, IO], + **kwargs: Any + ) -> Optional[_models.WorkloadNetworkDnsService]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_dns_service_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'dnsServiceId': self._serialize.url("dns_service_id", dns_service_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') - - # 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(workload_network_dns_service, 'WorkloadNetworkDnsService') - 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) + 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.WorkloadNetworkDnsService]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(workload_network_dns_service, (IO, bytes)): + _content = workload_network_dns_service + else: + _json = self._serialize.body(workload_network_dns_service, "WorkloadNetworkDnsService") + + request = build_update_dns_service_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + dns_service_id=dns_service_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_dns_service_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]: @@ -2816,130 +5383,220 @@ def _update_dns_service_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('WorkloadNetworkDnsService', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkDnsService", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_dns_service_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsServices/{dnsServiceId}'} # type: ignore + _update_dns_service_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsServices/{dnsServiceId}"} # type: ignore + + @overload + def begin_update_dns_service( + self, + resource_group_name: str, + private_cloud_name: str, + dns_service_id: str, + workload_network_dns_service: _models.WorkloadNetworkDnsService, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WorkloadNetworkDnsService]: + """Create or update a DNS service by id in a private cloud workload network. + + Create or update a DNS service by id in a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param dns_service_id: NSX DNS Service identifier. Generally the same as the DNS Service's + display name. Required. + :type dns_service_id: str + :param workload_network_dns_service: NSX DNS Service. Required. + :type workload_network_dns_service: ~azure.mgmt.avs.models.WorkloadNetworkDnsService + :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 WorkloadNetworkDnsService or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.WorkloadNetworkDnsService] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update_dns_service( + self, + resource_group_name: str, + private_cloud_name: str, + dns_service_id: str, + workload_network_dns_service: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WorkloadNetworkDnsService]: + """Create or update a DNS service by id in a private cloud workload network. + + Create or update a DNS service by id in a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param dns_service_id: NSX DNS Service identifier. Generally the same as the DNS Service's + display name. Required. + :type dns_service_id: str + :param workload_network_dns_service: NSX DNS Service. Required. + :type workload_network_dns_service: 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 WorkloadNetworkDnsService or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.WorkloadNetworkDnsService] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace def begin_update_dns_service( self, - resource_group_name, # type: str - private_cloud_name, # type: str - dns_service_id, # type: str - workload_network_dns_service, # type: "_models.WorkloadNetworkDnsService" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.WorkloadNetworkDnsService"] + resource_group_name: str, + private_cloud_name: str, + dns_service_id: str, + workload_network_dns_service: Union[_models.WorkloadNetworkDnsService, IO], + **kwargs: Any + ) -> LROPoller[_models.WorkloadNetworkDnsService]: """Create or update a DNS service by id in a private cloud workload network. Create or update a DNS service by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :param dns_service_id: NSX DNS Service identifier. Generally the same as the DNS Service's - display name. + display name. Required. :type dns_service_id: str - :param workload_network_dns_service: NSX DNS Service. - :type workload_network_dns_service: ~azure.mgmt.avs.models.WorkloadNetworkDnsService + :param workload_network_dns_service: NSX DNS Service. Is either a model type or a IO type. + Required. + :type workload_network_dns_service: ~azure.mgmt.avs.models.WorkloadNetworkDnsService 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. + :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 WorkloadNetworkDnsService 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 WorkloadNetworkDnsService or the result + of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.WorkloadNetworkDnsService] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkDnsService"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _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.WorkloadNetworkDnsService] + 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_dns_service_initial( + raw_result = self._update_dns_service_initial( # type: ignore resource_group_name=resource_group_name, private_cloud_name=private_cloud_name, dns_service_id=dns_service_id, workload_network_dns_service=workload_network_dns_service, - 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('WorkloadNetworkDnsService', pipeline_response) - + deserialized = self._deserialize("WorkloadNetworkDnsService", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'dnsServiceId': self._serialize.url("dns_service_id", dns_service_id, '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_dns_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsServices/{dnsServiceId}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def _delete_dns_service_initial( - self, - resource_group_name, # type: str - dns_service_id, # type: str - private_cloud_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_update_dns_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsServices/{dnsServiceId}"} # type: ignore + + def _delete_dns_service_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, dns_service_id: str, private_cloud_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_dns_service_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'dnsServiceId': self._serialize.url("dns_service_id", dns_service_id, 'str'), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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_dns_service_request( + resource_group_name=resource_group_name, + dns_service_id=dns_service_id, + private_cloud_name=private_cloud_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_dns_service_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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]: @@ -2949,136 +5606,146 @@ def _delete_dns_service_initial( if cls: return cls(pipeline_response, None, {}) - _delete_dns_service_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsServices/{dnsServiceId}'} # type: ignore + _delete_dns_service_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsServices/{dnsServiceId}"} # type: ignore + @distributed_trace def begin_delete_dns_service( - self, - resource_group_name, # type: str - dns_service_id, # type: str - private_cloud_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + self, resource_group_name: str, dns_service_id: str, private_cloud_name: str, **kwargs: Any + ) -> LROPoller[None]: """Delete a DNS service by id in a private cloud workload network. Delete a DNS service by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dns_service_id: NSX DNS Service identifier. Generally the same as the DNS Service's - display name. + display name. Required. :type dns_service_id: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_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_dns_service_initial( + raw_result = self._delete_dns_service_initial( # type: ignore resource_group_name=resource_group_name, dns_service_id=dns_service_id, private_cloud_name=private_cloud_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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'dnsServiceId': self._serialize.url("dns_service_id", dns_service_id, 'str'), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_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_dns_service.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsServices/{dnsServiceId}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_dns_service.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsServices/{dnsServiceId}"} # type: ignore + @distributed_trace def list_dns_zones( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.WorkloadNetworkDnsZonesList"] + self, resource_group_name: str, private_cloud_name: str, **kwargs: Any + ) -> Iterable["_models.WorkloadNetworkDnsZone"]: """List of DNS zones in a private cloud workload network. List of DNS zones in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WorkloadNetworkDnsZonesList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.avs.models.WorkloadNetworkDnsZonesList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either WorkloadNetworkDnsZone or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.avs.models.WorkloadNetworkDnsZone] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkDnsZonesList"] + _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.WorkloadNetworkDnsZonesList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_dns_zones.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - } - url = self._client.format_url(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_dns_zones_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_dns_zones.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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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('WorkloadNetworkDnsZonesList', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkDnsZonesList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -3087,7 +5754,9 @@ 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]: @@ -3096,118 +5765,128 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_dns_zones.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsZones'} # type: ignore + return ItemPaged(get_next, extract_data) + + list_dns_zones.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsZones"} # type: ignore + @distributed_trace def get_dns_zone( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - dns_zone_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.WorkloadNetworkDnsZone" + self, resource_group_name: str, private_cloud_name: str, dns_zone_id: str, **kwargs: Any + ) -> _models.WorkloadNetworkDnsZone: """Get a DNS zone by id in a private cloud workload network. Get a DNS zone by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :param dns_zone_id: NSX DNS Zone identifier. Generally the same as the DNS Zone's display name. + Required. :type dns_zone_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: WorkloadNetworkDnsZone, or the result of cls(response) + :return: WorkloadNetworkDnsZone or the result of cls(response) :rtype: ~azure.mgmt.avs.models.WorkloadNetworkDnsZone - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkDnsZone"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.get_dns_zone.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'dnsZoneId': self._serialize.url("dns_zone_id", dns_zone_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') + 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.WorkloadNetworkDnsZone] + + request = build_get_dns_zone_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + dns_zone_id=dns_zone_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_dns_zone.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('WorkloadNetworkDnsZone', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkDnsZone", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_dns_zone.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsZones/{dnsZoneId}'} # type: ignore + + get_dns_zone.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsZones/{dnsZoneId}"} # type: ignore def _create_dns_zone_initial( self, - resource_group_name, # type: str - private_cloud_name, # type: str - dns_zone_id, # type: str - workload_network_dns_zone, # type: "_models.WorkloadNetworkDnsZone" - **kwargs # type: Any - ): - # type: (...) -> "_models.WorkloadNetworkDnsZone" - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkDnsZone"] + resource_group_name: str, + private_cloud_name: str, + dns_zone_id: str, + workload_network_dns_zone: Union[_models.WorkloadNetworkDnsZone, IO], + **kwargs: Any + ) -> _models.WorkloadNetworkDnsZone: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_dns_zone_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'dnsZoneId': self._serialize.url("dns_zone_id", dns_zone_id, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(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(workload_network_dns_zone, 'WorkloadNetworkDnsZone') - 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) + 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.WorkloadNetworkDnsZone] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(workload_network_dns_zone, (IO, bytes)): + _content = workload_network_dns_zone + else: + _json = self._serialize.body(workload_network_dns_zone, "WorkloadNetworkDnsZone") + + request = build_create_dns_zone_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + dns_zone_id=dns_zone_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_dns_zone_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]: @@ -3215,138 +5894,239 @@ def _create_dns_zone_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('WorkloadNetworkDnsZone', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkDnsZone", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('WorkloadNetworkDnsZone', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkDnsZone", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_dns_zone_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsZones/{dnsZoneId}'} # type: ignore + _create_dns_zone_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsZones/{dnsZoneId}"} # type: ignore + + @overload def begin_create_dns_zone( self, - resource_group_name, # type: str - private_cloud_name, # type: str - dns_zone_id, # type: str - workload_network_dns_zone, # type: "_models.WorkloadNetworkDnsZone" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.WorkloadNetworkDnsZone"] + resource_group_name: str, + private_cloud_name: str, + dns_zone_id: str, + workload_network_dns_zone: _models.WorkloadNetworkDnsZone, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WorkloadNetworkDnsZone]: """Create a DNS zone by id in a private cloud workload network. Create a DNS zone by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :param dns_zone_id: NSX DNS Zone identifier. Generally the same as the DNS Zone's display name. + Required. :type dns_zone_id: str - :param workload_network_dns_zone: NSX DNS Zone. + :param workload_network_dns_zone: NSX DNS Zone. Required. :type workload_network_dns_zone: ~azure.mgmt.avs.models.WorkloadNetworkDnsZone + :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 WorkloadNetworkDnsZone 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 WorkloadNetworkDnsZone or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.WorkloadNetworkDnsZone] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkDnsZone"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_dns_zone( + self, + resource_group_name: str, + private_cloud_name: str, + dns_zone_id: str, + workload_network_dns_zone: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WorkloadNetworkDnsZone]: + """Create a DNS zone by id in a private cloud workload network. + + Create a DNS zone by id in a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param dns_zone_id: NSX DNS Zone identifier. Generally the same as the DNS Zone's display name. + Required. + :type dns_zone_id: str + :param workload_network_dns_zone: NSX DNS Zone. Required. + :type workload_network_dns_zone: 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 WorkloadNetworkDnsZone or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.WorkloadNetworkDnsZone] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_dns_zone( + self, + resource_group_name: str, + private_cloud_name: str, + dns_zone_id: str, + workload_network_dns_zone: Union[_models.WorkloadNetworkDnsZone, IO], + **kwargs: Any + ) -> LROPoller[_models.WorkloadNetworkDnsZone]: + """Create a DNS zone by id in a private cloud workload network. + + Create a DNS zone by id in a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param dns_zone_id: NSX DNS Zone identifier. Generally the same as the DNS Zone's display name. + Required. + :type dns_zone_id: str + :param workload_network_dns_zone: NSX DNS Zone. Is either a model type or a IO type. Required. + :type workload_network_dns_zone: ~azure.mgmt.avs.models.WorkloadNetworkDnsZone 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 WorkloadNetworkDnsZone or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.WorkloadNetworkDnsZone] + :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.WorkloadNetworkDnsZone] + 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_dns_zone_initial( + raw_result = self._create_dns_zone_initial( # type: ignore resource_group_name=resource_group_name, private_cloud_name=private_cloud_name, dns_zone_id=dns_zone_id, workload_network_dns_zone=workload_network_dns_zone, - 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('WorkloadNetworkDnsZone', pipeline_response) - + deserialized = self._deserialize("WorkloadNetworkDnsZone", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'dnsZoneId': self._serialize.url("dns_zone_id", dns_zone_id, '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_create_dns_zone.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsZones/{dnsZoneId}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_dns_zone.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsZones/{dnsZoneId}"} # type: ignore def _update_dns_zone_initial( self, - resource_group_name, # type: str - private_cloud_name, # type: str - dns_zone_id, # type: str - workload_network_dns_zone, # type: "_models.WorkloadNetworkDnsZone" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.WorkloadNetworkDnsZone"] - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.WorkloadNetworkDnsZone"]] + resource_group_name: str, + private_cloud_name: str, + dns_zone_id: str, + workload_network_dns_zone: Union[_models.WorkloadNetworkDnsZone, IO], + **kwargs: Any + ) -> Optional[_models.WorkloadNetworkDnsZone]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_dns_zone_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'dnsZoneId': self._serialize.url("dns_zone_id", dns_zone_id, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(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(workload_network_dns_zone, 'WorkloadNetworkDnsZone') - 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) + 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.WorkloadNetworkDnsZone]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(workload_network_dns_zone, (IO, bytes)): + _content = workload_network_dns_zone + else: + _json = self._serialize.body(workload_network_dns_zone, "WorkloadNetworkDnsZone") + + request = build_update_dns_zone_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + dns_zone_id=dns_zone_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_dns_zone_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]: @@ -3355,129 +6135,219 @@ def _update_dns_zone_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('WorkloadNetworkDnsZone', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkDnsZone", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_dns_zone_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsZones/{dnsZoneId}'} # type: ignore + _update_dns_zone_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsZones/{dnsZoneId}"} # type: ignore + + @overload def begin_update_dns_zone( self, - resource_group_name, # type: str - private_cloud_name, # type: str - dns_zone_id, # type: str - workload_network_dns_zone, # type: "_models.WorkloadNetworkDnsZone" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.WorkloadNetworkDnsZone"] + resource_group_name: str, + private_cloud_name: str, + dns_zone_id: str, + workload_network_dns_zone: _models.WorkloadNetworkDnsZone, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WorkloadNetworkDnsZone]: """Create or update a DNS zone by id in a private cloud workload network. Create or update a DNS zone by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :param dns_zone_id: NSX DNS Zone identifier. Generally the same as the DNS Zone's display name. + Required. :type dns_zone_id: str - :param workload_network_dns_zone: NSX DNS Zone. + :param workload_network_dns_zone: NSX DNS Zone. Required. :type workload_network_dns_zone: ~azure.mgmt.avs.models.WorkloadNetworkDnsZone + :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 WorkloadNetworkDnsZone 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 WorkloadNetworkDnsZone or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.WorkloadNetworkDnsZone] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkDnsZone"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_update_dns_zone( + self, + resource_group_name: str, + private_cloud_name: str, + dns_zone_id: str, + workload_network_dns_zone: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WorkloadNetworkDnsZone]: + """Create or update a DNS zone by id in a private cloud workload network. + + Create or update a DNS zone by id in a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param dns_zone_id: NSX DNS Zone identifier. Generally the same as the DNS Zone's display name. + Required. + :type dns_zone_id: str + :param workload_network_dns_zone: NSX DNS Zone. Required. + :type workload_network_dns_zone: 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 WorkloadNetworkDnsZone or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.WorkloadNetworkDnsZone] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_dns_zone( + self, + resource_group_name: str, + private_cloud_name: str, + dns_zone_id: str, + workload_network_dns_zone: Union[_models.WorkloadNetworkDnsZone, IO], + **kwargs: Any + ) -> LROPoller[_models.WorkloadNetworkDnsZone]: + """Create or update a DNS zone by id in a private cloud workload network. + + Create or update a DNS zone by id in a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param dns_zone_id: NSX DNS Zone identifier. Generally the same as the DNS Zone's display name. + Required. + :type dns_zone_id: str + :param workload_network_dns_zone: NSX DNS Zone. Is either a model type or a IO type. Required. + :type workload_network_dns_zone: ~azure.mgmt.avs.models.WorkloadNetworkDnsZone 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 WorkloadNetworkDnsZone or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.WorkloadNetworkDnsZone] + :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.WorkloadNetworkDnsZone] + 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_dns_zone_initial( + raw_result = self._update_dns_zone_initial( # type: ignore resource_group_name=resource_group_name, private_cloud_name=private_cloud_name, dns_zone_id=dns_zone_id, workload_network_dns_zone=workload_network_dns_zone, - 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('WorkloadNetworkDnsZone', pipeline_response) - + deserialized = self._deserialize("WorkloadNetworkDnsZone", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'dnsZoneId': self._serialize.url("dns_zone_id", dns_zone_id, '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_dns_zone.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsZones/{dnsZoneId}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def _delete_dns_zone_initial( - self, - resource_group_name, # type: str - dns_zone_id, # type: str - private_cloud_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_update_dns_zone.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsZones/{dnsZoneId}"} # type: ignore + + def _delete_dns_zone_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, dns_zone_id: str, private_cloud_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_dns_zone_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'dnsZoneId': self._serialize.url("dns_zone_id", dns_zone_id, 'str'), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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_dns_zone_request( + resource_group_name=resource_group_name, + dns_zone_id=dns_zone_id, + private_cloud_name=private_cloud_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_dns_zone_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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]: @@ -3487,135 +6357,146 @@ def _delete_dns_zone_initial( if cls: return cls(pipeline_response, None, {}) - _delete_dns_zone_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsZones/{dnsZoneId}'} # type: ignore + _delete_dns_zone_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsZones/{dnsZoneId}"} # type: ignore + @distributed_trace def begin_delete_dns_zone( - self, - resource_group_name, # type: str - dns_zone_id, # type: str - private_cloud_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + self, resource_group_name: str, dns_zone_id: str, private_cloud_name: str, **kwargs: Any + ) -> LROPoller[None]: """Delete a DNS zone by id in a private cloud workload network. Delete a DNS zone by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param dns_zone_id: NSX DNS Zone identifier. Generally the same as the DNS Zone's display name. + Required. :type dns_zone_id: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_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_dns_zone_initial( + raw_result = self._delete_dns_zone_initial( # type: ignore resource_group_name=resource_group_name, dns_zone_id=dns_zone_id, private_cloud_name=private_cloud_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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'dnsZoneId': self._serialize.url("dns_zone_id", dns_zone_id, 'str'), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_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_dns_zone.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsZones/{dnsZoneId}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_dns_zone.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dnsZones/{dnsZoneId}"} # type: ignore + + @distributed_trace def list_public_i_ps( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.WorkloadNetworkPublicIPsList"] + self, resource_group_name: str, private_cloud_name: str, **kwargs: Any + ) -> Iterable["_models.WorkloadNetworkPublicIP"]: """List of Public IP Blocks in a private cloud workload network. List of Public IP Blocks in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either WorkloadNetworkPublicIPsList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.avs.models.WorkloadNetworkPublicIPsList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either WorkloadNetworkPublicIP or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.avs.models.WorkloadNetworkPublicIP] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkPublicIPsList"] + _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.WorkloadNetworkPublicIPsList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" + error_map.update(kwargs.pop("error_map", {}) or {}) def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_public_i_ps.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - } - url = self._client.format_url(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_public_i_ps_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_public_i_ps.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 = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.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('WorkloadNetworkPublicIPsList', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkPublicIPsList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -3624,7 +6505,9 @@ 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]: @@ -3633,119 +6516,128 @@ def get_next(next_link=None): return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_public_i_ps.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/publicIPs'} # type: ignore + return ItemPaged(get_next, extract_data) + list_public_i_ps.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/publicIPs"} # type: ignore + + @distributed_trace def get_public_ip( - self, - resource_group_name, # type: str - private_cloud_name, # type: str - public_ip_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.WorkloadNetworkPublicIP" + self, resource_group_name: str, private_cloud_name: str, public_ip_id: str, **kwargs: Any + ) -> _models.WorkloadNetworkPublicIP: """Get a Public IP Block by id in a private cloud workload network. Get a Public IP Block by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :param public_ip_id: NSX Public IP Block identifier. Generally the same as the Public IP - Block's display name. + Block's display name. Required. :type public_ip_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: WorkloadNetworkPublicIP, or the result of cls(response) + :return: WorkloadNetworkPublicIP or the result of cls(response) :rtype: ~azure.mgmt.avs.models.WorkloadNetworkPublicIP - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkPublicIP"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self.get_public_ip.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'publicIPId': self._serialize.url("public_ip_id", public_ip_id, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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.WorkloadNetworkPublicIP] + + request = build_get_public_ip_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + public_ip_id=public_ip_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_public_ip.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('WorkloadNetworkPublicIP', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkPublicIP", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_public_ip.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/publicIPs/{publicIPId}'} # type: ignore + + get_public_ip.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/publicIPs/{publicIPId}"} # type: ignore def _create_public_ip_initial( self, - resource_group_name, # type: str - private_cloud_name, # type: str - public_ip_id, # type: str - workload_network_public_ip, # type: "_models.WorkloadNetworkPublicIP" - **kwargs # type: Any - ): - # type: (...) -> "_models.WorkloadNetworkPublicIP" - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkPublicIP"] + resource_group_name: str, + private_cloud_name: str, + public_ip_id: str, + workload_network_public_ip: Union[_models.WorkloadNetworkPublicIP, IO], + **kwargs: Any + ) -> _models.WorkloadNetworkPublicIP: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_public_ip_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'publicIPId': self._serialize.url("public_ip_id", public_ip_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') - - # 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(workload_network_public_ip, 'WorkloadNetworkPublicIP') - 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) + 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.WorkloadNetworkPublicIP] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(workload_network_public_ip, (IO, bytes)): + _content = workload_network_public_ip + else: + _json = self._serialize.body(workload_network_public_ip, "WorkloadNetworkPublicIP") + + request = build_create_public_ip_request( + resource_group_name=resource_group_name, + private_cloud_name=private_cloud_name, + public_ip_id=public_ip_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_public_ip_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]: @@ -3753,133 +6645,223 @@ def _create_public_ip_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('WorkloadNetworkPublicIP', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkPublicIP", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('WorkloadNetworkPublicIP', pipeline_response) + deserialized = self._deserialize("WorkloadNetworkPublicIP", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_public_ip_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/publicIPs/{publicIPId}'} # type: ignore + _create_public_ip_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/publicIPs/{publicIPId}"} # type: ignore + + @overload def begin_create_public_ip( self, - resource_group_name, # type: str - private_cloud_name, # type: str - public_ip_id, # type: str - workload_network_public_ip, # type: "_models.WorkloadNetworkPublicIP" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.WorkloadNetworkPublicIP"] + resource_group_name: str, + private_cloud_name: str, + public_ip_id: str, + workload_network_public_ip: _models.WorkloadNetworkPublicIP, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WorkloadNetworkPublicIP]: """Create a Public IP Block by id in a private cloud workload network. Create a Public IP Block by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_name: str :param public_ip_id: NSX Public IP Block identifier. Generally the same as the Public IP - Block's display name. + Block's display name. Required. :type public_ip_id: str - :param workload_network_public_ip: NSX Public IP Block. + :param workload_network_public_ip: NSX Public IP Block. Required. :type workload_network_public_ip: ~azure.mgmt.avs.models.WorkloadNetworkPublicIP + :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 WorkloadNetworkPublicIP 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 WorkloadNetworkPublicIP or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.WorkloadNetworkPublicIP] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.WorkloadNetworkPublicIP"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_public_ip( + self, + resource_group_name: str, + private_cloud_name: str, + public_ip_id: str, + workload_network_public_ip: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.WorkloadNetworkPublicIP]: + """Create a Public IP Block by id in a private cloud workload network. + + Create a Public IP Block by id in a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param public_ip_id: NSX Public IP Block identifier. Generally the same as the Public IP + Block's display name. Required. + :type public_ip_id: str + :param workload_network_public_ip: NSX Public IP Block. Required. + :type workload_network_public_ip: 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 WorkloadNetworkPublicIP or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.WorkloadNetworkPublicIP] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_public_ip( + self, + resource_group_name: str, + private_cloud_name: str, + public_ip_id: str, + workload_network_public_ip: Union[_models.WorkloadNetworkPublicIP, IO], + **kwargs: Any + ) -> LROPoller[_models.WorkloadNetworkPublicIP]: + """Create a Public IP Block by id in a private cloud workload network. + + Create a Public IP Block by id in a private cloud workload network. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param private_cloud_name: Name of the private cloud. Required. + :type private_cloud_name: str + :param public_ip_id: NSX Public IP Block identifier. Generally the same as the Public IP + Block's display name. Required. + :type public_ip_id: str + :param workload_network_public_ip: NSX Public IP Block. Is either a model type or a IO type. + Required. + :type workload_network_public_ip: ~azure.mgmt.avs.models.WorkloadNetworkPublicIP 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 WorkloadNetworkPublicIP or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.avs.models.WorkloadNetworkPublicIP] + :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.WorkloadNetworkPublicIP] + 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_public_ip_initial( + raw_result = self._create_public_ip_initial( # type: ignore resource_group_name=resource_group_name, private_cloud_name=private_cloud_name, public_ip_id=public_ip_id, workload_network_public_ip=workload_network_public_ip, - 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('WorkloadNetworkPublicIP', pipeline_response) - + deserialized = self._deserialize("WorkloadNetworkPublicIP", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), - 'publicIPId': self._serialize.url("public_ip_id", public_ip_id, '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_create_public_ip.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/publicIPs/{publicIPId}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def _delete_public_ip_initial( - self, - resource_group_name, # type: str - public_ip_id, # type: str - private_cloud_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create_public_ip.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/publicIPs/{publicIPId}"} # type: ignore + + def _delete_public_ip_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, public_ip_id: str, private_cloud_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-12-01" - accept = "application/json" - - # Construct URL - url = self._delete_public_ip_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'publicIPId': self._serialize.url("public_ip_id", public_ip_id, 'str'), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_name, 'str'), + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) 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_public_ip_request( + resource_group_name=resource_group_name, + public_ip_id=public_ip_id, + private_cloud_name=private_cloud_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_public_ip_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - 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]: @@ -3889,77 +6871,74 @@ def _delete_public_ip_initial( if cls: return cls(pipeline_response, None, {}) - _delete_public_ip_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/publicIPs/{publicIPId}'} # type: ignore + _delete_public_ip_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/publicIPs/{publicIPId}"} # type: ignore + @distributed_trace def begin_delete_public_ip( - self, - resource_group_name, # type: str - public_ip_id, # type: str - private_cloud_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + self, resource_group_name: str, public_ip_id: str, private_cloud_name: str, **kwargs: Any + ) -> LROPoller[None]: """Delete a Public IP Block by id in a private cloud workload network. Delete a Public IP Block by id in a private cloud workload network. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :param public_ip_id: NSX Public IP Block identifier. Generally the same as the Public IP - Block's display name. + Block's display name. Required. :type public_ip_id: str - :param private_cloud_name: Name of the private cloud. + :param private_cloud_name: Name of the private cloud. Required. :type private_cloud_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_public_ip_initial( + raw_result = self._delete_public_ip_initial( # type: ignore resource_group_name=resource_group_name, public_ip_id=public_ip_id, private_cloud_name=private_cloud_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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'publicIPId': self._serialize.url("public_ip_id", public_ip_id, 'str'), - 'privateCloudName': self._serialize.url("private_cloud_name", private_cloud_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_public_ip.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/publicIPs/{publicIPId}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete_public_ip.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/publicIPs/{publicIPId}"} # type: ignore