diff --git a/sdk/hdinsight/azure-mgmt-hdinsight/_meta.json b/sdk/hdinsight/azure-mgmt-hdinsight/_meta.json index 804c28c2fdc43..f93b40302f93d 100644 --- a/sdk/hdinsight/azure-mgmt-hdinsight/_meta.json +++ b/sdk/hdinsight/azure-mgmt-hdinsight/_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": "7326c66014c2180e83c52c30f150eea094613ca4", + "commit": "4e995f502d45d47732b76ecdf7b0e91297094089", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/hdinsight/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/hdinsight/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/hdinsight/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/__init__.py b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/__init__.py index 14ab46d45b328..cae2f2cf5798c 100644 --- a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/__init__.py +++ b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/__init__.py @@ -10,10 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['HDInsightManagementClient'] 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__ = ["HDInsightManagementClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/_configuration.py b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/_configuration.py index 9051ba4fbdb9c..46da4ab9c98b7 100644 --- a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/_configuration.py +++ b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/_configuration.py @@ -6,66 +6,65 @@ # 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 HDInsightManagementClientConfiguration(Configuration): +class HDInsightManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for HDInsightManagementClient. Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: The subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-06-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(HDInsightManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2021-06-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(HDInsightManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-06-01" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-hdinsight/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-hdinsight/{}".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/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/_hd_insight_management_client.py b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/_hd_insight_management_client.py index ab317c6ca195a..d8e25dd86c400 100644 --- a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/_hd_insight_management_client.py +++ b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/_hd_insight_management_client.py @@ -6,34 +6,35 @@ # 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 HDInsightManagementClientConfiguration +from ._serialization import Deserializer, Serializer +from .operations import ( + ApplicationsOperations, + ClustersOperations, + ConfigurationsOperations, + ExtensionsOperations, + LocationsOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + ScriptActionsOperations, + ScriptExecutionHistoryOperations, + VirtualMachinesOperations, +) 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 HDInsightManagementClientConfiguration -from .operations import ClustersOperations -from .operations import ApplicationsOperations -from .operations import LocationsOperations -from .operations import ConfigurationsOperations -from .operations import ExtensionsOperations -from .operations import ScriptActionsOperations -from .operations import ScriptExecutionHistoryOperations -from .operations import Operations -from .operations import VirtualMachinesOperations -from .operations import PrivateEndpointConnectionsOperations -from .operations import PrivateLinkResourcesOperations -from . import models -class HDInsightManagementClient(object): +class HDInsightManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """HDInsight Management Client. :ivar clusters: ClustersOperations operations @@ -49,81 +50,88 @@ class HDInsightManagementClient(object): :ivar script_actions: ScriptActionsOperations operations :vartype script_actions: azure.mgmt.hdinsight.operations.ScriptActionsOperations :ivar script_execution_history: ScriptExecutionHistoryOperations operations - :vartype script_execution_history: azure.mgmt.hdinsight.operations.ScriptExecutionHistoryOperations + :vartype script_execution_history: + azure.mgmt.hdinsight.operations.ScriptExecutionHistoryOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.hdinsight.operations.Operations :ivar virtual_machines: VirtualMachinesOperations operations :vartype virtual_machines: azure.mgmt.hdinsight.operations.VirtualMachinesOperations :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: azure.mgmt.hdinsight.operations.PrivateEndpointConnectionsOperations + :vartype private_endpoint_connections: + azure.mgmt.hdinsight.operations.PrivateEndpointConnectionsOperations :ivar private_link_resources: PrivateLinkResourcesOperations operations :vartype private_link_resources: azure.mgmt.hdinsight.operations.PrivateLinkResourcesOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: The subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. 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 "2021-06-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 = HDInsightManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = HDInsightManagementClientConfiguration( + 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.clusters = ClustersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.applications = ApplicationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.locations = LocationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.configurations = ConfigurationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.extensions = ExtensionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.script_actions = ScriptActionsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._serialize.client_side_validation = False + self.clusters = ClustersOperations(self._client, self._config, self._serialize, self._deserialize) + self.applications = ApplicationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.locations = LocationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.configurations = ConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.extensions = ExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.script_actions = ScriptActionsOperations(self._client, self._config, self._serialize, self._deserialize) self.script_execution_history = ScriptExecutionHistoryOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.virtual_machines = VirtualMachinesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.private_link_resources = PrivateLinkResourcesOperations( - 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'), - } - 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/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/_metadata.json b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/_metadata.json deleted file mode 100644 index da780c65d7bec..0000000000000 --- a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/_metadata.json +++ /dev/null @@ -1,113 +0,0 @@ -{ - "chosen_version": "2021-06-01", - "total_api_version_list": ["2021-06-01"], - "client": { - "name": "HDInsightManagementClient", - "filename": "_hd_insight_management_client", - "description": "HDInsight Management Client.", - "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\": [\"HDInsightManagementClientConfiguration\"]}}, \"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\": [\"HDInsightManagementClientConfiguration\"]}}, \"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 subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", - "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 subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", - "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": { - "clusters": "ClustersOperations", - "applications": "ApplicationsOperations", - "locations": "LocationsOperations", - "configurations": "ConfigurationsOperations", - "extensions": "ExtensionsOperations", - "script_actions": "ScriptActionsOperations", - "script_execution_history": "ScriptExecutionHistoryOperations", - "operations": "Operations", - "virtual_machines": "VirtualMachinesOperations", - "private_endpoint_connections": "PrivateEndpointConnectionsOperations", - "private_link_resources": "PrivateLinkResourcesOperations" - } -} \ No newline at end of file diff --git a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/_patch.py b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/_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/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/_serialization.py b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/_serialization.py new file mode 100644 index 0000000000000..7c1dedb5133d3 --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/_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/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/_vendor.py b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/_vendor.py new file mode 100644 index 0000000000000..9aad73fc743e7 --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/_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/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/_version.py b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/_version.py index b77ac9246082f..e5754a47ce68f 100644 --- a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/_version.py +++ b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "9.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/__init__.py b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/__init__.py index b412b06504564..ccc3ed5845339 100644 --- a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/__init__.py +++ b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/__init__.py @@ -7,4 +7,15 @@ # -------------------------------------------------------------------------- from ._hd_insight_management_client import HDInsightManagementClient -__all__ = ['HDInsightManagementClient'] + +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__ = ["HDInsightManagementClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/_configuration.py b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/_configuration.py index 292a4248952a7..9e75a829bc0eb 100644 --- a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/_configuration.py +++ b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/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,49 @@ from azure.core.credentials_async import AsyncTokenCredential -class HDInsightManagementClientConfiguration(Configuration): +class HDInsightManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for HDInsightManagementClient. Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: The subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-06-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(HDInsightManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2021-06-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(HDInsightManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-06-01" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-hdinsight/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-hdinsight/{}".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/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/_hd_insight_management_client.py b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/_hd_insight_management_client.py index 8a0f1cda64ab7..8f51774a73d41 100644 --- a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/_hd_insight_management_client.py +++ b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/_hd_insight_management_client.py @@ -6,32 +6,35 @@ # 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 HDInsightManagementClientConfiguration +from .operations import ( + ApplicationsOperations, + ClustersOperations, + ConfigurationsOperations, + ExtensionsOperations, + LocationsOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + ScriptActionsOperations, + ScriptExecutionHistoryOperations, + VirtualMachinesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import HDInsightManagementClientConfiguration -from .operations import ClustersOperations -from .operations import ApplicationsOperations -from .operations import LocationsOperations -from .operations import ConfigurationsOperations -from .operations import ExtensionsOperations -from .operations import ScriptActionsOperations -from .operations import ScriptExecutionHistoryOperations -from .operations import Operations -from .operations import VirtualMachinesOperations -from .operations import PrivateEndpointConnectionsOperations -from .operations import PrivateLinkResourcesOperations -from .. import models - -class HDInsightManagementClient(object): +class HDInsightManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """HDInsight Management Client. :ivar clusters: ClustersOperations operations @@ -47,79 +50,89 @@ class HDInsightManagementClient(object): :ivar script_actions: ScriptActionsOperations operations :vartype script_actions: azure.mgmt.hdinsight.aio.operations.ScriptActionsOperations :ivar script_execution_history: ScriptExecutionHistoryOperations operations - :vartype script_execution_history: azure.mgmt.hdinsight.aio.operations.ScriptExecutionHistoryOperations + :vartype script_execution_history: + azure.mgmt.hdinsight.aio.operations.ScriptExecutionHistoryOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.hdinsight.aio.operations.Operations :ivar virtual_machines: VirtualMachinesOperations operations :vartype virtual_machines: azure.mgmt.hdinsight.aio.operations.VirtualMachinesOperations :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: azure.mgmt.hdinsight.aio.operations.PrivateEndpointConnectionsOperations + :vartype private_endpoint_connections: + azure.mgmt.hdinsight.aio.operations.PrivateEndpointConnectionsOperations :ivar private_link_resources: PrivateLinkResourcesOperations operations - :vartype private_link_resources: azure.mgmt.hdinsight.aio.operations.PrivateLinkResourcesOperations - :param credential: Credential needed for the client to connect to Azure. + :vartype private_link_resources: + azure.mgmt.hdinsight.aio.operations.PrivateLinkResourcesOperations + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: The subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. 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 "2021-06-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 = HDInsightManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = HDInsightManagementClientConfiguration( + 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.clusters = ClustersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.applications = ApplicationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.locations = LocationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.configurations = ConfigurationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.extensions = ExtensionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.script_actions = ScriptActionsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._serialize.client_side_validation = False + self.clusters = ClustersOperations(self._client, self._config, self._serialize, self._deserialize) + self.applications = ApplicationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.locations = LocationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.configurations = ConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.extensions = ExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.script_actions = ScriptActionsOperations(self._client, self._config, self._serialize, self._deserialize) self.script_execution_history = ScriptExecutionHistoryOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.virtual_machines = VirtualMachinesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.private_link_resources = PrivateLinkResourcesOperations( - 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'), - } - 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/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/_patch.py b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/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/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/operations/__init__.py b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/operations/__init__.py index f6dc3dfa5a094..54d25aae0b45f 100644 --- a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/operations/__init__.py +++ b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/operations/__init__.py @@ -18,16 +18,22 @@ from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations from ._private_link_resources_operations import PrivateLinkResourcesOperations +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__ = [ - 'ClustersOperations', - 'ApplicationsOperations', - 'LocationsOperations', - 'ConfigurationsOperations', - 'ExtensionsOperations', - 'ScriptActionsOperations', - 'ScriptExecutionHistoryOperations', - 'Operations', - 'VirtualMachinesOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkResourcesOperations', + "ClustersOperations", + "ApplicationsOperations", + "LocationsOperations", + "ConfigurationsOperations", + "ExtensionsOperations", + "ScriptActionsOperations", + "ScriptExecutionHistoryOperations", + "Operations", + "VirtualMachinesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/operations/_applications_operations.py b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/operations/_applications_operations.py index 87804fba53ae7..670d20dd71647 100644 --- a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/operations/_applications_operations.py +++ b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/operations/_applications_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, 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._applications_operations import ( + build_create_request, + build_delete_request, + build_get_azure_async_operation_status_request, + build_get_request, + build_list_by_cluster_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ApplicationsOperations: - """ApplicationsOperations 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 ApplicationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.hdinsight.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.hdinsight.aio.HDInsightManagementClient`'s + :attr:`applications` 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_by_cluster( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ApplicationListResult"]: + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Application"]: """Lists all of the applications for the HDInsight cluster. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApplicationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hdinsight.models.ApplicationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Application or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hdinsight.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationListResult"] + _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.ApplicationListResult] + 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-06-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_by_cluster.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_cluster_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_cluster.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('ApplicationListResult', pipeline_response) + deserialized = self._deserialize("ApplicationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -103,395 +133,491 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_cluster.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/applications'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list_by_cluster.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/applications"} # type: ignore + @distributed_trace_async async def get( - self, - resource_group_name: str, - cluster_name: str, - application_name: str, - **kwargs: Any - ) -> "_models.Application": + self, resource_group_name: str, cluster_name: str, application_name: str, **kwargs: Any + ) -> _models.Application: """Gets properties of the specified application. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param application_name: The constant value for the application name. + :param application_name: The constant value for the application name. Required. :type application_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Application, or the result of cls(response) + :return: Application or the result of cls(response) :rtype: ~azure.mgmt.hdinsight.models.Application - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Application"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-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'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'applicationName': self._serialize.url("application_name", application_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.Application] + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + application_name=application_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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Application', pipeline_response) + deserialized = self._deserialize("Application", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/applications/{applicationName}'} # type: ignore + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/applications/{applicationName}"} # type: ignore async def _create_initial( self, resource_group_name: str, cluster_name: str, application_name: str, - parameters: "_models.Application", + parameters: Union[_models.Application, IO], **kwargs: Any - ) -> "_models.Application": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Application"] + ) -> _models.Application: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'applicationName': self._serialize.url("application_name", application_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(parameters, 'Application') - 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.Application] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Application") + + request = build_create_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Application', pipeline_response) + deserialized = self._deserialize("Application", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/applications/{applicationName}'} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/applications/{applicationName}"} # type: ignore + + @overload async def begin_create( self, resource_group_name: str, cluster_name: str, application_name: str, - parameters: "_models.Application", + parameters: _models.Application, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.Application"]: + ) -> AsyncLROPoller[_models.Application]: """Creates applications for the HDInsight cluster. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param application_name: The constant value for the application name. + :param application_name: The constant value for the application name. Required. :type application_name: str - :param parameters: The application create request. + :param parameters: The application create request. Required. :type parameters: ~azure.mgmt.hdinsight.models.Application + :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 Application 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 Application or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hdinsight.models.Application] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Application"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create( + self, + resource_group_name: str, + cluster_name: str, + application_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Application]: + """Creates applications for the HDInsight cluster. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param application_name: The constant value for the application name. Required. + :type application_name: str + :param parameters: The application create request. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Application or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hdinsight.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + cluster_name: str, + application_name: str, + parameters: Union[_models.Application, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.Application]: + """Creates applications for the HDInsight cluster. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param application_name: The constant value for the application name. Required. + :type application_name: str + :param parameters: The application create request. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.hdinsight.models.Application 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 Application or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hdinsight.models.Application] + :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.Application] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_initial( + raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, application_name=application_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Application', pipeline_response) - + deserialized = self._deserialize("Application", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'applicationName': self._serialize.url("application_name", application_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/applications/{applicationName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - async def _delete_initial( - self, - resource_group_name: str, - cluster_name: str, - application_name: str, - **kwargs: Any + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/applications/{applicationName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, cluster_name: str, application_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-06-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'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'applicationName': self._serialize.url("application_name", application_name, 'str'), - } - url = self._client.format_url(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, + cluster_name=cluster_name, + application_name=application_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/applications/{applicationName}'} # type: ignore + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/applications/{applicationName}"} # type: ignore + @distributed_trace_async async def begin_delete( - self, - resource_group_name: str, - cluster_name: str, - application_name: str, - **kwargs: Any + self, resource_group_name: str, cluster_name: str, application_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the specified application on the HDInsight cluster. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param application_name: The constant value for the application name. + :param application_name: The constant value for the application name. Required. :type application_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, cluster_name=cluster_name, application_name=application_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'applicationName': self._serialize.url("application_name", application_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + 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.HDInsight/clusters/{clusterName}/applications/{applicationName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/applications/{applicationName}"} # type: ignore + + @distributed_trace_async async def get_azure_async_operation_status( - self, - resource_group_name: str, - cluster_name: str, - application_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.AsyncOperationResult": + self, resource_group_name: str, cluster_name: str, application_name: str, operation_id: str, **kwargs: Any + ) -> _models.AsyncOperationResult: """Gets the async operation status. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param application_name: The constant value for the application name. + :param application_name: The constant value for the application name. Required. :type application_name: str - :param operation_id: The long running operation id. + :param operation_id: The long running operation id. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AsyncOperationResult, or the result of cls(response) + :return: AsyncOperationResult or the result of cls(response) :rtype: ~azure.mgmt.hdinsight.models.AsyncOperationResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AsyncOperationResult"] 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-06-01" - accept = "application/json" - - # Construct URL - url = self.get_azure_async_operation_status.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'applicationName': self._serialize.url("application_name", application_name, 'str'), - 'operationId': self._serialize.url("operation_id", operation_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.AsyncOperationResult] + + request = build_get_azure_async_operation_status_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + application_name=application_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_azure_async_operation_status.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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AsyncOperationResult', pipeline_response) + deserialized = self._deserialize("AsyncOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_azure_async_operation_status.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/applications/{applicationName}/azureasyncoperations/{operationId}'} # type: ignore + + get_azure_async_operation_status.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/applications/{applicationName}/azureasyncoperations/{operationId}"} # type: ignore diff --git a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/operations/_clusters_operations.py b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/operations/_clusters_operations.py index 6f42fe25ebd0c..17a8bd850be95 100644 --- a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/operations/_clusters_operations.py +++ b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/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,452 +6,647 @@ # 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_request, + build_delete_request, + build_execute_script_actions_request, + build_get_azure_async_operation_status_request, + build_get_gateway_settings_request, + build_get_request, + build_list_by_resource_group_request, + build_list_request, + build_resize_request, + build_rotate_disk_encryption_key_request, + build_update_auto_scale_configuration_request, + build_update_gateway_settings_request, + build_update_identity_certificate_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: # 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.hdinsight.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.hdinsight.aio.HDInsightManagementClient`'s + :attr:`clusters` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _create_initial( self, resource_group_name: str, cluster_name: str, - parameters: "_models.ClusterCreateParametersExtended", + parameters: Union[_models.ClusterCreateParametersExtended, IO], **kwargs: Any - ) -> "_models.Cluster": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Cluster"] + ) -> _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-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ClusterCreateParametersExtended') - 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(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ClusterCreateParametersExtended") + + request = build_create_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Cluster', pipeline_response) + deserialized = self._deserialize("Cluster", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}'} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}"} # type: ignore + + @overload async def begin_create( self, resource_group_name: str, cluster_name: str, - parameters: "_models.ClusterCreateParametersExtended", + parameters: _models.ClusterCreateParametersExtended, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.Cluster"]: + ) -> AsyncLROPoller[_models.Cluster]: """Creates a new HDInsight cluster with the specified parameters. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param parameters: The cluster create request. + :param parameters: The cluster create request. Required. :type parameters: ~azure.mgmt.hdinsight.models.ClusterCreateParametersExtended + :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.hdinsight.models.Cluster] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Cluster"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create( + self, + resource_group_name: str, + cluster_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Cluster]: + """Creates a new HDInsight cluster with the specified parameters. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param parameters: The cluster create request. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Cluster or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hdinsight.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + cluster_name: str, + parameters: Union[_models.ClusterCreateParametersExtended, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.Cluster]: + """Creates a new HDInsight cluster with the specified parameters. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param parameters: The cluster create request. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.hdinsight.models.ClusterCreateParametersExtended 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.hdinsight.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Cluster] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_initial( + raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Cluster', pipeline_response) - + deserialized = self._deserialize("Cluster", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}"} # type: ignore + @overload async def update( self, resource_group_name: str, cluster_name: str, - parameters: "_models.ClusterPatchParameters", + parameters: _models.ClusterPatchParameters, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.Cluster": + ) -> _models.Cluster: """Patch HDInsight cluster with the specified parameters. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param parameters: The cluster patch request. + :param parameters: The cluster patch request. Required. :type parameters: ~azure.mgmt.hdinsight.models.ClusterPatchParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Cluster or the result of cls(response) + :rtype: ~azure.mgmt.hdinsight.models.Cluster + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + cluster_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Cluster: + """Patch HDInsight cluster with the specified parameters. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param parameters: The cluster patch request. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Cluster, or the result of cls(response) + :return: Cluster or the result of cls(response) :rtype: ~azure.mgmt.hdinsight.models.Cluster - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + cluster_name: str, + parameters: Union[_models.ClusterPatchParameters, IO], + **kwargs: Any + ) -> _models.Cluster: + """Patch HDInsight cluster with the specified parameters. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param parameters: The cluster patch request. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.hdinsight.models.ClusterPatchParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Cluster or the result of cls(response) + :rtype: ~azure.mgmt.hdinsight.models.Cluster + :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-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ClusterPatchParameters') - 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(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ClusterPatchParameters") + + request = build_update_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Cluster', pipeline_response) + deserialized = self._deserialize("Cluster", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}'} # type: ignore - async def _delete_initial( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, cluster_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-06-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'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_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, + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}'} # type: ignore + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}"} # type: ignore - async def begin_delete( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + @distributed_trace_async + async def begin_delete(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Deletes the specified HDInsight cluster. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. 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, 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'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + 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.HDInsight/clusters/{clusterName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - async def get( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> "_models.Cluster": + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}"} # type: ignore + + @distributed_trace_async + async def get(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> _models.Cluster: """Gets the specified cluster. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Cluster, or the result of cls(response) + :return: Cluster or the result of cls(response) :rtype: ~azure.mgmt.hdinsight.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-06-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'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Cluster] + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Cluster', pipeline_response) + deserialized = self._deserialize("Cluster", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}'} # type: ignore - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ClusterListResult"]: + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}"} # type: ignore + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Cluster"]: """Lists the HDInsight clusters in a resource group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. 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 ClusterListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hdinsight.models.ClusterListResult] - :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.hdinsight.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClusterListResult"] + _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.ClusterListResult] + 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-06-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_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = 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('ClusterListResult', pipeline_response) + deserialized = self._deserialize("ClusterListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -459,317 +655,516 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters"} # type: ignore - async def _resize_initial( + async def _resize_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_name: str, - role_name: Union[str, "_models.RoleName"], - parameters: "_models.ClusterResizeParameters", + role_name: Union[str, _models.RoleName], + parameters: Union[_models.ClusterResizeParameters, IO], **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-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._resize_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - } - url = self._client.format_url(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(parameters, 'ClusterResizeParameters') - 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(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ClusterResizeParameters") + + request = build_resize_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + role_name=role_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._resize_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _resize_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/roles/{roleName}/resize'} # type: ignore + _resize_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/roles/{roleName}/resize"} # type: ignore + @overload async def begin_resize( self, resource_group_name: str, cluster_name: str, - role_name: Union[str, "_models.RoleName"], - parameters: "_models.ClusterResizeParameters", + role_name: Union[str, _models.RoleName], + parameters: _models.ClusterResizeParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: """Resizes the specified HDInsight cluster to the specified size. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param role_name: The constant value for the roleName. + :param role_name: The constant value for the roleName. "workernode" Required. :type role_name: str or ~azure.mgmt.hdinsight.models.RoleName - :param parameters: The parameters for the resize operation. + :param parameters: The parameters for the resize operation. Required. :type parameters: ~azure.mgmt.hdinsight.models.ClusterResizeParameters + :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_resize( + self, + resource_group_name: str, + cluster_name: str, + role_name: Union[str, _models.RoleName], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Resizes the specified HDInsight cluster to the specified size. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param role_name: The constant value for the roleName. "workernode" Required. + :type role_name: str or ~azure.mgmt.hdinsight.models.RoleName + :param parameters: The parameters for the resize operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_resize( + self, + resource_group_name: str, + cluster_name: str, + role_name: Union[str, _models.RoleName], + parameters: Union[_models.ClusterResizeParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Resizes the specified HDInsight cluster to the specified size. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param role_name: The constant value for the roleName. "workernode" Required. + :type role_name: str or ~azure.mgmt.hdinsight.models.RoleName + :param parameters: The parameters for the resize operation. Is either a model type or a IO + type. Required. + :type parameters: ~azure.mgmt.hdinsight.models.ClusterResizeParameters 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._resize_initial( + raw_result = await self._resize_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, role_name=role_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_resize.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/roles/{roleName}/resize'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_resize.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/roles/{roleName}/resize"} # type: ignore - async def _update_auto_scale_configuration_initial( + async def _update_auto_scale_configuration_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_name: str, - role_name: Union[str, "_models.RoleName"], - parameters: "_models.AutoscaleConfigurationUpdateParameter", + role_name: Union[str, _models.RoleName], + parameters: Union[_models.AutoscaleConfigurationUpdateParameter, IO], **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-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_auto_scale_configuration_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - } - url = self._client.format_url(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(parameters, 'AutoscaleConfigurationUpdateParameter') - 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(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AutoscaleConfigurationUpdateParameter") + + request = build_update_auto_scale_configuration_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + role_name=role_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_auto_scale_configuration_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _update_auto_scale_configuration_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/roles/{roleName}/autoscale'} # type: ignore + _update_auto_scale_configuration_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/roles/{roleName}/autoscale"} # type: ignore + @overload async def begin_update_auto_scale_configuration( self, resource_group_name: str, cluster_name: str, - role_name: Union[str, "_models.RoleName"], - parameters: "_models.AutoscaleConfigurationUpdateParameter", + role_name: Union[str, _models.RoleName], + parameters: _models.AutoscaleConfigurationUpdateParameter, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: """Updates the Autoscale Configuration for HDInsight cluster. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param role_name: The constant value for the roleName. + :param role_name: The constant value for the roleName. "workernode" Required. :type role_name: str or ~azure.mgmt.hdinsight.models.RoleName - :param parameters: The parameters for the update autoscale configuration operation. + :param parameters: The parameters for the update autoscale configuration operation. Required. :type parameters: ~azure.mgmt.hdinsight.models.AutoscaleConfigurationUpdateParameter + :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_update_auto_scale_configuration( + self, + resource_group_name: str, + cluster_name: str, + role_name: Union[str, _models.RoleName], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Updates the Autoscale Configuration for HDInsight cluster. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param role_name: The constant value for the roleName. "workernode" Required. + :type role_name: str or ~azure.mgmt.hdinsight.models.RoleName + :param parameters: The parameters for the update autoscale configuration operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update_auto_scale_configuration( + self, + resource_group_name: str, + cluster_name: str, + role_name: Union[str, _models.RoleName], + parameters: Union[_models.AutoscaleConfigurationUpdateParameter, IO], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Updates the Autoscale Configuration for HDInsight cluster. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param role_name: The constant value for the roleName. "workernode" Required. + :type role_name: str or ~azure.mgmt.hdinsight.models.RoleName + :param parameters: The parameters for the update autoscale configuration operation. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.hdinsight.models.AutoscaleConfigurationUpdateParameter 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._update_auto_scale_configuration_initial( + raw_result = await self._update_auto_scale_configuration_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, role_name=role_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update_auto_scale_configuration.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/roles/{roleName}/autoscale'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.ClusterListResult"]: + begin_update_auto_scale_configuration.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/roles/{roleName}/autoscale"} # type: ignore + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.Cluster"]: """Lists all the HDInsight clusters under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ClusterListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hdinsight.models.ClusterListResult] - :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.hdinsight.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClusterListResult"] + _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.ClusterListResult] + 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-06-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'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = 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('ClusterListResult', pipeline_response) + deserialized = self._deserialize("ClusterListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -778,615 +1173,969 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HDInsight/clusters'} # type: ignore + return AsyncItemPaged(get_next, extract_data) - async def _rotate_disk_encryption_key_initial( + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.HDInsight/clusters"} # type: ignore + + async def _rotate_disk_encryption_key_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_name: str, - parameters: "_models.ClusterDiskEncryptionParameters", + parameters: Union[_models.ClusterDiskEncryptionParameters, 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-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._rotate_disk_encryption_key_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 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(parameters, 'ClusterDiskEncryptionParameters') - 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(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ClusterDiskEncryptionParameters") + + request = build_rotate_disk_encryption_key_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._rotate_disk_encryption_key_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _rotate_disk_encryption_key_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/rotatediskencryptionkey'} # type: ignore + _rotate_disk_encryption_key_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/rotatediskencryptionkey"} # type: ignore + @overload async def begin_rotate_disk_encryption_key( self, resource_group_name: str, cluster_name: str, - parameters: "_models.ClusterDiskEncryptionParameters", + parameters: _models.ClusterDiskEncryptionParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: """Rotate disk encryption key of the specified HDInsight cluster. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param parameters: The parameters for the disk encryption operation. + :param parameters: The parameters for the disk encryption operation. Required. :type parameters: ~azure.mgmt.hdinsight.models.ClusterDiskEncryptionParameters + :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_rotate_disk_encryption_key( + self, + resource_group_name: str, + cluster_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Rotate disk encryption key of the specified HDInsight cluster. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param parameters: The parameters for the disk encryption operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_rotate_disk_encryption_key( + self, + resource_group_name: str, + cluster_name: str, + parameters: Union[_models.ClusterDiskEncryptionParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Rotate disk encryption key of the specified HDInsight cluster. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param parameters: The parameters for the disk encryption operation. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.hdinsight.models.ClusterDiskEncryptionParameters 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._rotate_disk_encryption_key_initial( + raw_result = await self._rotate_disk_encryption_key_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_rotate_disk_encryption_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/rotatediskencryptionkey'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_rotate_disk_encryption_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/rotatediskencryptionkey"} # type: ignore + + @distributed_trace_async async def get_gateway_settings( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> "_models.GatewaySettings": + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> _models.GatewaySettings: """Gets the gateway settings for the specified cluster. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GatewaySettings, or the result of cls(response) + :return: GatewaySettings or the result of cls(response) :rtype: ~azure.mgmt.hdinsight.models.GatewaySettings - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewaySettings"] 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-06-01" - accept = "application/json" - - # Construct URL - url = self.get_gateway_settings.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + 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.GatewaySettings] + + request = build_get_gateway_settings_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_gateway_settings.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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('GatewaySettings', pipeline_response) + deserialized = self._deserialize("GatewaySettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_gateway_settings.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/getGatewaySettings'} # type: ignore - async def _update_gateway_settings_initial( + get_gateway_settings.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/getGatewaySettings"} # type: ignore + + async def _update_gateway_settings_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_name: str, - parameters: "_models.UpdateGatewaySettingsParameters", + parameters: Union[_models.UpdateGatewaySettingsParameters, 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-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_gateway_settings_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 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(parameters, 'UpdateGatewaySettingsParameters') - 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(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "UpdateGatewaySettingsParameters") + + request = build_update_gateway_settings_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_gateway_settings_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _update_gateway_settings_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/updateGatewaySettings'} # type: ignore + _update_gateway_settings_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/updateGatewaySettings"} # type: ignore + @overload async def begin_update_gateway_settings( self, resource_group_name: str, cluster_name: str, - parameters: "_models.UpdateGatewaySettingsParameters", + parameters: _models.UpdateGatewaySettingsParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: """Configures the gateway settings on the specified cluster. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param parameters: The cluster configurations. + :param parameters: The cluster configurations. Required. :type parameters: ~azure.mgmt.hdinsight.models.UpdateGatewaySettingsParameters + :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_update_gateway_settings( + self, + resource_group_name: str, + cluster_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Configures the gateway settings on the specified cluster. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param parameters: The cluster configurations. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update_gateway_settings( + self, + resource_group_name: str, + cluster_name: str, + parameters: Union[_models.UpdateGatewaySettingsParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Configures the gateway settings on the specified cluster. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param parameters: The cluster configurations. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.hdinsight.models.UpdateGatewaySettingsParameters 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._update_gateway_settings_initial( + raw_result = await self._update_gateway_settings_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update_gateway_settings.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/updateGatewaySettings'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update_gateway_settings.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/updateGatewaySettings"} # type: ignore + + @distributed_trace_async async def get_azure_async_operation_status( - self, - resource_group_name: str, - cluster_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.AsyncOperationResult": + self, resource_group_name: str, cluster_name: str, operation_id: str, **kwargs: Any + ) -> _models.AsyncOperationResult: """The the async operation status. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param operation_id: The long running operation id. + :param operation_id: The long running operation id. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AsyncOperationResult, or the result of cls(response) + :return: AsyncOperationResult or the result of cls(response) :rtype: ~azure.mgmt.hdinsight.models.AsyncOperationResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AsyncOperationResult"] 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-06-01" - accept = "application/json" - - # Construct URL - url = self.get_azure_async_operation_status.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'operationId': self._serialize.url("operation_id", operation_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.AsyncOperationResult] + + request = build_get_azure_async_operation_status_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_azure_async_operation_status.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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AsyncOperationResult', pipeline_response) + deserialized = self._deserialize("AsyncOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_azure_async_operation_status.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/azureasyncoperations/{operationId}'} # type: ignore - async def _update_identity_certificate_initial( + get_azure_async_operation_status.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/azureasyncoperations/{operationId}"} # type: ignore + + async def _update_identity_certificate_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_name: str, - parameters: "_models.UpdateClusterIdentityCertificateParameters", + parameters: Union[_models.UpdateClusterIdentityCertificateParameters, 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-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_identity_certificate_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 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(parameters, 'UpdateClusterIdentityCertificateParameters') - 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(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "UpdateClusterIdentityCertificateParameters") + + request = build_update_identity_certificate_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_identity_certificate_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _update_identity_certificate_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/updateClusterIdentityCertificate'} # type: ignore + _update_identity_certificate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/updateClusterIdentityCertificate"} # type: ignore + @overload async def begin_update_identity_certificate( self, resource_group_name: str, cluster_name: str, - parameters: "_models.UpdateClusterIdentityCertificateParameters", + parameters: _models.UpdateClusterIdentityCertificateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: """Updates the cluster identity certificate. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param parameters: The cluster configurations. + :param parameters: The cluster configurations. Required. :type parameters: ~azure.mgmt.hdinsight.models.UpdateClusterIdentityCertificateParameters + :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_update_identity_certificate( + self, + resource_group_name: str, + cluster_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Updates the cluster identity certificate. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param parameters: The cluster configurations. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update_identity_certificate( + self, + resource_group_name: str, + cluster_name: str, + parameters: Union[_models.UpdateClusterIdentityCertificateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Updates the cluster identity certificate. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param parameters: The cluster configurations. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.hdinsight.models.UpdateClusterIdentityCertificateParameters 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._update_identity_certificate_initial( + raw_result = await self._update_identity_certificate_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update_identity_certificate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/updateClusterIdentityCertificate'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - async def _execute_script_actions_initial( + begin_update_identity_certificate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/updateClusterIdentityCertificate"} # type: ignore + + async def _execute_script_actions_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_name: str, - parameters: "_models.ExecuteScriptActionParameters", + parameters: Union[_models.ExecuteScriptActionParameters, 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-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._execute_script_actions_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 401: ClientAuthenticationError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 404: lambda response: ResourceNotFoundError(response=response, error_format=ARMErrorFormat), } - url = self._client.format_url(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(parameters, 'ExecuteScriptActionParameters') - 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(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ExecuteScriptActionParameters") + + request = build_execute_script_actions_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._execute_script_actions_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _execute_script_actions_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/executeScriptActions'} # type: ignore + _execute_script_actions_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/executeScriptActions"} # type: ignore + @overload async def begin_execute_script_actions( self, resource_group_name: str, cluster_name: str, - parameters: "_models.ExecuteScriptActionParameters", + parameters: _models.ExecuteScriptActionParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: """Executes script actions on the specified HDInsight cluster. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param parameters: The parameters for executing script actions. + :param parameters: The parameters for executing script actions. Required. :type parameters: ~azure.mgmt.hdinsight.models.ExecuteScriptActionParameters + :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_execute_script_actions( + self, + resource_group_name: str, + cluster_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Executes script actions on the specified HDInsight cluster. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param parameters: The parameters for executing script actions. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_execute_script_actions( + self, + resource_group_name: str, + cluster_name: str, + parameters: Union[_models.ExecuteScriptActionParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Executes script actions on the specified HDInsight cluster. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param parameters: The parameters for executing script actions. Is either a model type or a IO + type. Required. + :type parameters: ~azure.mgmt.hdinsight.models.ExecuteScriptActionParameters 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._execute_script_actions_initial( + raw_result = await self._execute_script_actions_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_execute_script_actions.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/executeScriptActions'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_execute_script_actions.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/executeScriptActions"} # type: ignore diff --git a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/operations/_configurations_operations.py b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/operations/_configurations_operations.py index 156f9cf6d24d3..b22fec94aa1e6 100644 --- a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/operations/_configurations_operations.py +++ b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/operations/_configurations_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,289 +6,393 @@ # 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, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, 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.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +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 azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models +from ..._vendor import _convert_request +from ...operations._configurations_operations import build_get_request, build_list_request, build_update_request -T = TypeVar('T') +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ConfigurationsOperations: - """ConfigurationsOperations 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 ConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.hdinsight.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.hdinsight.aio.HDInsightManagementClient`'s + :attr:`configurations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - async def list( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> "_models.ClusterConfigurations": + @distributed_trace_async + async def list(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> _models.ClusterConfigurations: """Gets all configuration information for an HDI cluster. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ClusterConfigurations, or the result of cls(response) + :return: ClusterConfigurations or the result of cls(response) :rtype: ~azure.mgmt.hdinsight.models.ClusterConfigurations - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClusterConfigurations"] 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-06-01" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - '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.ClusterConfigurations] + + request = build_list_request( + resource_group_name=resource_group_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 - # 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ClusterConfigurations', pipeline_response) + deserialized = self._deserialize("ClusterConfigurations", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/configurations'} # type: ignore - async def _update_initial( + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/configurations"} # type: ignore + + async def _update_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_name: str, configuration_name: str, - parameters: Dict[str, str], + parameters: Union[Dict[str, str], 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-06-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'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'configurationName': self._serialize.url("configuration_name", configuration_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(parameters, '{str}') - 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(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "{str}") + + request = build_update_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + configuration_name=configuration_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, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/configurations/{configurationName}'} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/configurations/{configurationName}"} # type: ignore + @overload async def begin_update( self, resource_group_name: str, cluster_name: str, configuration_name: str, parameters: Dict[str, str], + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: """Configures the HTTP settings on the specified cluster. This API is deprecated, please use UpdateGatewaySettings in cluster endpoint instead. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param configuration_name: The name of the cluster configuration. + :param configuration_name: The name of the cluster configuration. Required. :type configuration_name: str - :param parameters: The cluster configurations. + :param parameters: The cluster configurations. Required. :type parameters: dict[str, str] + :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_update( + self, + resource_group_name: str, + cluster_name: str, + configuration_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Configures the HTTP settings on the specified cluster. This API is deprecated, please use + UpdateGatewaySettings in cluster endpoint instead. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param configuration_name: The name of the cluster configuration. Required. + :type configuration_name: str + :param parameters: The cluster configurations. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + cluster_name: str, + configuration_name: str, + parameters: Union[Dict[str, str], IO], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Configures the HTTP settings on the specified cluster. This API is deprecated, please use + UpdateGatewaySettings in cluster endpoint instead. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param configuration_name: The name of the cluster configuration. Required. + :type configuration_name: str + :param parameters: The cluster configurations. Is either a dict type or a IO type. Required. + :type parameters: dict[str, str] 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._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, configuration_name=configuration_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + 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.HDInsight/clusters/{clusterName}/configurations/{configurationName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/configurations/{configurationName}"} # type: ignore + + @distributed_trace_async async def get( - self, - resource_group_name: str, - cluster_name: str, - configuration_name: str, - **kwargs: Any + self, resource_group_name: str, cluster_name: str, configuration_name: str, **kwargs: Any ) -> Dict[str, str]: """The configuration object for the specified cluster. This API is not recommended and might be removed in the future. Please consider using List configurations API instead. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param configuration_name: The name of the cluster configuration. + :param configuration_name: The name of the cluster configuration. Required. :type configuration_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to str, or the result of cls(response) + :return: dict mapping str to str or the result of cls(response) :rtype: dict[str, str] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Dict[str, str]] 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-06-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'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), - } - url = self._client.format_url(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[Dict[str, str]] + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + configuration_name=configuration_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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('{str}', pipeline_response) + deserialized = self._deserialize("{str}", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/configurations/{configurationName}'} # type: ignore + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/configurations/{configurationName}"} # type: ignore diff --git a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/operations/_extensions_operations.py b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/operations/_extensions_operations.py index a94fc6e3e06fe..f1f78a1c63bee 100644 --- a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/operations/_extensions_operations.py +++ b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/operations/_extensions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,985 +6,1279 @@ # 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, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, 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.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +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 azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._extensions_operations import ( + build_create_request, + build_delete_request, + build_disable_azure_monitor_request, + build_disable_monitoring_request, + build_enable_azure_monitor_request, + build_enable_monitoring_request, + build_get_azure_async_operation_status_request, + build_get_azure_monitor_status_request, + build_get_monitoring_status_request, + build_get_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ExtensionsOperations: - """ExtensionsOperations 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 ExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.hdinsight.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.hdinsight.aio.HDInsightManagementClient`'s + :attr:`extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - async def _enable_monitoring_initial( + async def _enable_monitoring_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_name: str, - parameters: "_models.ClusterMonitoringRequest", + parameters: Union[_models.ClusterMonitoringRequest, IO], **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-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._enable_monitoring_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ClusterMonitoringRequest') - 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[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ClusterMonitoringRequest") + + request = build_enable_monitoring_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._enable_monitoring_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _enable_monitoring_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/clustermonitoring'} # type: ignore + _enable_monitoring_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/clustermonitoring"} # type: ignore + @overload async def begin_enable_monitoring( self, resource_group_name: str, cluster_name: str, - parameters: "_models.ClusterMonitoringRequest", + parameters: _models.ClusterMonitoringRequest, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: """Enables the Operations Management Suite (OMS) on the HDInsight cluster. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param parameters: The Operations Management Suite (OMS) workspace parameters. + :param parameters: The Operations Management Suite (OMS) workspace parameters. Required. :type parameters: ~azure.mgmt.hdinsight.models.ClusterMonitoringRequest + :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_enable_monitoring( + self, + resource_group_name: str, + cluster_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Enables the Operations Management Suite (OMS) on the HDInsight cluster. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param parameters: The Operations Management Suite (OMS) workspace parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_enable_monitoring( + self, + resource_group_name: str, + cluster_name: str, + parameters: Union[_models.ClusterMonitoringRequest, IO], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Enables the Operations Management Suite (OMS) on the HDInsight cluster. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param parameters: The Operations Management Suite (OMS) workspace parameters. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.hdinsight.models.ClusterMonitoringRequest 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._enable_monitoring_initial( + raw_result = await self._enable_monitoring_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_enable_monitoring.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/clustermonitoring'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_enable_monitoring.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/clustermonitoring"} # type: ignore + @distributed_trace_async async def get_monitoring_status( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> "_models.ClusterMonitoringResponse": + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> _models.ClusterMonitoringResponse: """Gets the status of Operations Management Suite (OMS) on the HDInsight cluster. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ClusterMonitoringResponse, or the result of cls(response) + :return: ClusterMonitoringResponse or the result of cls(response) :rtype: ~azure.mgmt.hdinsight.models.ClusterMonitoringResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClusterMonitoringResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - accept = "application/json" - - # Construct URL - url = self.get_monitoring_status.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 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.ClusterMonitoringResponse] + + request = build_get_monitoring_status_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_monitoring_status.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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ClusterMonitoringResponse', pipeline_response) + deserialized = self._deserialize("ClusterMonitoringResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_monitoring_status.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/clustermonitoring'} # type: ignore - async def _disable_monitoring_initial( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any + get_monitoring_status.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/clustermonitoring"} # type: ignore + + async def _disable_monitoring_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, cluster_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-06-01" - accept = "application/json" - - # Construct URL - url = self._disable_monitoring_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 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_disable_monitoring_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._disable_monitoring_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _disable_monitoring_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/clustermonitoring'} # type: ignore + _disable_monitoring_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/clustermonitoring"} # type: ignore + @distributed_trace_async async def begin_disable_monitoring( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any + self, resource_group_name: str, cluster_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Disables the Operations Management Suite (OMS) on the HDInsight cluster. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. 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._disable_monitoring_initial( + raw_result = await self._disable_monitoring_initial( # type: ignore resource_group_name=resource_group_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'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_disable_monitoring.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/clustermonitoring'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_disable_monitoring.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/clustermonitoring"} # type: ignore - async def _enable_azure_monitor_initial( + async def _enable_azure_monitor_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_name: str, - parameters: "_models.AzureMonitorRequest", + parameters: Union[_models.AzureMonitorRequest, IO], **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-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._enable_azure_monitor_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'AzureMonitorRequest') - 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[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AzureMonitorRequest") + + request = build_enable_azure_monitor_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._enable_azure_monitor_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _enable_azure_monitor_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/azureMonitor'} # type: ignore + _enable_azure_monitor_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/azureMonitor"} # type: ignore + @overload async def begin_enable_azure_monitor( self, resource_group_name: str, cluster_name: str, - parameters: "_models.AzureMonitorRequest", + parameters: _models.AzureMonitorRequest, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: """Enables the Azure Monitor on the HDInsight cluster. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param parameters: The Log Analytics workspace parameters. + :param parameters: The Log Analytics workspace parameters. Required. :type parameters: ~azure.mgmt.hdinsight.models.AzureMonitorRequest + :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_enable_azure_monitor( + self, + resource_group_name: str, + cluster_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Enables the Azure Monitor on the HDInsight cluster. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param parameters: The Log Analytics workspace parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_enable_azure_monitor( + self, + resource_group_name: str, + cluster_name: str, + parameters: Union[_models.AzureMonitorRequest, IO], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Enables the Azure Monitor on the HDInsight cluster. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param parameters: The Log Analytics workspace parameters. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.hdinsight.models.AzureMonitorRequest 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._enable_azure_monitor_initial( + raw_result = await self._enable_azure_monitor_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_enable_azure_monitor.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/azureMonitor'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_enable_azure_monitor.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/azureMonitor"} # type: ignore + @distributed_trace_async async def get_azure_monitor_status( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> "_models.AzureMonitorResponse": + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> _models.AzureMonitorResponse: """Gets the status of Azure Monitor on the HDInsight cluster. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureMonitorResponse, or the result of cls(response) + :return: AzureMonitorResponse or the result of cls(response) :rtype: ~azure.mgmt.hdinsight.models.AzureMonitorResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureMonitorResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - accept = "application/json" - - # Construct URL - url = self.get_azure_monitor_status.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 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.AzureMonitorResponse] + + request = build_get_azure_monitor_status_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_azure_monitor_status.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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AzureMonitorResponse', pipeline_response) + deserialized = self._deserialize("AzureMonitorResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_azure_monitor_status.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/azureMonitor'} # type: ignore - async def _disable_azure_monitor_initial( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any + get_azure_monitor_status.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/azureMonitor"} # type: ignore + + async def _disable_azure_monitor_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, cluster_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-06-01" - accept = "application/json" - - # Construct URL - url = self._disable_azure_monitor_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 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_disable_azure_monitor_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._disable_azure_monitor_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _disable_azure_monitor_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/azureMonitor'} # type: ignore + _disable_azure_monitor_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/azureMonitor"} # type: ignore + @distributed_trace_async async def begin_disable_azure_monitor( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any + self, resource_group_name: str, cluster_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Disables the Azure Monitor on the HDInsight cluster. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. 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._disable_azure_monitor_initial( + raw_result = await self._disable_azure_monitor_initial( # type: ignore resource_group_name=resource_group_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'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_disable_azure_monitor.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/azureMonitor'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_disable_azure_monitor.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/azureMonitor"} # type: ignore - async def _create_initial( + async def _create_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, cluster_name: str, extension_name: str, - parameters: "_models.Extension", + parameters: Union[_models.Extension, IO], **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-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'extensionName': self._serialize.url("extension_name", extension_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Extension') - 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[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Extension") + + request = build_create_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + extension_name=extension_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/{extensionName}'} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/{extensionName}"} # type: ignore + @overload async def begin_create( self, resource_group_name: str, cluster_name: str, extension_name: str, - parameters: "_models.Extension", + parameters: _models.Extension, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: """Creates an HDInsight cluster extension. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param extension_name: The name of the cluster extension. + :param extension_name: The name of the cluster extension. Required. :type extension_name: str - :param parameters: The cluster extensions create request. + :param parameters: The cluster extensions create request. Required. :type parameters: ~azure.mgmt.hdinsight.models.Extension + :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_create( + self, + resource_group_name: str, + cluster_name: str, + extension_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Creates an HDInsight cluster extension. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param extension_name: The name of the cluster extension. Required. + :type extension_name: str + :param parameters: The cluster extensions create request. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + cluster_name: str, + extension_name: str, + parameters: Union[_models.Extension, IO], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Creates an HDInsight cluster extension. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param extension_name: The name of the cluster extension. Required. + :type extension_name: str + :param parameters: The cluster extensions create request. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.hdinsight.models.Extension 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._create_initial( + raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, extension_name=extension_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'extensionName': self._serialize.url("extension_name", extension_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/{extensionName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/{extensionName}"} # type: ignore + @distributed_trace_async async def get( - self, - resource_group_name: str, - cluster_name: str, - extension_name: str, - **kwargs: Any - ) -> "_models.ClusterMonitoringResponse": + self, resource_group_name: str, cluster_name: str, extension_name: str, **kwargs: Any + ) -> _models.ClusterMonitoringResponse: """Gets the extension properties for the specified HDInsight cluster extension. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param extension_name: The name of the cluster extension. + :param extension_name: The name of the cluster extension. Required. :type extension_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ClusterMonitoringResponse, or the result of cls(response) + :return: ClusterMonitoringResponse or the result of cls(response) :rtype: ~azure.mgmt.hdinsight.models.ClusterMonitoringResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClusterMonitoringResponse"] 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-06-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'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'extensionName': self._serialize.url("extension_name", extension_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + 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.ClusterMonitoringResponse] + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + extension_name=extension_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ClusterMonitoringResponse', pipeline_response) + deserialized = self._deserialize("ClusterMonitoringResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/{extensionName}'} # type: ignore - async def _delete_initial( - self, - resource_group_name: str, - cluster_name: str, - extension_name: str, - **kwargs: Any + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/{extensionName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, cluster_name: str, extension_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-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'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'extensionName': self._serialize.url("extension_name", extension_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, + cluster_name=cluster_name, + extension_name=extension_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/{extensionName}'} # type: ignore + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/{extensionName}"} # type: ignore + @distributed_trace_async async def begin_delete( - self, - resource_group_name: str, - cluster_name: str, - extension_name: str, - **kwargs: Any + self, resource_group_name: str, cluster_name: str, extension_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the specified extension for HDInsight cluster. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param extension_name: The name of the cluster extension. + :param extension_name: The name of the cluster extension. Required. :type extension_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, extension_name=extension_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'extensionName': self._serialize.url("extension_name", extension_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + 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.HDInsight/clusters/{clusterName}/extensions/{extensionName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/{extensionName}"} # type: ignore + + @distributed_trace_async async def get_azure_async_operation_status( - self, - resource_group_name: str, - cluster_name: str, - extension_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.AsyncOperationResult": + self, resource_group_name: str, cluster_name: str, extension_name: str, operation_id: str, **kwargs: Any + ) -> _models.AsyncOperationResult: """Gets the async operation status. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param extension_name: The name of the cluster extension. + :param extension_name: The name of the cluster extension. Required. :type extension_name: str - :param operation_id: The long running operation id. + :param operation_id: The long running operation id. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AsyncOperationResult, or the result of cls(response) + :return: AsyncOperationResult or the result of cls(response) :rtype: ~azure.mgmt.hdinsight.models.AsyncOperationResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AsyncOperationResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - accept = "application/json" - - # Construct URL - url = self.get_azure_async_operation_status.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'extensionName': self._serialize.url("extension_name", extension_name, 'str'), - 'operationId': self._serialize.url("operation_id", operation_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.AsyncOperationResult] + + request = build_get_azure_async_operation_status_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + extension_name=extension_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_azure_async_operation_status.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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AsyncOperationResult', pipeline_response) + deserialized = self._deserialize("AsyncOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_azure_async_operation_status.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/{extensionName}/azureAsyncOperations/{operationId}'} # type: ignore + + get_azure_async_operation_status.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/{extensionName}/azureAsyncOperations/{operationId}"} # type: ignore diff --git a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/operations/_locations_operations.py b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/operations/_locations_operations.py index 78a7cc05efbcf..3e92b90827f66 100644 --- a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/operations/_locations_operations.py +++ b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/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,387 +6,518 @@ # 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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._locations_operations import ( + build_check_name_availability_request, + build_get_azure_async_operation_status_request, + build_get_capabilities_request, + build_list_billing_specs_request, + build_list_usages_request, + build_validate_cluster_create_request_request, +) + +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.hdinsight.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.hdinsight.aio.HDInsightManagementClient`'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") - async def get_capabilities( - self, - location: str, - **kwargs: Any - ) -> "_models.CapabilitiesResult": + @distributed_trace_async + async def get_capabilities(self, location: str, **kwargs: Any) -> _models.CapabilitiesResult: """Gets the capabilities for the specified location. - :param location: The Azure location (region) for which to make the request. + :param location: The Azure location (region) for which to make the request. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CapabilitiesResult, or the result of cls(response) + :return: CapabilitiesResult or the result of cls(response) :rtype: ~azure.mgmt.hdinsight.models.CapabilitiesResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapabilitiesResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - accept = "application/json" - - # Construct URL - url = self.get_capabilities.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - '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.CapabilitiesResult] + + request = build_get_capabilities_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_capabilities.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CapabilitiesResult', pipeline_response) + deserialized = self._deserialize("CapabilitiesResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_capabilities.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HDInsight/locations/{location}/capabilities'} # type: ignore - async def list_usages( - self, - location: str, - **kwargs: Any - ) -> "_models.UsagesListResult": + get_capabilities.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.HDInsight/locations/{location}/capabilities"} # type: ignore + + @distributed_trace_async + async def list_usages(self, location: str, **kwargs: Any) -> _models.UsagesListResult: """Lists the usages for the specified location. - :param location: The Azure location (region) for which to make the request. + :param location: The Azure location (region) for which to make the request. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: UsagesListResult, or the result of cls(response) + :return: UsagesListResult or the result of cls(response) :rtype: ~azure.mgmt.hdinsight.models.UsagesListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UsagesListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - accept = "application/json" - - # Construct URL - url = self.list_usages.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - '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 {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.UsagesListResult] - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = build_list_usages_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_usages.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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('UsagesListResult', pipeline_response) + deserialized = self._deserialize("UsagesListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_usages.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HDInsight/locations/{location}/usages'} # type: ignore - async def list_billing_specs( - self, - location: str, - **kwargs: Any - ) -> "_models.BillingResponseListResult": + list_usages.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.HDInsight/locations/{location}/usages"} # type: ignore + + @distributed_trace_async + async def list_billing_specs(self, location: str, **kwargs: Any) -> _models.BillingResponseListResult: """Lists the billingSpecs for the specified subscription and location. - :param location: The Azure location (region) for which to make the request. + :param location: The Azure location (region) for which to make the request. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BillingResponseListResult, or the result of cls(response) + :return: BillingResponseListResult or the result of cls(response) :rtype: ~azure.mgmt.hdinsight.models.BillingResponseListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BillingResponseListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - accept = "application/json" - - # Construct URL - url = self.list_billing_specs.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - '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.BillingResponseListResult] + + request = build_list_billing_specs_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_billing_specs.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('BillingResponseListResult', pipeline_response) + deserialized = self._deserialize("BillingResponseListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_billing_specs.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HDInsight/locations/{location}/billingSpecs'} # type: ignore + list_billing_specs.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.HDInsight/locations/{location}/billingSpecs"} # type: ignore + + @distributed_trace_async async def get_azure_async_operation_status( - self, - location: str, - operation_id: str, - **kwargs: Any - ) -> "_models.AsyncOperationResult": + self, location: str, operation_id: str, **kwargs: Any + ) -> _models.AsyncOperationResult: """Get the async operation status. - :param location: The Azure location (region) for which to make the request. + :param location: The Azure location (region) for which to make the request. Required. :type location: str - :param operation_id: The long running operation id. + :param operation_id: The long running operation id. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AsyncOperationResult, or the result of cls(response) + :return: AsyncOperationResult or the result of cls(response) :rtype: ~azure.mgmt.hdinsight.models.AsyncOperationResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AsyncOperationResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - accept = "application/json" - - # Construct URL - url = self.get_azure_async_operation_status.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'location': self._serialize.url("location", location, 'str'), - 'operationId': self._serialize.url("operation_id", operation_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['Accept'] = self._serialize.header("accept", accept, '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.AsyncOperationResult] + + request = build_get_azure_async_operation_status_request( + location=location, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_azure_async_operation_status.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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AsyncOperationResult', pipeline_response) + deserialized = self._deserialize("AsyncOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_azure_async_operation_status.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HDInsight/locations/{location}/azureasyncoperations/{operationId}'} # type: ignore + get_azure_async_operation_status.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.HDInsight/locations/{location}/azureasyncoperations/{operationId}"} # type: ignore + + @overload async def check_name_availability( self, location: str, - parameters: "_models.NameAvailabilityCheckRequestParameters", + parameters: _models.NameAvailabilityCheckRequestParameters, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.NameAvailabilityCheckResult": + ) -> _models.NameAvailabilityCheckResult: """Check the cluster name is available or not. - :param location: The Azure location (region) for which to make the request. + :param location: The Azure location (region) for which to make the request. Required. :type location: str - :param parameters: + :param parameters: Required. :type parameters: ~azure.mgmt.hdinsight.models.NameAvailabilityCheckRequestParameters + :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: NameAvailabilityCheckResult, or the result of cls(response) + :return: NameAvailabilityCheckResult or the result of cls(response) :rtype: ~azure.mgmt.hdinsight.models.NameAvailabilityCheckResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, location: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.NameAvailabilityCheckResult: + """Check the cluster name is available or not. + + :param location: The Azure location (region) for which to make the request. Required. + :type location: str + :param parameters: Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: NameAvailabilityCheckResult or the result of cls(response) + :rtype: ~azure.mgmt.hdinsight.models.NameAvailabilityCheckResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, location: str, parameters: Union[_models.NameAvailabilityCheckRequestParameters, IO], **kwargs: Any + ) -> _models.NameAvailabilityCheckResult: + """Check the cluster name is available or not. + + :param location: The Azure location (region) for which to make the request. Required. + :type location: str + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.hdinsight.models.NameAvailabilityCheckRequestParameters 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: NameAvailabilityCheckResult or the result of cls(response) + :rtype: ~azure.mgmt.hdinsight.models.NameAvailabilityCheckResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NameAvailabilityCheckResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'location': self._serialize.url("location", location, '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(parameters, 'NameAvailabilityCheckRequestParameters') - 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[_models.NameAvailabilityCheckResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NameAvailabilityCheckRequestParameters") + + request = build_check_name_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_name_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 + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NameAvailabilityCheckResult', pipeline_response) + deserialized = self._deserialize("NameAvailabilityCheckResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HDInsight/locations/{location}/checkNameAvailability'} # type: ignore + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.HDInsight/locations/{location}/checkNameAvailability"} # type: ignore + + @overload async def validate_cluster_create_request( self, location: str, - parameters: "_models.ClusterCreateRequestValidationParameters", + parameters: _models.ClusterCreateRequestValidationParameters, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.ClusterCreateValidationResult": + ) -> _models.ClusterCreateValidationResult: """Validate the cluster create request spec is valid or not. - :param location: The Azure location (region) for which to make the request. + :param location: The Azure location (region) for which to make the request. Required. :type location: str - :param parameters: + :param parameters: Required. :type parameters: ~azure.mgmt.hdinsight.models.ClusterCreateRequestValidationParameters + :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: ClusterCreateValidationResult, or the result of cls(response) + :return: ClusterCreateValidationResult or the result of cls(response) :rtype: ~azure.mgmt.hdinsight.models.ClusterCreateValidationResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def validate_cluster_create_request( + self, location: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ClusterCreateValidationResult: + """Validate the cluster create request spec is valid or not. + + :param location: The Azure location (region) for which to make the request. Required. + :type location: str + :param parameters: Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ClusterCreateValidationResult or the result of cls(response) + :rtype: ~azure.mgmt.hdinsight.models.ClusterCreateValidationResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def validate_cluster_create_request( + self, location: str, parameters: Union[_models.ClusterCreateRequestValidationParameters, IO], **kwargs: Any + ) -> _models.ClusterCreateValidationResult: + """Validate the cluster create request spec is valid or not. + + :param location: The Azure location (region) for which to make the request. Required. + :type location: str + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.hdinsight.models.ClusterCreateRequestValidationParameters 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: ClusterCreateValidationResult or the result of cls(response) + :rtype: ~azure.mgmt.hdinsight.models.ClusterCreateValidationResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClusterCreateValidationResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate_cluster_create_request.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'location': self._serialize.url("location", location, '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(parameters, 'ClusterCreateRequestValidationParameters') - 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[_models.ClusterCreateValidationResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ClusterCreateRequestValidationParameters") + + request = build_validate_cluster_create_request_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.validate_cluster_create_request.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ClusterCreateValidationResult', pipeline_response) + deserialized = self._deserialize("ClusterCreateValidationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_cluster_create_request.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HDInsight/locations/{location}/validateCreateRequest'} # type: ignore + + validate_cluster_create_request.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.HDInsight/locations/{location}/validateCreateRequest"} # type: ignore diff --git a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/operations/_operations.py b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/operations/_operations.py index b5277c2677cb2..8ff2d007f665e 100644 --- a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/operations/_operations.py +++ b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/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.hdinsight.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.hdinsight.aio.HDInsightManagementClient`'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.OperationListResult"]: + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available HDInsight REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hdinsight.models.OperationListResult] - :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.hdinsight.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _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.OperationListResult] + 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-06-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('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -89,17 +115,18 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.HDInsight/operations'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.HDInsight/operations"} # type: ignore diff --git a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/operations/_patch.py b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/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/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/operations/_private_endpoint_connections_operations.py b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/operations/_private_endpoint_connections_operations.py index 86e8bda4e5eef..e8a37c100a65c 100644 --- a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/operations/_private_endpoint_connections_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,96 +6,126 @@ # 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_endpoint_connections_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_cluster_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PrivateEndpointConnectionsOperations: - """PrivateEndpointConnectionsOperations 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 PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.hdinsight.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.hdinsight.aio.HDInsightManagementClient`'s + :attr:`private_endpoint_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_by_cluster( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.PrivateEndpointConnectionListResult"]: + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateEndpointConnection"]: """Lists the private endpoint connections for a HDInsight cluster. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hdinsight.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hdinsight.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] + _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.PrivateEndpointConnectionListResult] + 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-06-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_by_cluster.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_cluster_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_cluster.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('PrivateEndpointConnectionListResult', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -103,332 +134,433 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_cluster.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/privateEndpointConnections'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + + list_by_cluster.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/privateEndpointConnections"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, cluster_name: str, private_endpoint_connection_name: str, - parameters: "_models.PrivateEndpointConnection", + parameters: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> "_models.PrivateEndpointConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] + ) -> _models.PrivateEndpointConnection: 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-06-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'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_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(parameters, 'PrivateEndpointConnection') - 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.PrivateEndpointConnection] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PrivateEndpointConnection") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + private_endpoint_connection_name=private_endpoint_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + @overload async def begin_create_or_update( self, resource_group_name: str, cluster_name: str, private_endpoint_connection_name: str, - parameters: "_models.PrivateEndpointConnection", + parameters: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.PrivateEndpointConnection"]: + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: """Approve or reject a private endpoint connection manually. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str - :param parameters: The private endpoint connection create or update request. + :param parameters: The private endpoint connection create or update request. Required. :type parameters: ~azure.mgmt.hdinsight.models.PrivateEndpointConnection + :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 PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hdinsight.models.PrivateEndpointConnection] + :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 PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hdinsight.models.PrivateEndpointConnection] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - 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, + cluster_name: str, + private_endpoint_connection_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Approve or reject a private endpoint connection manually. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param parameters: The private endpoint connection create or update request. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hdinsight.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + cluster_name: str, + private_endpoint_connection_name: str, + parameters: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Approve or reject a private endpoint connection manually. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param parameters: The private endpoint connection create or update request. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.hdinsight.models.PrivateEndpointConnection 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 PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hdinsight.models.PrivateEndpointConnection] + :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.PrivateEndpointConnection] + 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, cluster_name=cluster_name, private_endpoint_connection_name=private_endpoint_connection_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) - + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}'} # 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.HDInsight/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + @distributed_trace_async async def get( - self, - resource_group_name: str, - cluster_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + self, resource_group_name: str, cluster_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: """Gets the specific private endpoint connection. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.hdinsight.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-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'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_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.PrivateEndpointConnection] + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + private_endpoint_connection_name=private_endpoint_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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - async def _delete_initial( - self, - resource_group_name: str, - cluster_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, cluster_name: str, private_endpoint_connection_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-06-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'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_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, + cluster_name=cluster_name, + private_endpoint_connection_name=private_endpoint_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + @distributed_trace_async async def begin_delete( - self, - resource_group_name: str, - cluster_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, cluster_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Deletes the specific private endpoint connection. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_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, cluster_name=cluster_name, private_endpoint_connection_name=private_endpoint_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'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/operations/_private_link_resources_operations.py b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/operations/_private_link_resources_operations.py index 4d6e798ec6dcd..8f3dbbeef8ff1 100644 --- a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/operations/_private_link_resources_operations.py +++ b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/operations/_private_link_resources_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,159 +6,171 @@ # 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, Optional, TypeVar + +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._private_link_resources_operations import build_get_request, build_list_by_cluster_request -T = TypeVar('T') +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PrivateLinkResourcesOperations: - """PrivateLinkResourcesOperations 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 PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.hdinsight.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.hdinsight.aio.HDInsightManagementClient`'s + :attr:`private_link_resources` 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_async async def list_by_cluster( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> "_models.PrivateLinkResourceListResult": + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> _models.PrivateLinkResourceListResult: """Lists the private link resources in a HDInsight cluster. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResourceListResult, or the result of cls(response) + :return: PrivateLinkResourceListResult or the result of cls(response) :rtype: ~azure.mgmt.hdinsight.models.PrivateLinkResourceListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - accept = "application/json" - - # Construct URL - url = self.list_by_cluster.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 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.PrivateLinkResourceListResult] + + request = build_list_by_cluster_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_cluster.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 + ) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResourceListResult', pipeline_response) + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_cluster.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/privateLinkResources'} # type: ignore + list_by_cluster.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/privateLinkResources"} # type: ignore + + @distributed_trace_async async def get( - self, - resource_group_name: str, - cluster_name: str, - private_link_resource_name: str, - **kwargs: Any - ) -> "_models.PrivateLinkResource": + self, resource_group_name: str, cluster_name: str, private_link_resource_name: str, **kwargs: Any + ) -> _models.PrivateLinkResource: """Gets the specific private link resource. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param private_link_resource_name: The name of the private link resource. + :param private_link_resource_name: The name of the private link resource. Required. :type private_link_resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResource, or the result of cls(response) + :return: PrivateLinkResource or the result of cls(response) :rtype: ~azure.mgmt.hdinsight.models.PrivateLinkResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-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'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'privateLinkResourceName': self._serialize.url("private_link_resource_name", private_link_resource_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 {}) + + _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.PrivateLinkResource] + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + private_link_resource_name=private_link_resource_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 + ) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResource', pipeline_response) + deserialized = self._deserialize("PrivateLinkResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/privateLinkResources/{privateLinkResourceName}'} # type: ignore + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/privateLinkResources/{privateLinkResourceName}"} # type: ignore diff --git a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/operations/_script_actions_operations.py b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/operations/_script_actions_operations.py index e2aa1d1e338c8..6f735cca799f7 100644 --- a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/operations/_script_actions_operations.py +++ b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/operations/_script_actions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,154 +6,184 @@ # 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 - -T = TypeVar('T') +from ..._vendor import _convert_request +from ...operations._script_actions_operations import ( + build_delete_request, + build_get_execution_async_operation_status_request, + build_get_execution_detail_request, + build_list_by_cluster_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ScriptActionsOperations: - """ScriptActionsOperations 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 ScriptActionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.hdinsight.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.hdinsight.aio.HDInsightManagementClient`'s + :attr:`script_actions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - async def delete( - self, - resource_group_name: str, - cluster_name: str, - script_name: str, - **kwargs: Any + 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_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, cluster_name: str, script_name: str, **kwargs: Any ) -> None: """Deletes a specified persisted script action of the cluster. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param script_name: The name of the script. + :param script_name: The name of the script. Required. :type script_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-06-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'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'scriptName': self._serialize.url("script_name", script_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, + cluster_name=cluster_name, + script_name=script_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/scriptActions/{scriptName}'} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/scriptActions/{scriptName}"} # type: ignore + @distributed_trace def list_by_cluster( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ScriptActionsList"]: + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> AsyncIterable["_models.RuntimeScriptActionDetail"]: """Lists all the persisted script actions for the specified cluster. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ScriptActionsList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hdinsight.models.ScriptActionsList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either RuntimeScriptActionDetail or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hdinsight.models.RuntimeScriptActionDetail] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScriptActionsList"] + _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.ScriptActionsList] + 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-06-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_by_cluster.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_cluster_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_cluster.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('ScriptActionsList', pipeline_response) + deserialized = self._deserialize("ScriptActionsList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -161,143 +192,146 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_cluster.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/scriptActions'} # type: ignore + return AsyncItemPaged(get_next, extract_data) + list_by_cluster.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/scriptActions"} # type: ignore + + @distributed_trace_async async def get_execution_detail( - self, - resource_group_name: str, - cluster_name: str, - script_execution_id: str, - **kwargs: Any - ) -> "_models.RuntimeScriptActionDetail": + self, resource_group_name: str, cluster_name: str, script_execution_id: str, **kwargs: Any + ) -> _models.RuntimeScriptActionDetail: """Gets the script execution detail for the given script execution ID. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param script_execution_id: The script execution Id. + :param script_execution_id: The script execution Id. Required. :type script_execution_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RuntimeScriptActionDetail, or the result of cls(response) + :return: RuntimeScriptActionDetail or the result of cls(response) :rtype: ~azure.mgmt.hdinsight.models.RuntimeScriptActionDetail - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RuntimeScriptActionDetail"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - accept = "application/json" - - # Construct URL - url = self.get_execution_detail.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'scriptExecutionId': self._serialize.url("script_execution_id", script_execution_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.RuntimeScriptActionDetail] + + request = build_get_execution_detail_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + script_execution_id=script_execution_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_execution_detail.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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('RuntimeScriptActionDetail', pipeline_response) + deserialized = self._deserialize("RuntimeScriptActionDetail", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_execution_detail.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/scriptExecutionHistory/{scriptExecutionId}'} # type: ignore + get_execution_detail.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/scriptExecutionHistory/{scriptExecutionId}"} # type: ignore + + @distributed_trace_async async def get_execution_async_operation_status( - self, - resource_group_name: str, - cluster_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.AsyncOperationResult": + self, resource_group_name: str, cluster_name: str, operation_id: str, **kwargs: Any + ) -> _models.AsyncOperationResult: """Gets the async operation status of execution operation. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param operation_id: The long running operation id. + :param operation_id: The long running operation id. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AsyncOperationResult, or the result of cls(response) + :return: AsyncOperationResult or the result of cls(response) :rtype: ~azure.mgmt.hdinsight.models.AsyncOperationResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AsyncOperationResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - accept = "application/json" - - # Construct URL - url = self.get_execution_async_operation_status.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'operationId': self._serialize.url("operation_id", operation_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.AsyncOperationResult] + + request = build_get_execution_async_operation_status_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_execution_async_operation_status.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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AsyncOperationResult', pipeline_response) + deserialized = self._deserialize("AsyncOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_execution_async_operation_status.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/executeScriptActions/azureasyncoperations/{operationId}'} # type: ignore + + get_execution_async_operation_status.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/executeScriptActions/azureasyncoperations/{operationId}"} # type: ignore diff --git a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/operations/_script_execution_history_operations.py b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/operations/_script_execution_history_operations.py index 7b0937b844ed5..0a8e080255793 100644 --- a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/operations/_script_execution_history_operations.py +++ b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/operations/_script_execution_history_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,94 +6,119 @@ # 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_execution_history_operations import build_list_by_cluster_request, build_promote_request -T = TypeVar('T') +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ScriptExecutionHistoryOperations: - """ScriptExecutionHistoryOperations 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 ScriptExecutionHistoryOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.hdinsight.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.hdinsight.aio.HDInsightManagementClient`'s + :attr:`script_execution_history` 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_by_cluster( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ScriptActionExecutionHistoryList"]: + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> AsyncIterable["_models.RuntimeScriptActionDetail"]: """Lists all scripts' execution history for the specified cluster. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ScriptActionExecutionHistoryList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hdinsight.models.ScriptActionExecutionHistoryList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either RuntimeScriptActionDetail or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hdinsight.models.RuntimeScriptActionDetail] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScriptActionExecutionHistoryList"] + _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.ScriptActionExecutionHistoryList] + 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-06-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_by_cluster.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_cluster_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_cluster.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('ScriptActionExecutionHistoryList', pipeline_response) + deserialized = self._deserialize("ScriptActionExecutionHistoryList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -101,77 +127,78 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response - return AsyncItemPaged( - get_next, extract_data - ) - list_by_cluster.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/scriptExecutionHistory'} # type: ignore - - async def promote( - self, - resource_group_name: str, - cluster_name: str, - script_execution_id: str, - **kwargs: Any + return AsyncItemPaged(get_next, extract_data) + + list_by_cluster.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/scriptExecutionHistory"} # type: ignore + + @distributed_trace_async + async def promote( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, cluster_name: str, script_execution_id: str, **kwargs: Any ) -> None: """Promotes the specified ad-hoc script execution to a persisted script. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param script_execution_id: The script execution Id. + :param script_execution_id: The script execution Id. Required. :type script_execution_id: 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-06-01" - accept = "application/json" - - # Construct URL - url = self.promote.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'scriptExecutionId': self._serialize.url("script_execution_id", script_execution_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_promote_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + script_execution_id=script_execution_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.promote.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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - promote.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/scriptExecutionHistory/{scriptExecutionId}/promote'} # type: ignore + promote.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/scriptExecutionHistory/{scriptExecutionId}/promote"} # type: ignore diff --git a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/operations/_virtual_machines_operations.py b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/operations/_virtual_machines_operations.py index ace7a43786ee9..7819964cd0bbe 100644 --- a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/aio/operations/_virtual_machines_operations.py +++ b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/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,280 +6,373 @@ # 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, List, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, 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.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +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 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_async_operation_status_request, + build_list_hosts_request, + build_restart_hosts_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.hdinsight.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.hdinsight.aio.HDInsightManagementClient`'s + :attr:`virtual_machines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - async def list_hosts( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> List["_models.HostInfo"]: + @distributed_trace_async + async def list_hosts(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> List[_models.HostInfo]: """Lists the HDInsight clusters hosts. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of HostInfo, or the result of cls(response) + :return: list of HostInfo or the result of cls(response) :rtype: list[~azure.mgmt.hdinsight.models.HostInfo] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.HostInfo"]] 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-06-01" - accept = "application/json" - - # Construct URL - url = self.list_hosts.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + 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[List[_models.HostInfo]] + + request = build_list_hosts_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_hosts.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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('[HostInfo]', pipeline_response) + deserialized = self._deserialize("[HostInfo]", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_hosts.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/listHosts'} # type: ignore - async def _restart_hosts_initial( - self, - resource_group_name: str, - cluster_name: str, - hosts: List[str], - **kwargs: Any + list_hosts.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/listHosts"} # type: ignore + + async def _restart_hosts_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, cluster_name: str, hosts: Union[List[str], IO], **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-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._restart_hosts_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(hosts, '[str]') - 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(hosts, (IO, bytes)): + _content = hosts + else: + _json = self._serialize.body(hosts, "[str]") + + request = build_restart_hosts_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._restart_hosts_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _restart_hosts_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/restartHosts'} # type: ignore + _restart_hosts_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/restartHosts"} # type: ignore + @overload async def begin_restart_hosts( self, resource_group_name: str, cluster_name: str, hosts: List[str], + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: """Restarts the specified HDInsight cluster hosts. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param hosts: The list of hosts to restart. + :param hosts: The list of hosts to restart. Required. :type hosts: list[str] + :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_restart_hosts( + self, + resource_group_name: str, + cluster_name: str, + hosts: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Restarts the specified HDInsight cluster hosts. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param hosts: The list of hosts to restart. Required. + :type hosts: 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_restart_hosts( + self, resource_group_name: str, cluster_name: str, hosts: Union[List[str], IO], **kwargs: Any + ) -> AsyncLROPoller[None]: + """Restarts the specified HDInsight cluster hosts. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param hosts: The list of hosts to restart. Is either a list type or a IO type. Required. + :type hosts: list[str] 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._restart_hosts_initial( + raw_result = await self._restart_hosts_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, hosts=hosts, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_restart_hosts.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/restartHosts'} # type: ignore + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_restart_hosts.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/restartHosts"} # type: ignore + + @distributed_trace_async async def get_async_operation_status( - self, - resource_group_name: str, - cluster_name: str, - operation_id: str, - **kwargs: Any - ) -> "_models.AsyncOperationResult": + self, resource_group_name: str, cluster_name: str, operation_id: str, **kwargs: Any + ) -> _models.AsyncOperationResult: """Gets the async operation status. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param operation_id: The long running operation id. + :param operation_id: The long running operation id. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AsyncOperationResult, or the result of cls(response) + :return: AsyncOperationResult or the result of cls(response) :rtype: ~azure.mgmt.hdinsight.models.AsyncOperationResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AsyncOperationResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - accept = "application/json" - - # Construct URL - url = self.get_async_operation_status.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'operationId': self._serialize.url("operation_id", operation_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.AsyncOperationResult] + + request = build_get_async_operation_status_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_async_operation_status.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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AsyncOperationResult', pipeline_response) + deserialized = self._deserialize("AsyncOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_async_operation_status.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/restartHosts/azureasyncoperations/{operationId}'} # type: ignore + + get_async_operation_status.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/restartHosts/azureasyncoperations/{operationId}"} # type: ignore diff --git a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/models/__init__.py b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/models/__init__.py index bf995f40d2f41..6d617a981e1f0 100644 --- a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/models/__init__.py +++ b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/models/__init__.py @@ -6,372 +6,264 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import AaddsResourceDetails - from ._models_py3 import Application - from ._models_py3 import ApplicationGetEndpoint - from ._models_py3 import ApplicationGetHttpsEndpoint - from ._models_py3 import ApplicationListResult - from ._models_py3 import ApplicationProperties - from ._models_py3 import AsyncOperationResult - from ._models_py3 import Autoscale - from ._models_py3 import AutoscaleCapacity - from ._models_py3 import AutoscaleConfigurationUpdateParameter - from ._models_py3 import AutoscaleRecurrence - from ._models_py3 import AutoscaleSchedule - from ._models_py3 import AutoscaleTimeAndCapacity - from ._models_py3 import AzureMonitorRequest - from ._models_py3 import AzureMonitorResponse - from ._models_py3 import AzureMonitorSelectedConfigurations - from ._models_py3 import AzureMonitorTableConfiguration - from ._models_py3 import BillingMeters - from ._models_py3 import BillingResources - from ._models_py3 import BillingResponseListResult - from ._models_py3 import CapabilitiesResult - from ._models_py3 import ClientGroupInfo - from ._models_py3 import Cluster - from ._models_py3 import ClusterConfigurations - from ._models_py3 import ClusterCreateParametersExtended - from ._models_py3 import ClusterCreateProperties - from ._models_py3 import ClusterCreateRequestValidationParameters - from ._models_py3 import ClusterCreateValidationResult - from ._models_py3 import ClusterDefinition - from ._models_py3 import ClusterDiskEncryptionParameters - from ._models_py3 import ClusterGetProperties - from ._models_py3 import ClusterIdentity - from ._models_py3 import ClusterListPersistedScriptActionsResult - from ._models_py3 import ClusterListResult - from ._models_py3 import ClusterMonitoringRequest - from ._models_py3 import ClusterMonitoringResponse - from ._models_py3 import ClusterPatchParameters - from ._models_py3 import ClusterResizeParameters - from ._models_py3 import ComputeIsolationProperties - from ._models_py3 import ComputeProfile - from ._models_py3 import ConnectivityEndpoint - from ._models_py3 import DataDisksGroups - from ._models_py3 import Dimension - from ._models_py3 import DiskBillingMeters - from ._models_py3 import DiskEncryptionProperties - from ._models_py3 import EncryptionInTransitProperties - from ._models_py3 import ErrorResponse - from ._models_py3 import Errors - from ._models_py3 import ExcludedServicesConfig - from ._models_py3 import ExecuteScriptActionParameters - from ._models_py3 import Extension - from ._models_py3 import GatewaySettings - from ._models_py3 import HardwareProfile - from ._models_py3 import HostInfo - from ._models_py3 import IPConfiguration - from ._models_py3 import KafkaRestProperties - from ._models_py3 import LinuxOperatingSystemProfile - from ._models_py3 import LocalizedName - from ._models_py3 import MetricSpecifications - from ._models_py3 import NameAvailabilityCheckRequestParameters - from ._models_py3 import NameAvailabilityCheckResult - from ._models_py3 import NetworkProperties - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationListResult - from ._models_py3 import OperationProperties - from ._models_py3 import OsProfile - from ._models_py3 import PrivateEndpoint - from ._models_py3 import PrivateEndpointConnection - from ._models_py3 import PrivateEndpointConnectionListResult - from ._models_py3 import PrivateLinkConfiguration - from ._models_py3 import PrivateLinkResource - from ._models_py3 import PrivateLinkResourceListResult - from ._models_py3 import PrivateLinkServiceConnectionState - from ._models_py3 import ProxyResource - from ._models_py3 import QuotaCapability - from ._models_py3 import QuotaInfo - from ._models_py3 import RegionalQuotaCapability - from ._models_py3 import RegionsCapability - from ._models_py3 import Resource - from ._models_py3 import ResourceAutoGenerated - from ._models_py3 import ResourceId - from ._models_py3 import Role - from ._models_py3 import RuntimeScriptAction - from ._models_py3 import RuntimeScriptActionDetail - from ._models_py3 import ScriptAction - from ._models_py3 import ScriptActionExecutionHistoryList - from ._models_py3 import ScriptActionExecutionSummary - from ._models_py3 import ScriptActionPersistedGetResponseSpec - from ._models_py3 import ScriptActionsList - from ._models_py3 import SecurityProfile - from ._models_py3 import ServiceSpecification - from ._models_py3 import SshProfile - from ._models_py3 import SshPublicKey - from ._models_py3 import StorageAccount - from ._models_py3 import StorageProfile - from ._models_py3 import SystemData - from ._models_py3 import TrackedResource - from ._models_py3 import UpdateClusterIdentityCertificateParameters - from ._models_py3 import UpdateGatewaySettingsParameters - from ._models_py3 import Usage - from ._models_py3 import UsagesListResult - from ._models_py3 import UserAssignedIdentity - from ._models_py3 import ValidationErrorInfo - from ._models_py3 import VersionSpec - from ._models_py3 import VersionsCapability - from ._models_py3 import VirtualNetworkProfile - from ._models_py3 import VmSizeCompatibilityFilterV2 - from ._models_py3 import VmSizeProperty -except (SyntaxError, ImportError): - from ._models import AaddsResourceDetails # type: ignore - from ._models import Application # type: ignore - from ._models import ApplicationGetEndpoint # type: ignore - from ._models import ApplicationGetHttpsEndpoint # type: ignore - from ._models import ApplicationListResult # type: ignore - from ._models import ApplicationProperties # type: ignore - from ._models import AsyncOperationResult # type: ignore - from ._models import Autoscale # type: ignore - from ._models import AutoscaleCapacity # type: ignore - from ._models import AutoscaleConfigurationUpdateParameter # type: ignore - from ._models import AutoscaleRecurrence # type: ignore - from ._models import AutoscaleSchedule # type: ignore - from ._models import AutoscaleTimeAndCapacity # type: ignore - from ._models import AzureMonitorRequest # type: ignore - from ._models import AzureMonitorResponse # type: ignore - from ._models import AzureMonitorSelectedConfigurations # type: ignore - from ._models import AzureMonitorTableConfiguration # type: ignore - from ._models import BillingMeters # type: ignore - from ._models import BillingResources # type: ignore - from ._models import BillingResponseListResult # type: ignore - from ._models import CapabilitiesResult # type: ignore - from ._models import ClientGroupInfo # type: ignore - from ._models import Cluster # type: ignore - from ._models import ClusterConfigurations # type: ignore - from ._models import ClusterCreateParametersExtended # type: ignore - from ._models import ClusterCreateProperties # type: ignore - from ._models import ClusterCreateRequestValidationParameters # type: ignore - from ._models import ClusterCreateValidationResult # type: ignore - from ._models import ClusterDefinition # type: ignore - from ._models import ClusterDiskEncryptionParameters # type: ignore - from ._models import ClusterGetProperties # type: ignore - from ._models import ClusterIdentity # type: ignore - from ._models import ClusterListPersistedScriptActionsResult # type: ignore - from ._models import ClusterListResult # type: ignore - from ._models import ClusterMonitoringRequest # type: ignore - from ._models import ClusterMonitoringResponse # type: ignore - from ._models import ClusterPatchParameters # type: ignore - from ._models import ClusterResizeParameters # type: ignore - from ._models import ComputeIsolationProperties # type: ignore - from ._models import ComputeProfile # type: ignore - from ._models import ConnectivityEndpoint # type: ignore - from ._models import DataDisksGroups # type: ignore - from ._models import Dimension # type: ignore - from ._models import DiskBillingMeters # type: ignore - from ._models import DiskEncryptionProperties # type: ignore - from ._models import EncryptionInTransitProperties # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import Errors # type: ignore - from ._models import ExcludedServicesConfig # type: ignore - from ._models import ExecuteScriptActionParameters # type: ignore - from ._models import Extension # type: ignore - from ._models import GatewaySettings # type: ignore - from ._models import HardwareProfile # type: ignore - from ._models import HostInfo # type: ignore - from ._models import IPConfiguration # type: ignore - from ._models import KafkaRestProperties # type: ignore - from ._models import LinuxOperatingSystemProfile # type: ignore - from ._models import LocalizedName # type: ignore - from ._models import MetricSpecifications # type: ignore - from ._models import NameAvailabilityCheckRequestParameters # type: ignore - from ._models import NameAvailabilityCheckResult # type: ignore - from ._models import NetworkProperties # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationListResult # type: ignore - from ._models import OperationProperties # type: ignore - from ._models import OsProfile # type: ignore - from ._models import PrivateEndpoint # type: ignore - from ._models import PrivateEndpointConnection # type: ignore - from ._models import PrivateEndpointConnectionListResult # type: ignore - from ._models import PrivateLinkConfiguration # type: ignore - from ._models import PrivateLinkResource # type: ignore - from ._models import PrivateLinkResourceListResult # type: ignore - from ._models import PrivateLinkServiceConnectionState # type: ignore - from ._models import ProxyResource # type: ignore - from ._models import QuotaCapability # type: ignore - from ._models import QuotaInfo # type: ignore - from ._models import RegionalQuotaCapability # type: ignore - from ._models import RegionsCapability # type: ignore - from ._models import Resource # type: ignore - from ._models import ResourceAutoGenerated # type: ignore - from ._models import ResourceId # type: ignore - from ._models import Role # type: ignore - from ._models import RuntimeScriptAction # type: ignore - from ._models import RuntimeScriptActionDetail # type: ignore - from ._models import ScriptAction # type: ignore - from ._models import ScriptActionExecutionHistoryList # type: ignore - from ._models import ScriptActionExecutionSummary # type: ignore - from ._models import ScriptActionPersistedGetResponseSpec # type: ignore - from ._models import ScriptActionsList # type: ignore - from ._models import SecurityProfile # type: ignore - from ._models import ServiceSpecification # type: ignore - from ._models import SshProfile # type: ignore - from ._models import SshPublicKey # type: ignore - from ._models import StorageAccount # type: ignore - from ._models import StorageProfile # type: ignore - from ._models import SystemData # type: ignore - from ._models import TrackedResource # type: ignore - from ._models import UpdateClusterIdentityCertificateParameters # type: ignore - from ._models import UpdateGatewaySettingsParameters # type: ignore - from ._models import Usage # type: ignore - from ._models import UsagesListResult # type: ignore - from ._models import UserAssignedIdentity # type: ignore - from ._models import ValidationErrorInfo # type: ignore - from ._models import VersionSpec # type: ignore - from ._models import VersionsCapability # type: ignore - from ._models import VirtualNetworkProfile # type: ignore - from ._models import VmSizeCompatibilityFilterV2 # type: ignore - from ._models import VmSizeProperty # type: ignore +from ._models_py3 import AaddsResourceDetails +from ._models_py3 import Application +from ._models_py3 import ApplicationGetEndpoint +from ._models_py3 import ApplicationGetHttpsEndpoint +from ._models_py3 import ApplicationListResult +from ._models_py3 import ApplicationProperties +from ._models_py3 import AsyncOperationResult +from ._models_py3 import Autoscale +from ._models_py3 import AutoscaleCapacity +from ._models_py3 import AutoscaleConfigurationUpdateParameter +from ._models_py3 import AutoscaleRecurrence +from ._models_py3 import AutoscaleSchedule +from ._models_py3 import AutoscaleTimeAndCapacity +from ._models_py3 import AzureMonitorRequest +from ._models_py3 import AzureMonitorResponse +from ._models_py3 import AzureMonitorSelectedConfigurations +from ._models_py3 import AzureMonitorTableConfiguration +from ._models_py3 import BillingMeters +from ._models_py3 import BillingResources +from ._models_py3 import BillingResponseListResult +from ._models_py3 import CapabilitiesResult +from ._models_py3 import ClientGroupInfo +from ._models_py3 import Cluster +from ._models_py3 import ClusterConfigurations +from ._models_py3 import ClusterCreateParametersExtended +from ._models_py3 import ClusterCreateProperties +from ._models_py3 import ClusterCreateRequestValidationParameters +from ._models_py3 import ClusterCreateValidationResult +from ._models_py3 import ClusterDefinition +from ._models_py3 import ClusterDiskEncryptionParameters +from ._models_py3 import ClusterGetProperties +from ._models_py3 import ClusterIdentity +from ._models_py3 import ClusterListPersistedScriptActionsResult +from ._models_py3 import ClusterListResult +from ._models_py3 import ClusterMonitoringRequest +from ._models_py3 import ClusterMonitoringResponse +from ._models_py3 import ClusterPatchParameters +from ._models_py3 import ClusterResizeParameters +from ._models_py3 import ComputeIsolationProperties +from ._models_py3 import ComputeProfile +from ._models_py3 import ConnectivityEndpoint +from ._models_py3 import DataDisksGroups +from ._models_py3 import Dimension +from ._models_py3 import DiskBillingMeters +from ._models_py3 import DiskEncryptionProperties +from ._models_py3 import EncryptionInTransitProperties +from ._models_py3 import ErrorResponse +from ._models_py3 import Errors +from ._models_py3 import ExcludedServicesConfig +from ._models_py3 import ExecuteScriptActionParameters +from ._models_py3 import Extension +from ._models_py3 import GatewaySettings +from ._models_py3 import HardwareProfile +from ._models_py3 import HostInfo +from ._models_py3 import IPConfiguration +from ._models_py3 import KafkaRestProperties +from ._models_py3 import LinuxOperatingSystemProfile +from ._models_py3 import LocalizedName +from ._models_py3 import MetricSpecifications +from ._models_py3 import NameAvailabilityCheckRequestParameters +from ._models_py3 import NameAvailabilityCheckResult +from ._models_py3 import NetworkProperties +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationListResult +from ._models_py3 import OperationProperties +from ._models_py3 import OsProfile +from ._models_py3 import PrivateEndpoint +from ._models_py3 import PrivateEndpointConnection +from ._models_py3 import PrivateEndpointConnectionListResult +from ._models_py3 import PrivateLinkConfiguration +from ._models_py3 import PrivateLinkResource +from ._models_py3 import PrivateLinkResourceListResult +from ._models_py3 import PrivateLinkServiceConnectionState +from ._models_py3 import ProxyResource +from ._models_py3 import QuotaCapability +from ._models_py3 import QuotaInfo +from ._models_py3 import RegionalQuotaCapability +from ._models_py3 import RegionsCapability +from ._models_py3 import Resource +from ._models_py3 import ResourceAutoGenerated +from ._models_py3 import ResourceId +from ._models_py3 import Role +from ._models_py3 import RuntimeScriptAction +from ._models_py3 import RuntimeScriptActionDetail +from ._models_py3 import ScriptAction +from ._models_py3 import ScriptActionExecutionHistoryList +from ._models_py3 import ScriptActionExecutionSummary +from ._models_py3 import ScriptActionPersistedGetResponseSpec +from ._models_py3 import ScriptActionsList +from ._models_py3 import SecurityProfile +from ._models_py3 import ServiceSpecification +from ._models_py3 import SshProfile +from ._models_py3 import SshPublicKey +from ._models_py3 import StorageAccount +from ._models_py3 import StorageProfile +from ._models_py3 import SystemData +from ._models_py3 import TrackedResource +from ._models_py3 import UpdateClusterIdentityCertificateParameters +from ._models_py3 import UpdateGatewaySettingsParameters +from ._models_py3 import Usage +from ._models_py3 import UsagesListResult +from ._models_py3 import UserAssignedIdentity +from ._models_py3 import ValidationErrorInfo +from ._models_py3 import VersionSpec +from ._models_py3 import VersionsCapability +from ._models_py3 import VirtualNetworkProfile +from ._models_py3 import VmSizeCompatibilityFilterV2 +from ._models_py3 import VmSizeProperty -from ._hd_insight_management_client_enums import ( - AsyncOperationState, - CreatedByType, - DaysOfWeek, - DirectoryType, - FilterMode, - HDInsightClusterProvisioningState, - JsonWebKeyEncryptionAlgorithm, - OSType, - PrivateEndpointConnectionProvisioningState, - PrivateIPAllocationMethod, - PrivateLink, - PrivateLinkConfigurationProvisioningState, - PrivateLinkServiceConnectionStatus, - ResourceIdentityType, - ResourceProviderConnection, - RoleName, - Tier, -) +from ._hd_insight_management_client_enums import AsyncOperationState +from ._hd_insight_management_client_enums import CreatedByType +from ._hd_insight_management_client_enums import DaysOfWeek +from ._hd_insight_management_client_enums import DirectoryType +from ._hd_insight_management_client_enums import FilterMode +from ._hd_insight_management_client_enums import HDInsightClusterProvisioningState +from ._hd_insight_management_client_enums import JsonWebKeyEncryptionAlgorithm +from ._hd_insight_management_client_enums import OSType +from ._hd_insight_management_client_enums import PrivateEndpointConnectionProvisioningState +from ._hd_insight_management_client_enums import PrivateIPAllocationMethod +from ._hd_insight_management_client_enums import PrivateLink +from ._hd_insight_management_client_enums import PrivateLinkConfigurationProvisioningState +from ._hd_insight_management_client_enums import PrivateLinkServiceConnectionStatus +from ._hd_insight_management_client_enums import ResourceIdentityType +from ._hd_insight_management_client_enums import ResourceProviderConnection +from ._hd_insight_management_client_enums import RoleName +from ._hd_insight_management_client_enums import Tier +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__ = [ - 'AaddsResourceDetails', - 'Application', - 'ApplicationGetEndpoint', - 'ApplicationGetHttpsEndpoint', - 'ApplicationListResult', - 'ApplicationProperties', - 'AsyncOperationResult', - 'Autoscale', - 'AutoscaleCapacity', - 'AutoscaleConfigurationUpdateParameter', - 'AutoscaleRecurrence', - 'AutoscaleSchedule', - 'AutoscaleTimeAndCapacity', - 'AzureMonitorRequest', - 'AzureMonitorResponse', - 'AzureMonitorSelectedConfigurations', - 'AzureMonitorTableConfiguration', - 'BillingMeters', - 'BillingResources', - 'BillingResponseListResult', - 'CapabilitiesResult', - 'ClientGroupInfo', - 'Cluster', - 'ClusterConfigurations', - 'ClusterCreateParametersExtended', - 'ClusterCreateProperties', - 'ClusterCreateRequestValidationParameters', - 'ClusterCreateValidationResult', - 'ClusterDefinition', - 'ClusterDiskEncryptionParameters', - 'ClusterGetProperties', - 'ClusterIdentity', - 'ClusterListPersistedScriptActionsResult', - 'ClusterListResult', - 'ClusterMonitoringRequest', - 'ClusterMonitoringResponse', - 'ClusterPatchParameters', - 'ClusterResizeParameters', - 'ComputeIsolationProperties', - 'ComputeProfile', - 'ConnectivityEndpoint', - 'DataDisksGroups', - 'Dimension', - 'DiskBillingMeters', - 'DiskEncryptionProperties', - 'EncryptionInTransitProperties', - 'ErrorResponse', - 'Errors', - 'ExcludedServicesConfig', - 'ExecuteScriptActionParameters', - 'Extension', - 'GatewaySettings', - 'HardwareProfile', - 'HostInfo', - 'IPConfiguration', - 'KafkaRestProperties', - 'LinuxOperatingSystemProfile', - 'LocalizedName', - 'MetricSpecifications', - 'NameAvailabilityCheckRequestParameters', - 'NameAvailabilityCheckResult', - 'NetworkProperties', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'OperationProperties', - 'OsProfile', - 'PrivateEndpoint', - 'PrivateEndpointConnection', - 'PrivateEndpointConnectionListResult', - 'PrivateLinkConfiguration', - 'PrivateLinkResource', - 'PrivateLinkResourceListResult', - 'PrivateLinkServiceConnectionState', - 'ProxyResource', - 'QuotaCapability', - 'QuotaInfo', - 'RegionalQuotaCapability', - 'RegionsCapability', - 'Resource', - 'ResourceAutoGenerated', - 'ResourceId', - 'Role', - 'RuntimeScriptAction', - 'RuntimeScriptActionDetail', - 'ScriptAction', - 'ScriptActionExecutionHistoryList', - 'ScriptActionExecutionSummary', - 'ScriptActionPersistedGetResponseSpec', - 'ScriptActionsList', - 'SecurityProfile', - 'ServiceSpecification', - 'SshProfile', - 'SshPublicKey', - 'StorageAccount', - 'StorageProfile', - 'SystemData', - 'TrackedResource', - 'UpdateClusterIdentityCertificateParameters', - 'UpdateGatewaySettingsParameters', - 'Usage', - 'UsagesListResult', - 'UserAssignedIdentity', - 'ValidationErrorInfo', - 'VersionSpec', - 'VersionsCapability', - 'VirtualNetworkProfile', - 'VmSizeCompatibilityFilterV2', - 'VmSizeProperty', - 'AsyncOperationState', - 'CreatedByType', - 'DaysOfWeek', - 'DirectoryType', - 'FilterMode', - 'HDInsightClusterProvisioningState', - 'JsonWebKeyEncryptionAlgorithm', - 'OSType', - 'PrivateEndpointConnectionProvisioningState', - 'PrivateIPAllocationMethod', - 'PrivateLink', - 'PrivateLinkConfigurationProvisioningState', - 'PrivateLinkServiceConnectionStatus', - 'ResourceIdentityType', - 'ResourceProviderConnection', - 'RoleName', - 'Tier', + "AaddsResourceDetails", + "Application", + "ApplicationGetEndpoint", + "ApplicationGetHttpsEndpoint", + "ApplicationListResult", + "ApplicationProperties", + "AsyncOperationResult", + "Autoscale", + "AutoscaleCapacity", + "AutoscaleConfigurationUpdateParameter", + "AutoscaleRecurrence", + "AutoscaleSchedule", + "AutoscaleTimeAndCapacity", + "AzureMonitorRequest", + "AzureMonitorResponse", + "AzureMonitorSelectedConfigurations", + "AzureMonitorTableConfiguration", + "BillingMeters", + "BillingResources", + "BillingResponseListResult", + "CapabilitiesResult", + "ClientGroupInfo", + "Cluster", + "ClusterConfigurations", + "ClusterCreateParametersExtended", + "ClusterCreateProperties", + "ClusterCreateRequestValidationParameters", + "ClusterCreateValidationResult", + "ClusterDefinition", + "ClusterDiskEncryptionParameters", + "ClusterGetProperties", + "ClusterIdentity", + "ClusterListPersistedScriptActionsResult", + "ClusterListResult", + "ClusterMonitoringRequest", + "ClusterMonitoringResponse", + "ClusterPatchParameters", + "ClusterResizeParameters", + "ComputeIsolationProperties", + "ComputeProfile", + "ConnectivityEndpoint", + "DataDisksGroups", + "Dimension", + "DiskBillingMeters", + "DiskEncryptionProperties", + "EncryptionInTransitProperties", + "ErrorResponse", + "Errors", + "ExcludedServicesConfig", + "ExecuteScriptActionParameters", + "Extension", + "GatewaySettings", + "HardwareProfile", + "HostInfo", + "IPConfiguration", + "KafkaRestProperties", + "LinuxOperatingSystemProfile", + "LocalizedName", + "MetricSpecifications", + "NameAvailabilityCheckRequestParameters", + "NameAvailabilityCheckResult", + "NetworkProperties", + "Operation", + "OperationDisplay", + "OperationListResult", + "OperationProperties", + "OsProfile", + "PrivateEndpoint", + "PrivateEndpointConnection", + "PrivateEndpointConnectionListResult", + "PrivateLinkConfiguration", + "PrivateLinkResource", + "PrivateLinkResourceListResult", + "PrivateLinkServiceConnectionState", + "ProxyResource", + "QuotaCapability", + "QuotaInfo", + "RegionalQuotaCapability", + "RegionsCapability", + "Resource", + "ResourceAutoGenerated", + "ResourceId", + "Role", + "RuntimeScriptAction", + "RuntimeScriptActionDetail", + "ScriptAction", + "ScriptActionExecutionHistoryList", + "ScriptActionExecutionSummary", + "ScriptActionPersistedGetResponseSpec", + "ScriptActionsList", + "SecurityProfile", + "ServiceSpecification", + "SshProfile", + "SshPublicKey", + "StorageAccount", + "StorageProfile", + "SystemData", + "TrackedResource", + "UpdateClusterIdentityCertificateParameters", + "UpdateGatewaySettingsParameters", + "Usage", + "UsagesListResult", + "UserAssignedIdentity", + "ValidationErrorInfo", + "VersionSpec", + "VersionsCapability", + "VirtualNetworkProfile", + "VmSizeCompatibilityFilterV2", + "VmSizeProperty", + "AsyncOperationState", + "CreatedByType", + "DaysOfWeek", + "DirectoryType", + "FilterMode", + "HDInsightClusterProvisioningState", + "JsonWebKeyEncryptionAlgorithm", + "OSType", + "PrivateEndpointConnectionProvisioningState", + "PrivateIPAllocationMethod", + "PrivateLink", + "PrivateLinkConfigurationProvisioningState", + "PrivateLinkServiceConnectionStatus", + "ResourceIdentityType", + "ResourceProviderConnection", + "RoleName", + "Tier", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/models/_hd_insight_management_client_enums.py b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/models/_hd_insight_management_client_enums.py index ad598a6ab5c9e..15a659d438f2f 100644 --- a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/models/_hd_insight_management_client_enums.py +++ b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/models/_hd_insight_management_client_enums.py @@ -6,44 +6,29 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta -from six import with_metaclass - -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class AsyncOperationState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The async operation state. - """ +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class AsyncOperationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The async operation state.""" IN_PROGRESS = "InProgress" SUCCEEDED = "Succeeded" FAILED = "Failed" -class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The type of identity that created the resource. - """ + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class DaysOfWeek(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + +class DaysOfWeek(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """DaysOfWeek.""" MONDAY = "Monday" TUESDAY = "Tuesday" @@ -53,13 +38,14 @@ class DaysOfWeek(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SATURDAY = "Saturday" SUNDAY = "Sunday" -class DirectoryType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The directory type. - """ + +class DirectoryType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The directory type.""" ACTIVE_DIRECTORY = "ActiveDirectory" -class FilterMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + +class FilterMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The filtering mode. Effectively this can enabling or disabling the VM sizes in a particular set. """ @@ -69,9 +55,9 @@ class FilterMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): RECOMMEND = "Recommend" DEFAULT = "Default" -class HDInsightClusterProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The provisioning state, which only appears in the response. - """ + +class HDInsightClusterProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state, which only appears in the response.""" IN_PROGRESS = "InProgress" FAILED = "Failed" @@ -79,24 +65,24 @@ class HDInsightClusterProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, CANCELED = "Canceled" DELETING = "Deleting" -class JsonWebKeyEncryptionAlgorithm(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Algorithm identifier for encryption, default RSA-OAEP. - """ + +class JsonWebKeyEncryptionAlgorithm(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Algorithm identifier for encryption, default RSA-OAEP.""" RSA_OAEP = "RSA-OAEP" RSA_OAEP256 = "RSA-OAEP-256" RSA1_5 = "RSA1_5" -class OSType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The type of operating system. - """ + +class OSType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of operating system.""" WINDOWS = "Windows" LINUX = "Linux" -class PrivateEndpointConnectionProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The provisioning state, which only appears in the response. - """ + +class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provisioning state, which only appears in the response.""" IN_PROGRESS = "InProgress" UPDATING = "Updating" @@ -105,23 +91,23 @@ class PrivateEndpointConnectionProvisioningState(with_metaclass(_CaseInsensitive CANCELED = "Canceled" DELETING = "Deleting" -class PrivateIPAllocationMethod(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The method that private IP address is allocated. - """ + +class PrivateIPAllocationMethod(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The method that private IP address is allocated.""" DYNAMIC = "dynamic" STATIC = "static" -class PrivateLink(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Indicates whether or not private link is enabled. - """ + +class PrivateLink(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates whether or not private link is enabled.""" DISABLED = "Disabled" ENABLED = "Enabled" -class PrivateLinkConfigurationProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The private link configuration provisioning state, which only appears in the response. - """ + +class PrivateLinkConfigurationProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The private link configuration provisioning state, which only appears in the response.""" IN_PROGRESS = "InProgress" FAILED = "Failed" @@ -129,16 +115,17 @@ class PrivateLinkConfigurationProvisioningState(with_metaclass(_CaseInsensitiveE CANCELED = "Canceled" DELETING = "Deleting" -class PrivateLinkServiceConnectionStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The concrete private link service connection. - """ + +class PrivateLinkServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The concrete private link service connection.""" APPROVED = "Approved" REJECTED = "Rejected" PENDING = "Pending" REMOVED = "Removed" -class ResourceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + +class ResourceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity used for the cluster. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. """ @@ -148,20 +135,22 @@ class ResourceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class ResourceProviderConnection(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The direction for the resource provider connection. - """ + +class ResourceProviderConnection(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The direction for the resource provider connection.""" INBOUND = "Inbound" OUTBOUND = "Outbound" -class RoleName(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + +class RoleName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """RoleName.""" WORKERNODE = "workernode" -class Tier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The cluster tier. - """ + +class Tier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The cluster tier.""" STANDARD = "Standard" PREMIUM = "Premium" diff --git a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/models/_models.py b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/models/_models.py deleted file mode 100644 index 51e412c8eed2a..0000000000000 --- a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/models/_models.py +++ /dev/null @@ -1,3665 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class AaddsResourceDetails(msrest.serialization.Model): - """The Azure active directory domain service resource details. - - :param domain_name: The Azure active directory domain service name. - :type domain_name: str - :param initial_sync_complete: This indicates whether initial sync complete or not. - :type initial_sync_complete: bool - :param ldaps_enabled: This indicates whether enable ldaps or not. - :type ldaps_enabled: bool - :param ldaps_public_certificate_in_base64: The base 64 format string of public ldap - certificate. - :type ldaps_public_certificate_in_base64: str - :param resource_id: The resource id of azure active directory domain service. - :type resource_id: str - :param subnet_id: The subnet resource id. - :type subnet_id: str - :param tenant_id: The tenant id of azure active directory domain service . - :type tenant_id: str - """ - - _attribute_map = { - 'domain_name': {'key': 'domainName', 'type': 'str'}, - 'initial_sync_complete': {'key': 'initialSyncComplete', 'type': 'bool'}, - 'ldaps_enabled': {'key': 'ldapsEnabled', 'type': 'bool'}, - 'ldaps_public_certificate_in_base64': {'key': 'ldapsPublicCertificateInBase64', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'subnet_id': {'key': 'subnetId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AaddsResourceDetails, self).__init__(**kwargs) - self.domain_name = kwargs.get('domain_name', None) - self.initial_sync_complete = kwargs.get('initial_sync_complete', None) - self.ldaps_enabled = kwargs.get('ldaps_enabled', None) - self.ldaps_public_certificate_in_base64 = kwargs.get('ldaps_public_certificate_in_base64', None) - self.resource_id = kwargs.get('resource_id', None) - self.subnet_id = kwargs.get('subnet_id', None) - self.tenant_id = kwargs.get('tenant_id', None) - - -class ResourceAutoGenerated(msrest.serialization.Model): - """Common fields that are returned in the response for all Azure Resource Manager resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceAutoGenerated, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class ProxyResource(ResourceAutoGenerated): - """The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ProxyResource, self).__init__(**kwargs) - - -class Application(ProxyResource): - """The HDInsight cluster application. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param etag: The ETag for the application. - :type etag: str - :param tags: A set of tags. The tags for the application. - :type tags: dict[str, str] - :param properties: The properties of the application. - :type properties: ~azure.mgmt.hdinsight.models.ApplicationProperties - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.hdinsight.models.SystemData - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'properties': {'key': 'properties', 'type': 'ApplicationProperties'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - } - - def __init__( - self, - **kwargs - ): - super(Application, self).__init__(**kwargs) - self.etag = kwargs.get('etag', None) - self.tags = kwargs.get('tags', None) - self.properties = kwargs.get('properties', None) - self.system_data = None - - -class ApplicationGetEndpoint(msrest.serialization.Model): - """Gets the application SSH endpoint. - - :param location: The location of the endpoint. - :type location: str - :param destination_port: The destination port to connect to. - :type destination_port: int - :param public_port: The public port to connect to. - :type public_port: int - :param private_ip_address: The private ip address of the endpoint. - :type private_ip_address: str - """ - - _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'destination_port': {'key': 'destinationPort', 'type': 'int'}, - 'public_port': {'key': 'publicPort', 'type': 'int'}, - 'private_ip_address': {'key': 'privateIPAddress', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApplicationGetEndpoint, self).__init__(**kwargs) - self.location = kwargs.get('location', None) - self.destination_port = kwargs.get('destination_port', None) - self.public_port = kwargs.get('public_port', None) - self.private_ip_address = kwargs.get('private_ip_address', None) - - -class ApplicationGetHttpsEndpoint(msrest.serialization.Model): - """Gets the application HTTP endpoints. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param access_modes: The list of access modes for the application. - :type access_modes: list[str] - :ivar location: The location of the endpoint. - :vartype location: str - :param destination_port: The destination port to connect to. - :type destination_port: int - :ivar public_port: The public port to connect to. - :vartype public_port: int - :param private_ip_address: The private ip address of the endpoint. - :type private_ip_address: str - :param sub_domain_suffix: The subdomain suffix of the application. - :type sub_domain_suffix: str - :param disable_gateway_auth: The value indicates whether to disable GatewayAuth. - :type disable_gateway_auth: bool - """ - - _validation = { - 'location': {'readonly': True}, - 'public_port': {'readonly': True}, - } - - _attribute_map = { - 'access_modes': {'key': 'accessModes', 'type': '[str]'}, - 'location': {'key': 'location', 'type': 'str'}, - 'destination_port': {'key': 'destinationPort', 'type': 'int'}, - 'public_port': {'key': 'publicPort', 'type': 'int'}, - 'private_ip_address': {'key': 'privateIPAddress', 'type': 'str'}, - 'sub_domain_suffix': {'key': 'subDomainSuffix', 'type': 'str'}, - 'disable_gateway_auth': {'key': 'disableGatewayAuth', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(ApplicationGetHttpsEndpoint, self).__init__(**kwargs) - self.access_modes = kwargs.get('access_modes', None) - self.location = None - self.destination_port = kwargs.get('destination_port', None) - self.public_port = None - self.private_ip_address = kwargs.get('private_ip_address', None) - self.sub_domain_suffix = kwargs.get('sub_domain_suffix', None) - self.disable_gateway_auth = kwargs.get('disable_gateway_auth', None) - - -class ApplicationListResult(msrest.serialization.Model): - """Result of the request to list cluster Applications. It contains a list of operations and a URL link to get the next set of results. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: The list of HDInsight applications installed on HDInsight cluster. - :type value: list[~azure.mgmt.hdinsight.models.Application] - :ivar next_link: The URL to get the next set of operation list results if there are any. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Application]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ApplicationListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class ApplicationProperties(msrest.serialization.Model): - """The HDInsight cluster application GET response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param compute_profile: The list of roles in the cluster. - :type compute_profile: ~azure.mgmt.hdinsight.models.ComputeProfile - :param install_script_actions: The list of install script actions. - :type install_script_actions: list[~azure.mgmt.hdinsight.models.RuntimeScriptAction] - :param uninstall_script_actions: The list of uninstall script actions. - :type uninstall_script_actions: list[~azure.mgmt.hdinsight.models.RuntimeScriptAction] - :param https_endpoints: The list of application HTTPS endpoints. - :type https_endpoints: list[~azure.mgmt.hdinsight.models.ApplicationGetHttpsEndpoint] - :param ssh_endpoints: The list of application SSH endpoints. - :type ssh_endpoints: list[~azure.mgmt.hdinsight.models.ApplicationGetEndpoint] - :ivar provisioning_state: The provisioning state of the application. - :vartype provisioning_state: str - :param application_type: The application type. - :type application_type: str - :ivar application_state: The application state. - :vartype application_state: str - :param errors: The list of errors. - :type errors: list[~azure.mgmt.hdinsight.models.Errors] - :ivar created_date: The application create date time. - :vartype created_date: str - :ivar marketplace_identifier: The marketplace identifier. - :vartype marketplace_identifier: str - :param private_link_configurations: The private link configurations. - :type private_link_configurations: list[~azure.mgmt.hdinsight.models.PrivateLinkConfiguration] - """ - - _validation = { - 'provisioning_state': {'readonly': True}, - 'application_state': {'readonly': True}, - 'created_date': {'readonly': True}, - 'marketplace_identifier': {'readonly': True}, - } - - _attribute_map = { - 'compute_profile': {'key': 'computeProfile', 'type': 'ComputeProfile'}, - 'install_script_actions': {'key': 'installScriptActions', 'type': '[RuntimeScriptAction]'}, - 'uninstall_script_actions': {'key': 'uninstallScriptActions', 'type': '[RuntimeScriptAction]'}, - 'https_endpoints': {'key': 'httpsEndpoints', 'type': '[ApplicationGetHttpsEndpoint]'}, - 'ssh_endpoints': {'key': 'sshEndpoints', 'type': '[ApplicationGetEndpoint]'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'application_type': {'key': 'applicationType', 'type': 'str'}, - 'application_state': {'key': 'applicationState', 'type': 'str'}, - 'errors': {'key': 'errors', 'type': '[Errors]'}, - 'created_date': {'key': 'createdDate', 'type': 'str'}, - 'marketplace_identifier': {'key': 'marketplaceIdentifier', 'type': 'str'}, - 'private_link_configurations': {'key': 'privateLinkConfigurations', 'type': '[PrivateLinkConfiguration]'}, - } - - def __init__( - self, - **kwargs - ): - super(ApplicationProperties, self).__init__(**kwargs) - self.compute_profile = kwargs.get('compute_profile', None) - self.install_script_actions = kwargs.get('install_script_actions', None) - self.uninstall_script_actions = kwargs.get('uninstall_script_actions', None) - self.https_endpoints = kwargs.get('https_endpoints', None) - self.ssh_endpoints = kwargs.get('ssh_endpoints', None) - self.provisioning_state = None - self.application_type = kwargs.get('application_type', None) - self.application_state = None - self.errors = kwargs.get('errors', None) - self.created_date = None - self.marketplace_identifier = None - self.private_link_configurations = kwargs.get('private_link_configurations', None) - - -class AsyncOperationResult(msrest.serialization.Model): - """The azure async operation response. - - :param status: The async operation state. Possible values include: "InProgress", "Succeeded", - "Failed". - :type status: str or ~azure.mgmt.hdinsight.models.AsyncOperationState - :param error: The operation error information. - :type error: ~azure.mgmt.hdinsight.models.Errors - """ - - _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'error': {'key': 'error', 'type': 'Errors'}, - } - - def __init__( - self, - **kwargs - ): - super(AsyncOperationResult, self).__init__(**kwargs) - self.status = kwargs.get('status', None) - self.error = kwargs.get('error', None) - - -class Autoscale(msrest.serialization.Model): - """The autoscale request parameters. - - :param capacity: Parameters for load-based autoscale. - :type capacity: ~azure.mgmt.hdinsight.models.AutoscaleCapacity - :param recurrence: Parameters for schedule-based autoscale. - :type recurrence: ~azure.mgmt.hdinsight.models.AutoscaleRecurrence - """ - - _attribute_map = { - 'capacity': {'key': 'capacity', 'type': 'AutoscaleCapacity'}, - 'recurrence': {'key': 'recurrence', 'type': 'AutoscaleRecurrence'}, - } - - def __init__( - self, - **kwargs - ): - super(Autoscale, self).__init__(**kwargs) - self.capacity = kwargs.get('capacity', None) - self.recurrence = kwargs.get('recurrence', None) - - -class AutoscaleCapacity(msrest.serialization.Model): - """The load-based autoscale request parameters. - - :param min_instance_count: The minimum instance count of the cluster. - :type min_instance_count: int - :param max_instance_count: The maximum instance count of the cluster. - :type max_instance_count: int - """ - - _attribute_map = { - 'min_instance_count': {'key': 'minInstanceCount', 'type': 'int'}, - 'max_instance_count': {'key': 'maxInstanceCount', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(AutoscaleCapacity, self).__init__(**kwargs) - self.min_instance_count = kwargs.get('min_instance_count', None) - self.max_instance_count = kwargs.get('max_instance_count', None) - - -class AutoscaleConfigurationUpdateParameter(msrest.serialization.Model): - """The autoscale configuration update parameter. - - :param autoscale: The autoscale configuration. - :type autoscale: ~azure.mgmt.hdinsight.models.Autoscale - """ - - _attribute_map = { - 'autoscale': {'key': 'autoscale', 'type': 'Autoscale'}, - } - - def __init__( - self, - **kwargs - ): - super(AutoscaleConfigurationUpdateParameter, self).__init__(**kwargs) - self.autoscale = kwargs.get('autoscale', None) - - -class AutoscaleRecurrence(msrest.serialization.Model): - """Schedule-based autoscale request parameters. - - :param time_zone: The time zone for the autoscale schedule times. - :type time_zone: str - :param schedule: Array of schedule-based autoscale rules. - :type schedule: list[~azure.mgmt.hdinsight.models.AutoscaleSchedule] - """ - - _attribute_map = { - 'time_zone': {'key': 'timeZone', 'type': 'str'}, - 'schedule': {'key': 'schedule', 'type': '[AutoscaleSchedule]'}, - } - - def __init__( - self, - **kwargs - ): - super(AutoscaleRecurrence, self).__init__(**kwargs) - self.time_zone = kwargs.get('time_zone', None) - self.schedule = kwargs.get('schedule', None) - - -class AutoscaleSchedule(msrest.serialization.Model): - """Parameters for a schedule-based autoscale rule, consisting of an array of days + a time and capacity. - - :param days: Days of the week for a schedule-based autoscale rule. - :type days: list[str or ~azure.mgmt.hdinsight.models.DaysOfWeek] - :param time_and_capacity: Time and capacity for a schedule-based autoscale rule. - :type time_and_capacity: ~azure.mgmt.hdinsight.models.AutoscaleTimeAndCapacity - """ - - _attribute_map = { - 'days': {'key': 'days', 'type': '[str]'}, - 'time_and_capacity': {'key': 'timeAndCapacity', 'type': 'AutoscaleTimeAndCapacity'}, - } - - def __init__( - self, - **kwargs - ): - super(AutoscaleSchedule, self).__init__(**kwargs) - self.days = kwargs.get('days', None) - self.time_and_capacity = kwargs.get('time_and_capacity', None) - - -class AutoscaleTimeAndCapacity(msrest.serialization.Model): - """Time and capacity request parameters. - - :param time: 24-hour time in the form xx:xx. - :type time: str - :param min_instance_count: The minimum instance count of the cluster. - :type min_instance_count: int - :param max_instance_count: The maximum instance count of the cluster. - :type max_instance_count: int - """ - - _attribute_map = { - 'time': {'key': 'time', 'type': 'str'}, - 'min_instance_count': {'key': 'minInstanceCount', 'type': 'int'}, - 'max_instance_count': {'key': 'maxInstanceCount', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(AutoscaleTimeAndCapacity, self).__init__(**kwargs) - self.time = kwargs.get('time', None) - self.min_instance_count = kwargs.get('min_instance_count', None) - self.max_instance_count = kwargs.get('max_instance_count', None) - - -class AzureMonitorRequest(msrest.serialization.Model): - """The azure monitor parameters. - - :param workspace_id: The Log Analytics workspace ID. - :type workspace_id: str - :param primary_key: The Log Analytics workspace key. - :type primary_key: str - :param selected_configurations: The selected configurations. - :type selected_configurations: ~azure.mgmt.hdinsight.models.AzureMonitorSelectedConfigurations - """ - - _attribute_map = { - 'workspace_id': {'key': 'workspaceId', 'type': 'str'}, - 'primary_key': {'key': 'primaryKey', 'type': 'str'}, - 'selected_configurations': {'key': 'selectedConfigurations', 'type': 'AzureMonitorSelectedConfigurations'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureMonitorRequest, self).__init__(**kwargs) - self.workspace_id = kwargs.get('workspace_id', None) - self.primary_key = kwargs.get('primary_key', None) - self.selected_configurations = kwargs.get('selected_configurations', None) - - -class AzureMonitorResponse(msrest.serialization.Model): - """The azure monitor status response. - - :param cluster_monitoring_enabled: The status of the monitor on the HDInsight cluster. - :type cluster_monitoring_enabled: bool - :param workspace_id: The workspace ID of the monitor on the HDInsight cluster. - :type workspace_id: str - :param selected_configurations: The selected configurations. - :type selected_configurations: ~azure.mgmt.hdinsight.models.AzureMonitorSelectedConfigurations - """ - - _attribute_map = { - 'cluster_monitoring_enabled': {'key': 'clusterMonitoringEnabled', 'type': 'bool'}, - 'workspace_id': {'key': 'workspaceId', 'type': 'str'}, - 'selected_configurations': {'key': 'selectedConfigurations', 'type': 'AzureMonitorSelectedConfigurations'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureMonitorResponse, self).__init__(**kwargs) - self.cluster_monitoring_enabled = kwargs.get('cluster_monitoring_enabled', None) - self.workspace_id = kwargs.get('workspace_id', None) - self.selected_configurations = kwargs.get('selected_configurations', None) - - -class AzureMonitorSelectedConfigurations(msrest.serialization.Model): - """The selected configurations for azure monitor. - - :param configuration_version: The configuration version. - :type configuration_version: str - :param global_configurations: The global configurations of selected configurations. - :type global_configurations: dict[str, str] - :param table_list: The table list. - :type table_list: list[~azure.mgmt.hdinsight.models.AzureMonitorTableConfiguration] - """ - - _attribute_map = { - 'configuration_version': {'key': 'configurationVersion', 'type': 'str'}, - 'global_configurations': {'key': 'globalConfigurations', 'type': '{str}'}, - 'table_list': {'key': 'tableList', 'type': '[AzureMonitorTableConfiguration]'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureMonitorSelectedConfigurations, self).__init__(**kwargs) - self.configuration_version = kwargs.get('configuration_version', None) - self.global_configurations = kwargs.get('global_configurations', None) - self.table_list = kwargs.get('table_list', None) - - -class AzureMonitorTableConfiguration(msrest.serialization.Model): - """The table configuration for the Log Analytics integration. - - :param name: The name. - :type name: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureMonitorTableConfiguration, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - - -class BillingMeters(msrest.serialization.Model): - """The billing meters. - - :param meter_parameter: The virtual machine sizes. - :type meter_parameter: str - :param meter: The HDInsight meter guid. - :type meter: str - :param unit: The unit of meter, VMHours or CoreHours. - :type unit: str - """ - - _attribute_map = { - 'meter_parameter': {'key': 'meterParameter', 'type': 'str'}, - 'meter': {'key': 'meter', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(BillingMeters, self).__init__(**kwargs) - self.meter_parameter = kwargs.get('meter_parameter', None) - self.meter = kwargs.get('meter', None) - self.unit = kwargs.get('unit', None) - - -class BillingResources(msrest.serialization.Model): - """The billing resources. - - :param region: The region or location. - :type region: str - :param billing_meters: The billing meter information. - :type billing_meters: list[~azure.mgmt.hdinsight.models.BillingMeters] - :param disk_billing_meters: The managed disk billing information. - :type disk_billing_meters: list[~azure.mgmt.hdinsight.models.DiskBillingMeters] - """ - - _attribute_map = { - 'region': {'key': 'region', 'type': 'str'}, - 'billing_meters': {'key': 'billingMeters', 'type': '[BillingMeters]'}, - 'disk_billing_meters': {'key': 'diskBillingMeters', 'type': '[DiskBillingMeters]'}, - } - - def __init__( - self, - **kwargs - ): - super(BillingResources, self).__init__(**kwargs) - self.region = kwargs.get('region', None) - self.billing_meters = kwargs.get('billing_meters', None) - self.disk_billing_meters = kwargs.get('disk_billing_meters', None) - - -class BillingResponseListResult(msrest.serialization.Model): - """The response for the operation to get regional billingSpecs for a subscription. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param vm_sizes: The virtual machine sizes to include or exclude. - :type vm_sizes: list[str] - :param vm_sizes_with_encryption_at_host: The vm sizes which enable encryption at host. - :type vm_sizes_with_encryption_at_host: list[str] - :param vm_size_filters: The virtual machine filtering mode. Effectively this can enabling or - disabling the virtual machine sizes in a particular set. - :type vm_size_filters: list[~azure.mgmt.hdinsight.models.VmSizeCompatibilityFilterV2] - :ivar vm_size_properties: The vm size properties. - :vartype vm_size_properties: list[~azure.mgmt.hdinsight.models.VmSizeProperty] - :param billing_resources: The billing and managed disk billing resources for a region. - :type billing_resources: list[~azure.mgmt.hdinsight.models.BillingResources] - """ - - _validation = { - 'vm_size_properties': {'readonly': True}, - } - - _attribute_map = { - 'vm_sizes': {'key': 'vmSizes', 'type': '[str]'}, - 'vm_sizes_with_encryption_at_host': {'key': 'vmSizesWithEncryptionAtHost', 'type': '[str]'}, - 'vm_size_filters': {'key': 'vmSizeFilters', 'type': '[VmSizeCompatibilityFilterV2]'}, - 'vm_size_properties': {'key': 'vmSizeProperties', 'type': '[VmSizeProperty]'}, - 'billing_resources': {'key': 'billingResources', 'type': '[BillingResources]'}, - } - - def __init__( - self, - **kwargs - ): - super(BillingResponseListResult, self).__init__(**kwargs) - self.vm_sizes = kwargs.get('vm_sizes', None) - self.vm_sizes_with_encryption_at_host = kwargs.get('vm_sizes_with_encryption_at_host', None) - self.vm_size_filters = kwargs.get('vm_size_filters', None) - self.vm_size_properties = None - self.billing_resources = kwargs.get('billing_resources', None) - - -class CapabilitiesResult(msrest.serialization.Model): - """The Get Capabilities operation response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param versions: The version capability. - :type versions: dict[str, ~azure.mgmt.hdinsight.models.VersionsCapability] - :param regions: The virtual machine size compatibility features. - :type regions: dict[str, ~azure.mgmt.hdinsight.models.RegionsCapability] - :param features: The capability features. - :type features: list[str] - :ivar quota: The quota capability. - :vartype quota: ~azure.mgmt.hdinsight.models.QuotaCapability - """ - - _validation = { - 'quota': {'readonly': True}, - } - - _attribute_map = { - 'versions': {'key': 'versions', 'type': '{VersionsCapability}'}, - 'regions': {'key': 'regions', 'type': '{RegionsCapability}'}, - 'features': {'key': 'features', 'type': '[str]'}, - 'quota': {'key': 'quota', 'type': 'QuotaCapability'}, - } - - def __init__( - self, - **kwargs - ): - super(CapabilitiesResult, self).__init__(**kwargs) - self.versions = kwargs.get('versions', None) - self.regions = kwargs.get('regions', None) - self.features = kwargs.get('features', None) - self.quota = None - - -class ClientGroupInfo(msrest.serialization.Model): - """The information of AAD security group. - - :param group_name: The AAD security group name. - :type group_name: str - :param group_id: The AAD security group id. - :type group_id: str - """ - - _attribute_map = { - 'group_name': {'key': 'groupName', 'type': 'str'}, - 'group_id': {'key': 'groupId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ClientGroupInfo, self).__init__(**kwargs) - self.group_name = kwargs.get('group_name', None) - self.group_id = kwargs.get('group_id', None) - - -class Resource(msrest.serialization.Model): - """Common fields that are returned in the response for all Azure Resource Manager resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class TrackedResource(Resource): - """The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TrackedResource, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.location = kwargs['location'] - - -class Cluster(TrackedResource): - """The HDInsight cluster. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - :param etag: The ETag for the resource. - :type etag: str - :param zones: The availability zones. - :type zones: list[str] - :param properties: The properties of the cluster. - :type properties: ~azure.mgmt.hdinsight.models.ClusterGetProperties - :param identity: The identity of the cluster, if configured. - :type identity: ~azure.mgmt.hdinsight.models.ClusterIdentity - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.hdinsight.models.SystemData - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'zones': {'key': 'zones', 'type': '[str]'}, - 'properties': {'key': 'properties', 'type': 'ClusterGetProperties'}, - 'identity': {'key': 'identity', 'type': 'ClusterIdentity'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - } - - def __init__( - self, - **kwargs - ): - super(Cluster, self).__init__(**kwargs) - self.etag = kwargs.get('etag', None) - self.zones = kwargs.get('zones', None) - self.properties = kwargs.get('properties', None) - self.identity = kwargs.get('identity', None) - self.system_data = None - - -class ClusterConfigurations(msrest.serialization.Model): - """The configuration object for the specified cluster. - - :param configurations: The configuration object for the specified configuration for the - specified cluster. - :type configurations: dict[str, dict[str, str]] - """ - - _attribute_map = { - 'configurations': {'key': 'configurations', 'type': '{{str}}'}, - } - - def __init__( - self, - **kwargs - ): - super(ClusterConfigurations, self).__init__(**kwargs) - self.configurations = kwargs.get('configurations', None) - - -class ClusterCreateParametersExtended(msrest.serialization.Model): - """The CreateCluster request parameters. - - :param location: The location of the cluster. - :type location: str - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] - :param zones: The availability zones. - :type zones: list[str] - :param properties: The cluster create parameters. - :type properties: ~azure.mgmt.hdinsight.models.ClusterCreateProperties - :param identity: The identity of the cluster, if configured. - :type identity: ~azure.mgmt.hdinsight.models.ClusterIdentity - """ - - _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'zones': {'key': 'zones', 'type': '[str]'}, - 'properties': {'key': 'properties', 'type': 'ClusterCreateProperties'}, - 'identity': {'key': 'identity', 'type': 'ClusterIdentity'}, - } - - def __init__( - self, - **kwargs - ): - super(ClusterCreateParametersExtended, self).__init__(**kwargs) - self.location = kwargs.get('location', None) - self.tags = kwargs.get('tags', None) - self.zones = kwargs.get('zones', None) - self.properties = kwargs.get('properties', None) - self.identity = kwargs.get('identity', None) - - -class ClusterCreateProperties(msrest.serialization.Model): - """The cluster create parameters. - - :param cluster_version: The version of the cluster. - :type cluster_version: str - :param os_type: The type of operating system. Possible values include: "Windows", "Linux". - :type os_type: str or ~azure.mgmt.hdinsight.models.OSType - :param tier: The cluster tier. Possible values include: "Standard", "Premium". - :type tier: str or ~azure.mgmt.hdinsight.models.Tier - :param cluster_definition: The cluster definition. - :type cluster_definition: ~azure.mgmt.hdinsight.models.ClusterDefinition - :param kafka_rest_properties: The cluster kafka rest proxy configuration. - :type kafka_rest_properties: ~azure.mgmt.hdinsight.models.KafkaRestProperties - :param security_profile: The security profile. - :type security_profile: ~azure.mgmt.hdinsight.models.SecurityProfile - :param compute_profile: The compute profile. - :type compute_profile: ~azure.mgmt.hdinsight.models.ComputeProfile - :param storage_profile: The storage profile. - :type storage_profile: ~azure.mgmt.hdinsight.models.StorageProfile - :param disk_encryption_properties: The disk encryption properties. - :type disk_encryption_properties: ~azure.mgmt.hdinsight.models.DiskEncryptionProperties - :param encryption_in_transit_properties: The encryption-in-transit properties. - :type encryption_in_transit_properties: - ~azure.mgmt.hdinsight.models.EncryptionInTransitProperties - :param min_supported_tls_version: The minimal supported tls version. - :type min_supported_tls_version: str - :param network_properties: The network properties. - :type network_properties: ~azure.mgmt.hdinsight.models.NetworkProperties - :param compute_isolation_properties: The compute isolation properties. - :type compute_isolation_properties: ~azure.mgmt.hdinsight.models.ComputeIsolationProperties - :param private_link_configurations: The private link configurations. - :type private_link_configurations: list[~azure.mgmt.hdinsight.models.PrivateLinkConfiguration] - """ - - _attribute_map = { - 'cluster_version': {'key': 'clusterVersion', 'type': 'str'}, - 'os_type': {'key': 'osType', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'cluster_definition': {'key': 'clusterDefinition', 'type': 'ClusterDefinition'}, - 'kafka_rest_properties': {'key': 'kafkaRestProperties', 'type': 'KafkaRestProperties'}, - 'security_profile': {'key': 'securityProfile', 'type': 'SecurityProfile'}, - 'compute_profile': {'key': 'computeProfile', 'type': 'ComputeProfile'}, - 'storage_profile': {'key': 'storageProfile', 'type': 'StorageProfile'}, - 'disk_encryption_properties': {'key': 'diskEncryptionProperties', 'type': 'DiskEncryptionProperties'}, - 'encryption_in_transit_properties': {'key': 'encryptionInTransitProperties', 'type': 'EncryptionInTransitProperties'}, - 'min_supported_tls_version': {'key': 'minSupportedTlsVersion', 'type': 'str'}, - 'network_properties': {'key': 'networkProperties', 'type': 'NetworkProperties'}, - 'compute_isolation_properties': {'key': 'computeIsolationProperties', 'type': 'ComputeIsolationProperties'}, - 'private_link_configurations': {'key': 'privateLinkConfigurations', 'type': '[PrivateLinkConfiguration]'}, - } - - def __init__( - self, - **kwargs - ): - super(ClusterCreateProperties, self).__init__(**kwargs) - self.cluster_version = kwargs.get('cluster_version', None) - self.os_type = kwargs.get('os_type', None) - self.tier = kwargs.get('tier', None) - self.cluster_definition = kwargs.get('cluster_definition', None) - self.kafka_rest_properties = kwargs.get('kafka_rest_properties', None) - self.security_profile = kwargs.get('security_profile', None) - self.compute_profile = kwargs.get('compute_profile', None) - self.storage_profile = kwargs.get('storage_profile', None) - self.disk_encryption_properties = kwargs.get('disk_encryption_properties', None) - self.encryption_in_transit_properties = kwargs.get('encryption_in_transit_properties', None) - self.min_supported_tls_version = kwargs.get('min_supported_tls_version', None) - self.network_properties = kwargs.get('network_properties', None) - self.compute_isolation_properties = kwargs.get('compute_isolation_properties', None) - self.private_link_configurations = kwargs.get('private_link_configurations', None) - - -class ClusterCreateRequestValidationParameters(ClusterCreateParametersExtended): - """The cluster create request specification. - - :param location: The location of the cluster. - :type location: str - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] - :param zones: The availability zones. - :type zones: list[str] - :param properties: The cluster create parameters. - :type properties: ~azure.mgmt.hdinsight.models.ClusterCreateProperties - :param identity: The identity of the cluster, if configured. - :type identity: ~azure.mgmt.hdinsight.models.ClusterIdentity - :param name: The cluster name. - :type name: str - :param type: The resource type. - :type type: str - :param tenant_id: The tenant id. - :type tenant_id: str - :param fetch_aadds_resource: This indicates whether fetch Aadds resource or not. - :type fetch_aadds_resource: bool - """ - - _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'zones': {'key': 'zones', 'type': '[str]'}, - 'properties': {'key': 'properties', 'type': 'ClusterCreateProperties'}, - 'identity': {'key': 'identity', 'type': 'ClusterIdentity'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'fetch_aadds_resource': {'key': 'fetchAaddsResource', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(ClusterCreateRequestValidationParameters, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.type = kwargs.get('type', None) - self.tenant_id = kwargs.get('tenant_id', None) - self.fetch_aadds_resource = kwargs.get('fetch_aadds_resource', None) - - -class ClusterCreateValidationResult(msrest.serialization.Model): - """The response of cluster create request validation. - - :param validation_errors: The validation errors. - :type validation_errors: list[~azure.mgmt.hdinsight.models.ValidationErrorInfo] - :param validation_warnings: The validation warnings. - :type validation_warnings: list[~azure.mgmt.hdinsight.models.ValidationErrorInfo] - :param estimated_creation_duration: The estimated creation duration. - :type estimated_creation_duration: ~datetime.timedelta - :param aadds_resources_details: The Azure active directory domain service resource details. - :type aadds_resources_details: list[~azure.mgmt.hdinsight.models.AaddsResourceDetails] - """ - - _attribute_map = { - 'validation_errors': {'key': 'validationErrors', 'type': '[ValidationErrorInfo]'}, - 'validation_warnings': {'key': 'validationWarnings', 'type': '[ValidationErrorInfo]'}, - 'estimated_creation_duration': {'key': 'estimatedCreationDuration', 'type': 'duration'}, - 'aadds_resources_details': {'key': 'aaddsResourcesDetails', 'type': '[AaddsResourceDetails]'}, - } - - def __init__( - self, - **kwargs - ): - super(ClusterCreateValidationResult, self).__init__(**kwargs) - self.validation_errors = kwargs.get('validation_errors', None) - self.validation_warnings = kwargs.get('validation_warnings', None) - self.estimated_creation_duration = kwargs.get('estimated_creation_duration', None) - self.aadds_resources_details = kwargs.get('aadds_resources_details', None) - - -class ClusterDefinition(msrest.serialization.Model): - """The cluster definition. - - :param blueprint: The link to the blueprint. - :type blueprint: str - :param kind: The type of cluster. - :type kind: str - :param component_version: The versions of different services in the cluster. - :type component_version: dict[str, str] - :param configurations: The cluster configurations. - :type configurations: any - """ - - _attribute_map = { - 'blueprint': {'key': 'blueprint', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'component_version': {'key': 'componentVersion', 'type': '{str}'}, - 'configurations': {'key': 'configurations', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(ClusterDefinition, self).__init__(**kwargs) - self.blueprint = kwargs.get('blueprint', None) - self.kind = kwargs.get('kind', None) - self.component_version = kwargs.get('component_version', None) - self.configurations = kwargs.get('configurations', None) - - -class ClusterDiskEncryptionParameters(msrest.serialization.Model): - """The Disk Encryption Cluster request parameters. - - :param vault_uri: Base key vault URI where the customers key is located eg. - https://myvault.vault.azure.net. - :type vault_uri: str - :param key_name: Key name that is used for enabling disk encryption. - :type key_name: str - :param key_version: Specific key version that is used for enabling disk encryption. - :type key_version: str - """ - - _attribute_map = { - 'vault_uri': {'key': 'vaultUri', 'type': 'str'}, - 'key_name': {'key': 'keyName', 'type': 'str'}, - 'key_version': {'key': 'keyVersion', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ClusterDiskEncryptionParameters, self).__init__(**kwargs) - self.vault_uri = kwargs.get('vault_uri', None) - self.key_name = kwargs.get('key_name', None) - self.key_version = kwargs.get('key_version', None) - - -class ClusterGetProperties(msrest.serialization.Model): - """The properties of cluster. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param cluster_version: The version of the cluster. - :type cluster_version: str - :param cluster_hdp_version: The hdp version of the cluster. - :type cluster_hdp_version: str - :param os_type: The type of operating system. Possible values include: "Windows", "Linux". - :type os_type: str or ~azure.mgmt.hdinsight.models.OSType - :param tier: The cluster tier. Possible values include: "Standard", "Premium". - :type tier: str or ~azure.mgmt.hdinsight.models.Tier - :param cluster_id: The cluster id. - :type cluster_id: str - :param cluster_definition: Required. The cluster definition. - :type cluster_definition: ~azure.mgmt.hdinsight.models.ClusterDefinition - :param kafka_rest_properties: The cluster kafka rest proxy configuration. - :type kafka_rest_properties: ~azure.mgmt.hdinsight.models.KafkaRestProperties - :param security_profile: The security profile. - :type security_profile: ~azure.mgmt.hdinsight.models.SecurityProfile - :param compute_profile: The compute profile. - :type compute_profile: ~azure.mgmt.hdinsight.models.ComputeProfile - :param provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "InProgress", "Failed", "Succeeded", "Canceled", "Deleting". - :type provisioning_state: str or ~azure.mgmt.hdinsight.models.HDInsightClusterProvisioningState - :param created_date: The date on which the cluster was created. - :type created_date: str - :param cluster_state: The state of the cluster. - :type cluster_state: str - :param quota_info: The quota information. - :type quota_info: ~azure.mgmt.hdinsight.models.QuotaInfo - :param errors: The list of errors. - :type errors: list[~azure.mgmt.hdinsight.models.Errors] - :param connectivity_endpoints: The list of connectivity endpoints. - :type connectivity_endpoints: list[~azure.mgmt.hdinsight.models.ConnectivityEndpoint] - :param disk_encryption_properties: The disk encryption properties. - :type disk_encryption_properties: ~azure.mgmt.hdinsight.models.DiskEncryptionProperties - :param encryption_in_transit_properties: The encryption-in-transit properties. - :type encryption_in_transit_properties: - ~azure.mgmt.hdinsight.models.EncryptionInTransitProperties - :param storage_profile: The storage profile. - :type storage_profile: ~azure.mgmt.hdinsight.models.StorageProfile - :param min_supported_tls_version: The minimal supported tls version. - :type min_supported_tls_version: str - :param excluded_services_config: The excluded services config. - :type excluded_services_config: ~azure.mgmt.hdinsight.models.ExcludedServicesConfig - :param network_properties: The network properties. - :type network_properties: ~azure.mgmt.hdinsight.models.NetworkProperties - :param compute_isolation_properties: The compute isolation properties. - :type compute_isolation_properties: ~azure.mgmt.hdinsight.models.ComputeIsolationProperties - :param private_link_configurations: The private link configurations. - :type private_link_configurations: list[~azure.mgmt.hdinsight.models.PrivateLinkConfiguration] - :ivar private_endpoint_connections: The list of private endpoint connections. - :vartype private_endpoint_connections: - list[~azure.mgmt.hdinsight.models.PrivateEndpointConnection] - """ - - _validation = { - 'cluster_definition': {'required': True}, - 'private_endpoint_connections': {'readonly': True}, - } - - _attribute_map = { - 'cluster_version': {'key': 'clusterVersion', 'type': 'str'}, - 'cluster_hdp_version': {'key': 'clusterHdpVersion', 'type': 'str'}, - 'os_type': {'key': 'osType', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'cluster_id': {'key': 'clusterId', 'type': 'str'}, - 'cluster_definition': {'key': 'clusterDefinition', 'type': 'ClusterDefinition'}, - 'kafka_rest_properties': {'key': 'kafkaRestProperties', 'type': 'KafkaRestProperties'}, - 'security_profile': {'key': 'securityProfile', 'type': 'SecurityProfile'}, - 'compute_profile': {'key': 'computeProfile', 'type': 'ComputeProfile'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'created_date': {'key': 'createdDate', 'type': 'str'}, - 'cluster_state': {'key': 'clusterState', 'type': 'str'}, - 'quota_info': {'key': 'quotaInfo', 'type': 'QuotaInfo'}, - 'errors': {'key': 'errors', 'type': '[Errors]'}, - 'connectivity_endpoints': {'key': 'connectivityEndpoints', 'type': '[ConnectivityEndpoint]'}, - 'disk_encryption_properties': {'key': 'diskEncryptionProperties', 'type': 'DiskEncryptionProperties'}, - 'encryption_in_transit_properties': {'key': 'encryptionInTransitProperties', 'type': 'EncryptionInTransitProperties'}, - 'storage_profile': {'key': 'storageProfile', 'type': 'StorageProfile'}, - 'min_supported_tls_version': {'key': 'minSupportedTlsVersion', 'type': 'str'}, - 'excluded_services_config': {'key': 'excludedServicesConfig', 'type': 'ExcludedServicesConfig'}, - 'network_properties': {'key': 'networkProperties', 'type': 'NetworkProperties'}, - 'compute_isolation_properties': {'key': 'computeIsolationProperties', 'type': 'ComputeIsolationProperties'}, - 'private_link_configurations': {'key': 'privateLinkConfigurations', 'type': '[PrivateLinkConfiguration]'}, - 'private_endpoint_connections': {'key': 'privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, - } - - def __init__( - self, - **kwargs - ): - super(ClusterGetProperties, self).__init__(**kwargs) - self.cluster_version = kwargs.get('cluster_version', None) - self.cluster_hdp_version = kwargs.get('cluster_hdp_version', None) - self.os_type = kwargs.get('os_type', None) - self.tier = kwargs.get('tier', None) - self.cluster_id = kwargs.get('cluster_id', None) - self.cluster_definition = kwargs['cluster_definition'] - self.kafka_rest_properties = kwargs.get('kafka_rest_properties', None) - self.security_profile = kwargs.get('security_profile', None) - self.compute_profile = kwargs.get('compute_profile', None) - self.provisioning_state = kwargs.get('provisioning_state', None) - self.created_date = kwargs.get('created_date', None) - self.cluster_state = kwargs.get('cluster_state', None) - self.quota_info = kwargs.get('quota_info', None) - self.errors = kwargs.get('errors', None) - self.connectivity_endpoints = kwargs.get('connectivity_endpoints', None) - self.disk_encryption_properties = kwargs.get('disk_encryption_properties', None) - self.encryption_in_transit_properties = kwargs.get('encryption_in_transit_properties', None) - self.storage_profile = kwargs.get('storage_profile', None) - self.min_supported_tls_version = kwargs.get('min_supported_tls_version', None) - self.excluded_services_config = kwargs.get('excluded_services_config', None) - self.network_properties = kwargs.get('network_properties', None) - self.compute_isolation_properties = kwargs.get('compute_isolation_properties', None) - self.private_link_configurations = kwargs.get('private_link_configurations', None) - self.private_endpoint_connections = None - - -class ClusterIdentity(msrest.serialization.Model): - """Identity for the cluster. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: The principal id of cluster 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 cluster. This property will only be provided - for a system assigned identity. - :vartype tenant_id: str - :param type: The type of identity used for the cluster. The type 'SystemAssigned, UserAssigned' - includes both an implicitly created identity and a set of user assigned identities. Possible - values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". - :type type: str or ~azure.mgmt.hdinsight.models.ResourceIdentityType - :param user_assigned_identities: The list of user identities associated with the cluster. The - user identity dictionary key references will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. - :type user_assigned_identities: dict[str, ~azure.mgmt.hdinsight.models.UserAssignedIdentity] - """ - - _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'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserAssignedIdentity}'}, - } - - def __init__( - self, - **kwargs - ): - super(ClusterIdentity, self).__init__(**kwargs) - self.principal_id = None - self.tenant_id = None - self.type = kwargs.get('type', None) - self.user_assigned_identities = kwargs.get('user_assigned_identities', None) - - -class ClusterListPersistedScriptActionsResult(msrest.serialization.Model): - """The ListPersistedScriptActions operation response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: The list of Persisted Script Actions. - :type value: list[~azure.mgmt.hdinsight.models.RuntimeScriptAction] - :ivar next_link: The link (url) to the next page of results. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[RuntimeScriptAction]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ClusterListPersistedScriptActionsResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class ClusterListResult(msrest.serialization.Model): - """The List Cluster operation response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: The list of Clusters. - :type value: list[~azure.mgmt.hdinsight.models.Cluster] - :ivar next_link: The link (url) to the next page of results. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Cluster]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ClusterListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class ClusterMonitoringRequest(msrest.serialization.Model): - """The cluster monitor parameters. - - :param workspace_id: The cluster monitor workspace ID. - :type workspace_id: str - :param primary_key: The cluster monitor workspace key. - :type primary_key: str - """ - - _attribute_map = { - 'workspace_id': {'key': 'workspaceId', 'type': 'str'}, - 'primary_key': {'key': 'primaryKey', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ClusterMonitoringRequest, self).__init__(**kwargs) - self.workspace_id = kwargs.get('workspace_id', None) - self.primary_key = kwargs.get('primary_key', None) - - -class ClusterMonitoringResponse(msrest.serialization.Model): - """The cluster monitoring status response. - - :param cluster_monitoring_enabled: The status of the monitor on the HDInsight cluster. - :type cluster_monitoring_enabled: bool - :param workspace_id: The workspace ID of the monitor on the HDInsight cluster. - :type workspace_id: str - """ - - _attribute_map = { - 'cluster_monitoring_enabled': {'key': 'clusterMonitoringEnabled', 'type': 'bool'}, - 'workspace_id': {'key': 'workspaceId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ClusterMonitoringResponse, self).__init__(**kwargs) - self.cluster_monitoring_enabled = kwargs.get('cluster_monitoring_enabled', None) - self.workspace_id = kwargs.get('workspace_id', None) - - -class ClusterPatchParameters(msrest.serialization.Model): - """The PatchCluster request parameters. - - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(ClusterPatchParameters, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - - -class ClusterResizeParameters(msrest.serialization.Model): - """The Resize Cluster request parameters. - - :param target_instance_count: The target instance count for the operation. - :type target_instance_count: int - """ - - _attribute_map = { - 'target_instance_count': {'key': 'targetInstanceCount', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(ClusterResizeParameters, self).__init__(**kwargs) - self.target_instance_count = kwargs.get('target_instance_count', None) - - -class ComputeIsolationProperties(msrest.serialization.Model): - """The compute isolation properties. - - :param enable_compute_isolation: The flag indicates whether enable compute isolation or not. - :type enable_compute_isolation: bool - :param host_sku: The host sku. - :type host_sku: str - """ - - _attribute_map = { - 'enable_compute_isolation': {'key': 'enableComputeIsolation', 'type': 'bool'}, - 'host_sku': {'key': 'hostSku', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ComputeIsolationProperties, self).__init__(**kwargs) - self.enable_compute_isolation = kwargs.get('enable_compute_isolation', False) - self.host_sku = kwargs.get('host_sku', None) - - -class ComputeProfile(msrest.serialization.Model): - """Describes the compute profile. - - :param roles: The list of roles in the cluster. - :type roles: list[~azure.mgmt.hdinsight.models.Role] - """ - - _attribute_map = { - 'roles': {'key': 'roles', 'type': '[Role]'}, - } - - def __init__( - self, - **kwargs - ): - super(ComputeProfile, self).__init__(**kwargs) - self.roles = kwargs.get('roles', None) - - -class ConnectivityEndpoint(msrest.serialization.Model): - """The connectivity properties. - - :param name: The name of the endpoint. - :type name: str - :param protocol: The protocol of the endpoint. - :type protocol: str - :param location: The location of the endpoint. - :type location: str - :param port: The port to connect to. - :type port: int - :param private_ip_address: The private ip address of the endpoint. - :type private_ip_address: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'protocol': {'key': 'protocol', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'port': {'key': 'port', 'type': 'int'}, - 'private_ip_address': {'key': 'privateIPAddress', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ConnectivityEndpoint, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.protocol = kwargs.get('protocol', None) - self.location = kwargs.get('location', None) - self.port = kwargs.get('port', None) - self.private_ip_address = kwargs.get('private_ip_address', None) - - -class DataDisksGroups(msrest.serialization.Model): - """The data disks groups for the role. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param disks_per_node: The number of disks per node. - :type disks_per_node: int - :ivar storage_account_type: ReadOnly. The storage account type. Do not set this value. - :vartype storage_account_type: str - :ivar disk_size_gb: ReadOnly. The DiskSize in GB. Do not set this value. - :vartype disk_size_gb: int - """ - - _validation = { - 'storage_account_type': {'readonly': True}, - 'disk_size_gb': {'readonly': True}, - } - - _attribute_map = { - 'disks_per_node': {'key': 'disksPerNode', 'type': 'int'}, - 'storage_account_type': {'key': 'storageAccountType', 'type': 'str'}, - 'disk_size_gb': {'key': 'diskSizeGB', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(DataDisksGroups, self).__init__(**kwargs) - self.disks_per_node = kwargs.get('disks_per_node', None) - self.storage_account_type = None - self.disk_size_gb = None - - -class Dimension(msrest.serialization.Model): - """The definition of Dimension. - - :param name: The name of the dimension. - :type name: str - :param display_name: The display name of the dimension. - :type display_name: str - :param internal_name: The display name of the dimension. - :type internal_name: str - :param to_be_exported_for_shoebox: The flag indicates whether the metric will be exported for - shoebox or not. - :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(Dimension, 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 DiskBillingMeters(msrest.serialization.Model): - """The disk billing meters. - - :param disk_rp_meter: The managed disk meter guid. - :type disk_rp_meter: str - :param sku: The managed disk billing sku, P30 or S30. - :type sku: str - :param tier: The managed disk billing tier, Standard or Premium. Possible values include: - "Standard", "Premium". - :type tier: str or ~azure.mgmt.hdinsight.models.Tier - """ - - _attribute_map = { - 'disk_rp_meter': {'key': 'diskRpMeter', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DiskBillingMeters, self).__init__(**kwargs) - self.disk_rp_meter = kwargs.get('disk_rp_meter', None) - self.sku = kwargs.get('sku', None) - self.tier = kwargs.get('tier', None) - - -class DiskEncryptionProperties(msrest.serialization.Model): - """The disk encryption properties. - - :param vault_uri: Base key vault URI where the customers key is located eg. - https://myvault.vault.azure.net. - :type vault_uri: str - :param key_name: Key name that is used for enabling disk encryption. - :type key_name: str - :param key_version: Specific key version that is used for enabling disk encryption. - :type key_version: str - :param encryption_algorithm: Algorithm identifier for encryption, default RSA-OAEP. Possible - values include: "RSA-OAEP", "RSA-OAEP-256", "RSA1_5". - :type encryption_algorithm: str or ~azure.mgmt.hdinsight.models.JsonWebKeyEncryptionAlgorithm - :param msi_resource_id: Resource ID of Managed Identity that is used to access the key vault. - :type msi_resource_id: str - :param encryption_at_host: Indicates whether or not resource disk encryption is enabled. - :type encryption_at_host: bool - """ - - _attribute_map = { - 'vault_uri': {'key': 'vaultUri', 'type': 'str'}, - 'key_name': {'key': 'keyName', 'type': 'str'}, - 'key_version': {'key': 'keyVersion', 'type': 'str'}, - 'encryption_algorithm': {'key': 'encryptionAlgorithm', 'type': 'str'}, - 'msi_resource_id': {'key': 'msiResourceId', 'type': 'str'}, - 'encryption_at_host': {'key': 'encryptionAtHost', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(DiskEncryptionProperties, self).__init__(**kwargs) - self.vault_uri = kwargs.get('vault_uri', None) - self.key_name = kwargs.get('key_name', None) - self.key_version = kwargs.get('key_version', None) - self.encryption_algorithm = kwargs.get('encryption_algorithm', None) - self.msi_resource_id = kwargs.get('msi_resource_id', None) - self.encryption_at_host = kwargs.get('encryption_at_host', False) - - -class EncryptionInTransitProperties(msrest.serialization.Model): - """The encryption-in-transit properties. - - :param is_encryption_in_transit_enabled: Indicates whether or not inter cluster node - communication is encrypted in transit. - :type is_encryption_in_transit_enabled: bool - """ - - _attribute_map = { - 'is_encryption_in_transit_enabled': {'key': 'isEncryptionInTransitEnabled', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(EncryptionInTransitProperties, self).__init__(**kwargs) - self.is_encryption_in_transit_enabled = kwargs.get('is_encryption_in_transit_enabled', False) - - -class ErrorResponse(msrest.serialization.Model): - """Describes the format of Error response. - - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - - -class Errors(msrest.serialization.Model): - """The error message associated with the cluster creation. - - :param code: The error code. - :type code: str - :param message: The error message. - :type message: str - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Errors, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - - -class ExcludedServicesConfig(msrest.serialization.Model): - """The configuration that services will be excluded when creating cluster. - - :param excluded_services_config_id: The config id of excluded services. - :type excluded_services_config_id: str - :param excluded_services_list: The list of excluded services. - :type excluded_services_list: str - """ - - _attribute_map = { - 'excluded_services_config_id': {'key': 'excludedServicesConfigId', 'type': 'str'}, - 'excluded_services_list': {'key': 'excludedServicesList', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ExcludedServicesConfig, self).__init__(**kwargs) - self.excluded_services_config_id = kwargs.get('excluded_services_config_id', None) - self.excluded_services_list = kwargs.get('excluded_services_list', None) - - -class ExecuteScriptActionParameters(msrest.serialization.Model): - """The parameters for the script actions to execute on a running cluster. - - All required parameters must be populated in order to send to Azure. - - :param script_actions: The list of run time script actions. - :type script_actions: list[~azure.mgmt.hdinsight.models.RuntimeScriptAction] - :param persist_on_success: Required. Gets or sets if the scripts needs to be persisted. - :type persist_on_success: bool - """ - - _validation = { - 'persist_on_success': {'required': True}, - } - - _attribute_map = { - 'script_actions': {'key': 'scriptActions', 'type': '[RuntimeScriptAction]'}, - 'persist_on_success': {'key': 'persistOnSuccess', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(ExecuteScriptActionParameters, self).__init__(**kwargs) - self.script_actions = kwargs.get('script_actions', None) - self.persist_on_success = kwargs['persist_on_success'] - - -class Extension(msrest.serialization.Model): - """Cluster monitoring extensions. - - :param workspace_id: The workspace ID for the cluster monitoring extension. - :type workspace_id: str - :param primary_key: The certificate for the cluster monitoring extensions. - :type primary_key: str - """ - - _attribute_map = { - 'workspace_id': {'key': 'workspaceId', 'type': 'str'}, - 'primary_key': {'key': 'primaryKey', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Extension, self).__init__(**kwargs) - self.workspace_id = kwargs.get('workspace_id', None) - self.primary_key = kwargs.get('primary_key', None) - - -class GatewaySettings(msrest.serialization.Model): - """Gateway settings. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar is_credential_enabled: Indicates whether or not the gateway settings based authorization - is enabled. - :vartype is_credential_enabled: str - :ivar user_name: The gateway settings user name. - :vartype user_name: str - :ivar password: The gateway settings user password. - :vartype password: str - """ - - _validation = { - 'is_credential_enabled': {'readonly': True}, - 'user_name': {'readonly': True}, - 'password': {'readonly': True}, - } - - _attribute_map = { - 'is_credential_enabled': {'key': 'restAuthCredential\\.isEnabled', 'type': 'str'}, - 'user_name': {'key': 'restAuthCredential\\.username', 'type': 'str'}, - 'password': {'key': 'restAuthCredential\\.password', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(GatewaySettings, self).__init__(**kwargs) - self.is_credential_enabled = None - self.user_name = None - self.password = None - - -class HardwareProfile(msrest.serialization.Model): - """The hardware profile. - - :param vm_size: The size of the VM. - :type vm_size: str - """ - - _attribute_map = { - 'vm_size': {'key': 'vmSize', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(HardwareProfile, self).__init__(**kwargs) - self.vm_size = kwargs.get('vm_size', None) - - -class HostInfo(msrest.serialization.Model): - """The cluster host information. - - :param name: The host name. - :type name: str - :param fqdn: The Fully Qualified Domain Name of host. - :type fqdn: str - :param effective_disk_encryption_key_url: The effective disk encryption key URL used by the - host. - :type effective_disk_encryption_key_url: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'fqdn': {'key': 'fqdn', 'type': 'str'}, - 'effective_disk_encryption_key_url': {'key': 'effectiveDiskEncryptionKeyUrl', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(HostInfo, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.fqdn = kwargs.get('fqdn', None) - self.effective_disk_encryption_key_url = kwargs.get('effective_disk_encryption_key_url', None) - - -class IPConfiguration(msrest.serialization.Model): - """The ip configurations for the private link service. - - 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: The private link IP configuration id. - :vartype id: str - :param name: Required. The name of private link IP configuration. - :type name: str - :ivar type: The type of the private link IP configuration. - :vartype type: str - :ivar provisioning_state: The private link configuration provisioning state, which only appears - in the response. Possible values include: "InProgress", "Failed", "Succeeded", "Canceled", - "Deleting". - :vartype provisioning_state: str or - ~azure.mgmt.hdinsight.models.PrivateLinkConfigurationProvisioningState - :param primary: Indicates whether this IP configuration is primary for the corresponding NIC. - :type primary: bool - :param private_ip_address: The IP address. - :type private_ip_address: str - :param private_ip_allocation_method: The method that private IP address is allocated. Possible - values include: "dynamic", "static". - :type private_ip_allocation_method: str or - ~azure.mgmt.hdinsight.models.PrivateIPAllocationMethod - :param subnet: The subnet resource id. - :type subnet: ~azure.mgmt.hdinsight.models.ResourceId - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'required': 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'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'primary': {'key': 'properties.primary', 'type': 'bool'}, - 'private_ip_address': {'key': 'properties.privateIPAddress', 'type': 'str'}, - 'private_ip_allocation_method': {'key': 'properties.privateIPAllocationMethod', 'type': 'str'}, - 'subnet': {'key': 'properties.subnet', 'type': 'ResourceId'}, - } - - def __init__( - self, - **kwargs - ): - super(IPConfiguration, self).__init__(**kwargs) - self.id = None - self.name = kwargs['name'] - self.type = None - self.provisioning_state = None - self.primary = kwargs.get('primary', None) - self.private_ip_address = kwargs.get('private_ip_address', None) - self.private_ip_allocation_method = kwargs.get('private_ip_allocation_method', None) - self.subnet = kwargs.get('subnet', None) - - -class KafkaRestProperties(msrest.serialization.Model): - """The kafka rest proxy configuration which contains AAD security group information. - - :param client_group_info: The information of AAD security group. - :type client_group_info: ~azure.mgmt.hdinsight.models.ClientGroupInfo - :param configuration_override: The configurations that need to be overriden. - :type configuration_override: dict[str, str] - """ - - _attribute_map = { - 'client_group_info': {'key': 'clientGroupInfo', 'type': 'ClientGroupInfo'}, - 'configuration_override': {'key': 'configurationOverride', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(KafkaRestProperties, self).__init__(**kwargs) - self.client_group_info = kwargs.get('client_group_info', None) - self.configuration_override = kwargs.get('configuration_override', None) - - -class LinuxOperatingSystemProfile(msrest.serialization.Model): - """The ssh username, password, and ssh public key. - - :param username: The username. - :type username: str - :param password: The password. - :type password: str - :param ssh_profile: The SSH profile. - :type ssh_profile: ~azure.mgmt.hdinsight.models.SshProfile - """ - - _attribute_map = { - 'username': {'key': 'username', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, - 'ssh_profile': {'key': 'sshProfile', 'type': 'SshProfile'}, - } - - def __init__( - self, - **kwargs - ): - super(LinuxOperatingSystemProfile, self).__init__(**kwargs) - self.username = kwargs.get('username', None) - self.password = kwargs.get('password', None) - self.ssh_profile = kwargs.get('ssh_profile', None) - - -class LocalizedName(msrest.serialization.Model): - """The details about the localizable name of a type of usage. - - :param value: The name of the used resource. - :type value: str - :param localized_value: The localized name of the used resource. - :type localized_value: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(LocalizedName, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.localized_value = kwargs.get('localized_value', None) - - -class MetricSpecifications(msrest.serialization.Model): - """The details of metric specifications. - - :param name: The name of the metric specification. - :type name: str - :param display_name: The display name of the metric specification. - :type display_name: str - :param display_description: The display description of the metric specification. - :type display_description: str - :param unit: The unit of the metric specification. - :type unit: str - :param aggregation_type: The aggregation type of the metric specification. - :type aggregation_type: str - :param supported_aggregation_types: The supported aggregation types of the metric - specification. - :type supported_aggregation_types: list[str] - :param supported_time_grain_types: The supported time grain types of the metric specification. - :type supported_time_grain_types: list[str] - :param enable_regional_mdm_account: The flag indicates whether enable regional mdm account or - not. - :type enable_regional_mdm_account: bool - :param source_mdm_account: The source mdm account. - :type source_mdm_account: str - :param source_mdm_namespace: The source mdm namespace. - :type source_mdm_namespace: str - :param metric_filter_pattern: The metric filter pattern. - :type metric_filter_pattern: str - :param fill_gap_with_zero: The flag indicates whether filling gap with zero. - :type fill_gap_with_zero: bool - :param category: The category of the metric. - :type category: str - :param resource_id_dimension_name_override: The override name of resource id dimension name. - :type resource_id_dimension_name_override: str - :param is_internal: The flag indicates whether the metric is internal or not. - :type is_internal: bool - :param delegate_metric_name_override: The override name of delegate metric. - :type delegate_metric_name_override: str - :param dimensions: The dimensions of the metric specification. - :type dimensions: list[~azure.mgmt.hdinsight.models.Dimension] - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, - 'supported_aggregation_types': {'key': 'supportedAggregationTypes', 'type': '[str]'}, - 'supported_time_grain_types': {'key': 'supportedTimeGrainTypes', 'type': '[str]'}, - 'enable_regional_mdm_account': {'key': 'enableRegionalMdmAccount', 'type': 'bool'}, - 'source_mdm_account': {'key': 'sourceMdmAccount', 'type': 'str'}, - 'source_mdm_namespace': {'key': 'sourceMdmNamespace', 'type': 'str'}, - 'metric_filter_pattern': {'key': 'metricFilterPattern', 'type': 'str'}, - 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'bool'}, - 'category': {'key': 'category', 'type': 'str'}, - 'resource_id_dimension_name_override': {'key': 'resourceIdDimensionNameOverride', 'type': 'str'}, - 'is_internal': {'key': 'isInternal', 'type': 'bool'}, - 'delegate_metric_name_override': {'key': 'delegateMetricNameOverride', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[Dimension]'}, - } - - def __init__( - self, - **kwargs - ): - super(MetricSpecifications, 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.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.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) - self.metric_filter_pattern = kwargs.get('metric_filter_pattern', None) - self.fill_gap_with_zero = kwargs.get('fill_gap_with_zero', None) - self.category = kwargs.get('category', None) - self.resource_id_dimension_name_override = kwargs.get('resource_id_dimension_name_override', None) - self.is_internal = kwargs.get('is_internal', None) - self.delegate_metric_name_override = kwargs.get('delegate_metric_name_override', None) - self.dimensions = kwargs.get('dimensions', None) - - -class NameAvailabilityCheckRequestParameters(msrest.serialization.Model): - """The request spec of checking name availability. - - :param name: The resource name. - :type name: str - :param type: The resource type. - :type type: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(NameAvailabilityCheckRequestParameters, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.type = kwargs.get('type', None) - - -class NameAvailabilityCheckResult(msrest.serialization.Model): - """The response spec of checking name availability. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param name_available: This indicates whether the name is available. - :type name_available: bool - :ivar reason: The reason of the result. - :vartype reason: str - :ivar message: The related message. - :vartype message: str - """ - - _validation = { - 'reason': {'readonly': True}, - 'message': {'readonly': True}, - } - - _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(NameAvailabilityCheckResult, self).__init__(**kwargs) - self.name_available = kwargs.get('name_available', None) - self.reason = None - self.message = None - - -class NetworkProperties(msrest.serialization.Model): - """The network properties. - - :param resource_provider_connection: The direction for the resource provider connection. - Possible values include: "Inbound", "Outbound". - :type resource_provider_connection: str or - ~azure.mgmt.hdinsight.models.ResourceProviderConnection - :param private_link: Indicates whether or not private link is enabled. Possible values include: - "Disabled", "Enabled". - :type private_link: str or ~azure.mgmt.hdinsight.models.PrivateLink - """ - - _attribute_map = { - 'resource_provider_connection': {'key': 'resourceProviderConnection', 'type': 'str'}, - 'private_link': {'key': 'privateLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkProperties, self).__init__(**kwargs) - self.resource_provider_connection = kwargs.get('resource_provider_connection', None) - self.private_link = kwargs.get('private_link', None) - - -class Operation(msrest.serialization.Model): - """The HDInsight REST API operation. - - :param name: The operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The display of operation. - :type display: ~azure.mgmt.hdinsight.models.OperationDisplay - :param properties: The operation properties. - :type properties: ~azure.mgmt.hdinsight.models.OperationProperties - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'properties': {'key': 'properties', 'type': 'OperationProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display = kwargs.get('display', None) - self.properties = kwargs.get('properties', None) - - -class OperationDisplay(msrest.serialization.Model): - """The object that represents the operation. - - :param provider: The service provider: Microsoft.HDInsight. - :type provider: str - :param resource: The resource on which the operation is performed: Cluster, Applications, etc. - :type resource: str - :param operation: The operation type: read, write, delete, etc. - :type operation: str - :param description: Localized friendly description for the operation. - :type description: str - """ - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = kwargs.get('provider', None) - self.resource = kwargs.get('resource', None) - self.operation = kwargs.get('operation', None) - self.description = kwargs.get('description', None) - - -class OperationListResult(msrest.serialization.Model): - """Result of the request to list HDInsight operations. It contains a list of operations and a URL link to get the next set of results. - - :param value: The list of HDInsight operations supported by the HDInsight resource provider. - :type value: list[~azure.mgmt.hdinsight.models.Operation] - :param next_link: The URL to get the next set of operation list results if there are any. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class OperationProperties(msrest.serialization.Model): - """The details of operation. - - :param service_specification: The specification of the service. - :type service_specification: ~azure.mgmt.hdinsight.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 OsProfile(msrest.serialization.Model): - """The Linux operation systems profile. - - :param linux_operating_system_profile: The Linux OS profile. - :type linux_operating_system_profile: ~azure.mgmt.hdinsight.models.LinuxOperatingSystemProfile - """ - - _attribute_map = { - 'linux_operating_system_profile': {'key': 'linuxOperatingSystemProfile', 'type': 'LinuxOperatingSystemProfile'}, - } - - def __init__( - self, - **kwargs - ): - super(OsProfile, self).__init__(**kwargs) - self.linux_operating_system_profile = kwargs.get('linux_operating_system_profile', None) - - -class PrivateEndpoint(msrest.serialization.Model): - """The private endpoint. - - :param id: The private endpoint id. - :type id: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateEndpoint, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - - -class PrivateEndpointConnection(ResourceAutoGenerated): - """The private endpoint connection. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.hdinsight.models.SystemData - :ivar private_endpoint: The private endpoint of the private endpoint connection. - :vartype private_endpoint: ~azure.mgmt.hdinsight.models.PrivateEndpoint - :param private_link_service_connection_state: Required. The private link service connection - state. - :type private_link_service_connection_state: - ~azure.mgmt.hdinsight.models.PrivateLinkServiceConnectionState - :ivar link_identifier: The link identifier. - :vartype link_identifier: str - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "InProgress", "Updating", "Failed", "Succeeded", "Canceled", "Deleting". - :vartype provisioning_state: str or - ~azure.mgmt.hdinsight.models.PrivateEndpointConnectionProvisioningState - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'private_endpoint': {'readonly': True}, - 'private_link_service_connection_state': {'required': True}, - 'link_identifier': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'private_endpoint': {'key': 'properties.privateEndpoint', 'type': 'PrivateEndpoint'}, - 'private_link_service_connection_state': {'key': 'properties.privateLinkServiceConnectionState', 'type': 'PrivateLinkServiceConnectionState'}, - 'link_identifier': {'key': 'properties.linkIdentifier', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateEndpointConnection, self).__init__(**kwargs) - self.system_data = None - self.private_endpoint = None - self.private_link_service_connection_state = kwargs['private_link_service_connection_state'] - self.link_identifier = None - self.provisioning_state = None - - -class PrivateEndpointConnectionListResult(msrest.serialization.Model): - """The list private endpoint connections response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: The list of private endpoint connections. - :type value: list[~azure.mgmt.hdinsight.models.PrivateEndpointConnection] - :ivar next_link: The link (url) to the next page of results. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateEndpointConnection]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class PrivateLinkConfiguration(msrest.serialization.Model): - """The private link configuration. - - 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: The private link configuration id. - :vartype id: str - :param name: Required. The name of private link configuration. - :type name: str - :ivar type: The type of the private link configuration. - :vartype type: str - :param group_id: Required. The HDInsight private linkable sub-resource name to apply the - private link configuration to. For example, 'headnode', 'gateway', 'edgenode'. - :type group_id: str - :ivar provisioning_state: The private link configuration provisioning state, which only appears - in the response. Possible values include: "InProgress", "Failed", "Succeeded", "Canceled", - "Deleting". - :vartype provisioning_state: str or - ~azure.mgmt.hdinsight.models.PrivateLinkConfigurationProvisioningState - :param ip_configurations: Required. The IP configurations for the private link service. - :type ip_configurations: list[~azure.mgmt.hdinsight.models.IPConfiguration] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'required': True}, - 'type': {'readonly': True}, - 'group_id': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'ip_configurations': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'group_id': {'key': 'properties.groupId', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'ip_configurations': {'key': 'properties.ipConfigurations', 'type': '[IPConfiguration]'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateLinkConfiguration, self).__init__(**kwargs) - self.id = None - self.name = kwargs['name'] - self.type = None - self.group_id = kwargs['group_id'] - self.provisioning_state = None - self.ip_configurations = kwargs['ip_configurations'] - - -class PrivateLinkResource(Resource): - """A private link resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Metadata pertaining to creation and last modification of the resource. - :vartype system_data: ~azure.mgmt.hdinsight.models.SystemData - :ivar group_id: The private link resource group id. - :vartype group_id: str - :ivar required_members: The private link resource required member names. - :vartype required_members: list[str] - :param required_zone_names: The private link resource Private link DNS zone name. - :type required_zone_names: list[str] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'group_id': {'readonly': True}, - 'required_members': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'group_id': {'key': 'properties.groupId', 'type': 'str'}, - 'required_members': {'key': 'properties.requiredMembers', 'type': '[str]'}, - 'required_zone_names': {'key': 'properties.requiredZoneNames', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateLinkResource, self).__init__(**kwargs) - self.system_data = None - self.group_id = None - self.required_members = None - self.required_zone_names = kwargs.get('required_zone_names', None) - - -class PrivateLinkResourceListResult(msrest.serialization.Model): - """A list of private link resources. - - :param value: Array of private link resources. - :type value: list[~azure.mgmt.hdinsight.models.PrivateLinkResource] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateLinkResource]'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateLinkResourceListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class PrivateLinkServiceConnectionState(msrest.serialization.Model): - """The private link service connection state. - - All required parameters must be populated in order to send to Azure. - - :param status: Required. The concrete private link service connection. Possible values include: - "Approved", "Rejected", "Pending", "Removed". - :type status: str or ~azure.mgmt.hdinsight.models.PrivateLinkServiceConnectionStatus - :param description: The optional description of the status. - :type description: str - :param actions_required: Whether there is further actions. - :type actions_required: str - """ - - _validation = { - 'status': {'required': True}, - } - - _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'actions_required': {'key': 'actionsRequired', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateLinkServiceConnectionState, self).__init__(**kwargs) - self.status = kwargs['status'] - self.description = kwargs.get('description', None) - self.actions_required = kwargs.get('actions_required', None) - - -class QuotaCapability(msrest.serialization.Model): - """The regional quota capability. - - :param cores_used: The number of cores used in the subscription. - :type cores_used: long - :param max_cores_allowed: The number of cores that the subscription allowed. - :type max_cores_allowed: long - :param regional_quotas: The list of region quota capabilities. - :type regional_quotas: list[~azure.mgmt.hdinsight.models.RegionalQuotaCapability] - """ - - _attribute_map = { - 'cores_used': {'key': 'coresUsed', 'type': 'long'}, - 'max_cores_allowed': {'key': 'maxCoresAllowed', 'type': 'long'}, - 'regional_quotas': {'key': 'regionalQuotas', 'type': '[RegionalQuotaCapability]'}, - } - - def __init__( - self, - **kwargs - ): - super(QuotaCapability, self).__init__(**kwargs) - self.cores_used = kwargs.get('cores_used', None) - self.max_cores_allowed = kwargs.get('max_cores_allowed', None) - self.regional_quotas = kwargs.get('regional_quotas', None) - - -class QuotaInfo(msrest.serialization.Model): - """The quota properties for the cluster. - - :param cores_used: The cores used by the cluster. - :type cores_used: int - """ - - _attribute_map = { - 'cores_used': {'key': 'coresUsed', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(QuotaInfo, self).__init__(**kwargs) - self.cores_used = kwargs.get('cores_used', None) - - -class RegionalQuotaCapability(msrest.serialization.Model): - """The regional quota capacity. - - :param region_name: The region name. - :type region_name: str - :param cores_used: The number of cores used in the region. - :type cores_used: long - :param cores_available: The number of cores available in the region. - :type cores_available: long - """ - - _attribute_map = { - 'region_name': {'key': 'regionName', 'type': 'str'}, - 'cores_used': {'key': 'coresUsed', 'type': 'long'}, - 'cores_available': {'key': 'coresAvailable', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(RegionalQuotaCapability, self).__init__(**kwargs) - self.region_name = kwargs.get('region_name', None) - self.cores_used = kwargs.get('cores_used', None) - self.cores_available = kwargs.get('cores_available', None) - - -class RegionsCapability(msrest.serialization.Model): - """The regions capability. - - :param available: The list of region capabilities. - :type available: list[str] - """ - - _attribute_map = { - 'available': {'key': 'available', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(RegionsCapability, self).__init__(**kwargs) - self.available = kwargs.get('available', None) - - -class ResourceId(msrest.serialization.Model): - """The azure resource id. - - :param id: The azure resource id. - :type id: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceId, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - - -class Role(msrest.serialization.Model): - """Describes a role on the cluster. - - :param name: The name of the role. - :type name: str - :param min_instance_count: The minimum instance count of the cluster. - :type min_instance_count: int - :param target_instance_count: The instance count of the cluster. - :type target_instance_count: int - :param vm_group_name: The name of the virtual machine group. - :type vm_group_name: str - :param autoscale_configuration: The autoscale configurations. - :type autoscale_configuration: ~azure.mgmt.hdinsight.models.Autoscale - :param hardware_profile: The hardware profile. - :type hardware_profile: ~azure.mgmt.hdinsight.models.HardwareProfile - :param os_profile: The operating system profile. - :type os_profile: ~azure.mgmt.hdinsight.models.OsProfile - :param virtual_network_profile: The virtual network profile. - :type virtual_network_profile: ~azure.mgmt.hdinsight.models.VirtualNetworkProfile - :param data_disks_groups: The data disks groups for the role. - :type data_disks_groups: list[~azure.mgmt.hdinsight.models.DataDisksGroups] - :param script_actions: The list of script actions on the role. - :type script_actions: list[~azure.mgmt.hdinsight.models.ScriptAction] - :param encrypt_data_disks: Indicates whether encrypt the data disks. - :type encrypt_data_disks: bool - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'min_instance_count': {'key': 'minInstanceCount', 'type': 'int'}, - 'target_instance_count': {'key': 'targetInstanceCount', 'type': 'int'}, - 'vm_group_name': {'key': 'VMGroupName', 'type': 'str'}, - 'autoscale_configuration': {'key': 'autoscale', 'type': 'Autoscale'}, - 'hardware_profile': {'key': 'hardwareProfile', 'type': 'HardwareProfile'}, - 'os_profile': {'key': 'osProfile', 'type': 'OsProfile'}, - 'virtual_network_profile': {'key': 'virtualNetworkProfile', 'type': 'VirtualNetworkProfile'}, - 'data_disks_groups': {'key': 'dataDisksGroups', 'type': '[DataDisksGroups]'}, - 'script_actions': {'key': 'scriptActions', 'type': '[ScriptAction]'}, - 'encrypt_data_disks': {'key': 'encryptDataDisks', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(Role, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.min_instance_count = kwargs.get('min_instance_count', None) - self.target_instance_count = kwargs.get('target_instance_count', None) - self.vm_group_name = kwargs.get('vm_group_name', None) - self.autoscale_configuration = kwargs.get('autoscale_configuration', None) - self.hardware_profile = kwargs.get('hardware_profile', None) - self.os_profile = kwargs.get('os_profile', None) - self.virtual_network_profile = kwargs.get('virtual_network_profile', None) - self.data_disks_groups = kwargs.get('data_disks_groups', None) - self.script_actions = kwargs.get('script_actions', None) - self.encrypt_data_disks = kwargs.get('encrypt_data_disks', False) - - -class RuntimeScriptAction(msrest.serialization.Model): - """Describes a script action on a running cluster. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The name of the script action. - :type name: str - :param uri: Required. The URI to the script. - :type uri: str - :param parameters: The parameters for the script. - :type parameters: str - :param roles: Required. The list of roles where script will be executed. - :type roles: list[str] - :ivar application_name: The application name of the script action, if any. - :vartype application_name: str - """ - - _validation = { - 'name': {'required': True}, - 'uri': {'required': True}, - 'roles': {'required': True}, - 'application_name': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'parameters': {'key': 'parameters', 'type': 'str'}, - 'roles': {'key': 'roles', 'type': '[str]'}, - 'application_name': {'key': 'applicationName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RuntimeScriptAction, self).__init__(**kwargs) - self.name = kwargs['name'] - self.uri = kwargs['uri'] - self.parameters = kwargs.get('parameters', None) - self.roles = kwargs['roles'] - self.application_name = None - - -class RuntimeScriptActionDetail(RuntimeScriptAction): - """The execution details of a script action. - - 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 name: Required. The name of the script action. - :type name: str - :param uri: Required. The URI to the script. - :type uri: str - :param parameters: The parameters for the script. - :type parameters: str - :param roles: Required. The list of roles where script will be executed. - :type roles: list[str] - :ivar application_name: The application name of the script action, if any. - :vartype application_name: str - :ivar script_execution_id: The execution id of the script action. - :vartype script_execution_id: long - :ivar start_time: The start time of script action execution. - :vartype start_time: str - :ivar end_time: The end time of script action execution. - :vartype end_time: str - :ivar status: The current execution status of the script action. - :vartype status: str - :ivar operation: The reason why the script action was executed. - :vartype operation: str - :ivar execution_summary: The summary of script action execution result. - :vartype execution_summary: list[~azure.mgmt.hdinsight.models.ScriptActionExecutionSummary] - :ivar debug_information: The script action execution debug information. - :vartype debug_information: str - """ - - _validation = { - 'name': {'required': True}, - 'uri': {'required': True}, - 'roles': {'required': True}, - 'application_name': {'readonly': True}, - 'script_execution_id': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - 'status': {'readonly': True}, - 'operation': {'readonly': True}, - 'execution_summary': {'readonly': True}, - 'debug_information': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'parameters': {'key': 'parameters', 'type': 'str'}, - 'roles': {'key': 'roles', 'type': '[str]'}, - 'application_name': {'key': 'applicationName', 'type': 'str'}, - 'script_execution_id': {'key': 'scriptExecutionId', 'type': 'long'}, - 'start_time': {'key': 'startTime', 'type': 'str'}, - 'end_time': {'key': 'endTime', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'execution_summary': {'key': 'executionSummary', 'type': '[ScriptActionExecutionSummary]'}, - 'debug_information': {'key': 'debugInformation', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RuntimeScriptActionDetail, self).__init__(**kwargs) - self.script_execution_id = None - self.start_time = None - self.end_time = None - self.status = None - self.operation = None - self.execution_summary = None - self.debug_information = None - - -class ScriptAction(msrest.serialization.Model): - """Describes a script action on role on the cluster. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The name of the script action. - :type name: str - :param uri: Required. The URI to the script. - :type uri: str - :param parameters: Required. The parameters for the script provided. - :type parameters: str - """ - - _validation = { - 'name': {'required': True}, - 'uri': {'required': True}, - 'parameters': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'parameters': {'key': 'parameters', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ScriptAction, self).__init__(**kwargs) - self.name = kwargs['name'] - self.uri = kwargs['uri'] - self.parameters = kwargs['parameters'] - - -class ScriptActionExecutionHistoryList(msrest.serialization.Model): - """The list script execution history response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of persisted script action details for the cluster. - :vartype value: list[~azure.mgmt.hdinsight.models.RuntimeScriptActionDetail] - :ivar next_link: The link (url) to the next page of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[RuntimeScriptActionDetail]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ScriptActionExecutionHistoryList, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class ScriptActionExecutionSummary(msrest.serialization.Model): - """The execution summary of a script action. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar status: The status of script action execution. - :vartype status: str - :ivar instance_count: The instance count for a given script action execution status. - :vartype instance_count: int - """ - - _validation = { - 'status': {'readonly': True}, - 'instance_count': {'readonly': True}, - } - - _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'instance_count': {'key': 'instanceCount', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(ScriptActionExecutionSummary, self).__init__(**kwargs) - self.status = None - self.instance_count = None - - -class ScriptActionPersistedGetResponseSpec(msrest.serialization.Model): - """The persisted script action for cluster. - - :param name: The name of script action. - :type name: str - :param uri: The URI to the script. - :type uri: str - :param parameters: The parameters for the script provided. - :type parameters: str - :param roles: The list of roles where script will be executed. - :type roles: list[str] - :param application_name: The application name for the script action. - :type application_name: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'parameters': {'key': 'parameters', 'type': 'str'}, - 'roles': {'key': 'roles', 'type': '[str]'}, - 'application_name': {'key': 'applicationName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ScriptActionPersistedGetResponseSpec, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.uri = kwargs.get('uri', None) - self.parameters = kwargs.get('parameters', None) - self.roles = kwargs.get('roles', None) - self.application_name = kwargs.get('application_name', None) - - -class ScriptActionsList(msrest.serialization.Model): - """The persisted script action for the cluster. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: The list of persisted script action details for the cluster. - :type value: list[~azure.mgmt.hdinsight.models.RuntimeScriptActionDetail] - :ivar next_link: The link (url) to the next page of results. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[RuntimeScriptActionDetail]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ScriptActionsList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class SecurityProfile(msrest.serialization.Model): - """The security profile which contains Ssh public key for the HDInsight cluster. - - :param directory_type: The directory type. Possible values include: "ActiveDirectory". - :type directory_type: str or ~azure.mgmt.hdinsight.models.DirectoryType - :param domain: The organization's active directory domain. - :type domain: str - :param organizational_unit_dn: The organizational unit within the Active Directory to place the - cluster and service accounts. - :type organizational_unit_dn: str - :param ldaps_urls: The LDAPS protocol URLs to communicate with the Active Directory. - :type ldaps_urls: list[str] - :param domain_username: The domain user account that will have admin privileges on the cluster. - :type domain_username: str - :param domain_user_password: The domain admin password. - :type domain_user_password: str - :param cluster_users_group_d_ns: Optional. The Distinguished Names for cluster user groups. - :type cluster_users_group_d_ns: list[str] - :param aadds_resource_id: The resource ID of the user's Azure Active Directory Domain Service. - :type aadds_resource_id: str - :param msi_resource_id: User assigned identity that has permissions to read and create - cluster-related artifacts in the user's AADDS. - :type msi_resource_id: str - """ - - _attribute_map = { - 'directory_type': {'key': 'directoryType', 'type': 'str'}, - 'domain': {'key': 'domain', 'type': 'str'}, - 'organizational_unit_dn': {'key': 'organizationalUnitDN', 'type': 'str'}, - 'ldaps_urls': {'key': 'ldapsUrls', 'type': '[str]'}, - 'domain_username': {'key': 'domainUsername', 'type': 'str'}, - 'domain_user_password': {'key': 'domainUserPassword', 'type': 'str'}, - 'cluster_users_group_d_ns': {'key': 'clusterUsersGroupDNs', 'type': '[str]'}, - 'aadds_resource_id': {'key': 'aaddsResourceId', 'type': 'str'}, - 'msi_resource_id': {'key': 'msiResourceId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SecurityProfile, self).__init__(**kwargs) - self.directory_type = kwargs.get('directory_type', None) - self.domain = kwargs.get('domain', None) - self.organizational_unit_dn = kwargs.get('organizational_unit_dn', None) - self.ldaps_urls = kwargs.get('ldaps_urls', None) - self.domain_username = kwargs.get('domain_username', None) - self.domain_user_password = kwargs.get('domain_user_password', None) - self.cluster_users_group_d_ns = kwargs.get('cluster_users_group_d_ns', None) - self.aadds_resource_id = kwargs.get('aadds_resource_id', None) - self.msi_resource_id = kwargs.get('msi_resource_id', None) - - -class ServiceSpecification(msrest.serialization.Model): - """The specification of the service. - - :param metric_specifications: The metric specifications. - :type metric_specifications: list[~azure.mgmt.hdinsight.models.MetricSpecifications] - """ - - _attribute_map = { - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecifications]'}, - } - - def __init__( - self, - **kwargs - ): - super(ServiceSpecification, self).__init__(**kwargs) - self.metric_specifications = kwargs.get('metric_specifications', None) - - -class SshProfile(msrest.serialization.Model): - """The list of SSH public keys. - - :param public_keys: The list of SSH public keys. - :type public_keys: list[~azure.mgmt.hdinsight.models.SshPublicKey] - """ - - _attribute_map = { - 'public_keys': {'key': 'publicKeys', 'type': '[SshPublicKey]'}, - } - - def __init__( - self, - **kwargs - ): - super(SshProfile, self).__init__(**kwargs) - self.public_keys = kwargs.get('public_keys', None) - - -class SshPublicKey(msrest.serialization.Model): - """The SSH public key for the cluster nodes. - - :param certificate_data: The certificate for SSH. - :type certificate_data: str - """ - - _attribute_map = { - 'certificate_data': {'key': 'certificateData', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SshPublicKey, self).__init__(**kwargs) - self.certificate_data = kwargs.get('certificate_data', None) - - -class StorageAccount(msrest.serialization.Model): - """The storage Account. - - :param name: The name of the storage account. - :type name: str - :param is_default: Whether or not the storage account is the default storage account. - :type is_default: bool - :param container: The container in the storage account, only to be specified for WASB storage - accounts. - :type container: str - :param file_system: The filesystem, only to be specified for Azure Data Lake Storage Gen 2. - :type file_system: str - :param key: The storage account access key. - :type key: str - :param resource_id: The resource ID of storage account, only to be specified for Azure Data - Lake Storage Gen 2. - :type resource_id: str - :param msi_resource_id: The managed identity (MSI) that is allowed to access the storage - account, only to be specified for Azure Data Lake Storage Gen 2. - :type msi_resource_id: str - :param saskey: The shared access signature key. - :type saskey: str - :param fileshare: The file share name. - :type fileshare: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'is_default': {'key': 'isDefault', 'type': 'bool'}, - 'container': {'key': 'container', 'type': 'str'}, - 'file_system': {'key': 'fileSystem', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'msi_resource_id': {'key': 'msiResourceId', 'type': 'str'}, - 'saskey': {'key': 'saskey', 'type': 'str'}, - 'fileshare': {'key': 'fileshare', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(StorageAccount, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.is_default = kwargs.get('is_default', None) - self.container = kwargs.get('container', None) - self.file_system = kwargs.get('file_system', None) - self.key = kwargs.get('key', None) - self.resource_id = kwargs.get('resource_id', None) - self.msi_resource_id = kwargs.get('msi_resource_id', None) - self.saskey = kwargs.get('saskey', None) - self.fileshare = kwargs.get('fileshare', None) - - -class StorageProfile(msrest.serialization.Model): - """The storage profile. - - :param storageaccounts: The list of storage accounts in the cluster. - :type storageaccounts: list[~azure.mgmt.hdinsight.models.StorageAccount] - """ - - _attribute_map = { - 'storageaccounts': {'key': 'storageaccounts', 'type': '[StorageAccount]'}, - } - - def __init__( - self, - **kwargs - ): - super(StorageProfile, self).__init__(**kwargs) - self.storageaccounts = kwargs.get('storageaccounts', None) - - -class SystemData(msrest.serialization.Model): - """Metadata pertaining to creation and last modification of the resource. - - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~azure.mgmt.hdinsight.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or ~azure.mgmt.hdinsight.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - 'created_by': {'key': 'createdBy', 'type': 'str'}, - 'created_by_type': {'key': 'createdByType', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(SystemData, self).__init__(**kwargs) - self.created_by = kwargs.get('created_by', None) - self.created_by_type = kwargs.get('created_by_type', None) - self.created_at = kwargs.get('created_at', None) - self.last_modified_by = kwargs.get('last_modified_by', None) - self.last_modified_by_type = kwargs.get('last_modified_by_type', None) - self.last_modified_at = kwargs.get('last_modified_at', None) - - -class UpdateClusterIdentityCertificateParameters(msrest.serialization.Model): - """The update cluster identity certificate request parameters. - - :param application_id: The application id. - :type application_id: str - :param certificate: The certificate in base64 encoded format. - :type certificate: str - :param certificate_password: The password of the certificate. - :type certificate_password: str - """ - - _attribute_map = { - 'application_id': {'key': 'applicationId', 'type': 'str'}, - 'certificate': {'key': 'certificate', 'type': 'str'}, - 'certificate_password': {'key': 'certificatePassword', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UpdateClusterIdentityCertificateParameters, self).__init__(**kwargs) - self.application_id = kwargs.get('application_id', None) - self.certificate = kwargs.get('certificate', None) - self.certificate_password = kwargs.get('certificate_password', None) - - -class UpdateGatewaySettingsParameters(msrest.serialization.Model): - """The update gateway settings request parameters. - - :param is_credential_enabled: Indicates whether or not the gateway settings based authorization - is enabled. - :type is_credential_enabled: bool - :param user_name: The gateway settings user name. - :type user_name: str - :param password: The gateway settings user password. - :type password: str - """ - - _attribute_map = { - 'is_credential_enabled': {'key': 'restAuthCredential\\.isEnabled', 'type': 'bool'}, - 'user_name': {'key': 'restAuthCredential\\.username', 'type': 'str'}, - 'password': {'key': 'restAuthCredential\\.password', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UpdateGatewaySettingsParameters, self).__init__(**kwargs) - self.is_credential_enabled = kwargs.get('is_credential_enabled', True) - self.user_name = kwargs.get('user_name', None) - self.password = kwargs.get('password', None) - - -class Usage(msrest.serialization.Model): - """The details about the usage of a particular limited resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param unit: The type of measurement for usage. - :type unit: str - :param current_value: The current usage. - :type current_value: long - :param limit: The maximum allowed usage. - :type limit: long - :ivar name: The details about the localizable name of the used resource. - :vartype name: ~azure.mgmt.hdinsight.models.LocalizedName - """ - - _validation = { - 'name': {'readonly': True}, - } - - _attribute_map = { - 'unit': {'key': 'unit', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'long'}, - 'limit': {'key': 'limit', 'type': 'long'}, - 'name': {'key': 'name', 'type': 'LocalizedName'}, - } - - def __init__( - self, - **kwargs - ): - super(Usage, self).__init__(**kwargs) - self.unit = kwargs.get('unit', None) - self.current_value = kwargs.get('current_value', None) - self.limit = kwargs.get('limit', None) - self.name = None - - -class UsagesListResult(msrest.serialization.Model): - """The response for the operation to get regional usages for a subscription. - - :param value: The list of usages. - :type value: list[~azure.mgmt.hdinsight.models.Usage] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Usage]'}, - } - - def __init__( - self, - **kwargs - ): - super(UsagesListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class UserAssignedIdentity(msrest.serialization.Model): - """The User Assigned Identity. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: The principal id of user assigned identity. - :vartype principal_id: str - :ivar client_id: The client id of user assigned identity. - :vartype client_id: str - :param tenant_id: The tenant id of user assigned identity. - :type tenant_id: str - """ - - _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, - } - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UserAssignedIdentity, self).__init__(**kwargs) - self.principal_id = None - self.client_id = None - self.tenant_id = kwargs.get('tenant_id', None) - - -class ValidationErrorInfo(msrest.serialization.Model): - """The validation error information. - - :param code: The error code. - :type code: str - :param message: The error message. - :type message: str - :param error_resource: The error resource. - :type error_resource: str - :param message_arguments: The message arguments. - :type message_arguments: list[str] - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'error_resource': {'key': 'errorResource', 'type': 'str'}, - 'message_arguments': {'key': 'messageArguments', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(ValidationErrorInfo, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - self.error_resource = kwargs.get('error_resource', None) - self.message_arguments = kwargs.get('message_arguments', None) - - -class VersionsCapability(msrest.serialization.Model): - """The version capability. - - :param available: The list of version capabilities. - :type available: list[~azure.mgmt.hdinsight.models.VersionSpec] - """ - - _attribute_map = { - 'available': {'key': 'available', 'type': '[VersionSpec]'}, - } - - def __init__( - self, - **kwargs - ): - super(VersionsCapability, self).__init__(**kwargs) - self.available = kwargs.get('available', None) - - -class VersionSpec(msrest.serialization.Model): - """The version properties. - - :param friendly_name: The friendly name. - :type friendly_name: str - :param display_name: The display name. - :type display_name: str - :param is_default: Whether or not the version is the default version. - :type is_default: bool - :param component_versions: The component version property. - :type component_versions: dict[str, str] - """ - - _attribute_map = { - 'friendly_name': {'key': 'friendlyName', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'is_default': {'key': 'isDefault', 'type': 'bool'}, - 'component_versions': {'key': 'componentVersions', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(VersionSpec, self).__init__(**kwargs) - self.friendly_name = kwargs.get('friendly_name', None) - self.display_name = kwargs.get('display_name', None) - self.is_default = kwargs.get('is_default', None) - self.component_versions = kwargs.get('component_versions', None) - - -class VirtualNetworkProfile(msrest.serialization.Model): - """The virtual network properties. - - :param id: The ID of the virtual network. - :type id: str - :param subnet: The name of the subnet. - :type subnet: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'subnet': {'key': 'subnet', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(VirtualNetworkProfile, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.subnet = kwargs.get('subnet', None) - - -class VmSizeCompatibilityFilterV2(msrest.serialization.Model): - """This class represent a single filter object that defines a multidimensional set. The dimensions of this set are Regions, ClusterFlavors, NodeTypes and ClusterVersions. The constraint should be defined based on the following: FilterMode (Exclude vs Include), VMSizes (the vm sizes in affect of exclusion/inclusion) and the ordering of the Filters. Later filters override previous settings if conflicted. - - :param filter_mode: The filtering mode. Effectively this can enabling or disabling the VM sizes - in a particular set. Possible values include: "Exclude", "Include", "Recommend", "Default". - :type filter_mode: str or ~azure.mgmt.hdinsight.models.FilterMode - :param regions: The list of regions under the effect of the filter. - :type regions: list[str] - :param cluster_flavors: The list of cluster flavors under the effect of the filter. - :type cluster_flavors: list[str] - :param node_types: The list of node types affected by the filter. - :type node_types: list[str] - :param cluster_versions: The list of cluster versions affected in Major.Minor format. - :type cluster_versions: list[str] - :param os_type: The OSType affected, Windows or Linux. - :type os_type: list[str or ~azure.mgmt.hdinsight.models.OSType] - :param vm_sizes: The list of virtual machine sizes to include or exclude. - :type vm_sizes: list[str] - :param esp_applied: Whether apply for ESP cluster. 'true' means only for ESP, 'false' means - only for non-ESP, null or empty string or others mean for both. - :type esp_applied: str - :param compute_isolation_supported: Whether support compute isolation. 'true' means only for - ComputeIsolationEnabled, 'false' means only for regular cluster. - :type compute_isolation_supported: str - """ - - _attribute_map = { - 'filter_mode': {'key': 'filterMode', 'type': 'str'}, - 'regions': {'key': 'regions', 'type': '[str]'}, - 'cluster_flavors': {'key': 'clusterFlavors', 'type': '[str]'}, - 'node_types': {'key': 'nodeTypes', 'type': '[str]'}, - 'cluster_versions': {'key': 'clusterVersions', 'type': '[str]'}, - 'os_type': {'key': 'osType', 'type': '[str]'}, - 'vm_sizes': {'key': 'vmSizes', 'type': '[str]'}, - 'esp_applied': {'key': 'espApplied', 'type': 'str'}, - 'compute_isolation_supported': {'key': 'computeIsolationSupported', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(VmSizeCompatibilityFilterV2, self).__init__(**kwargs) - self.filter_mode = kwargs.get('filter_mode', None) - self.regions = kwargs.get('regions', None) - self.cluster_flavors = kwargs.get('cluster_flavors', None) - self.node_types = kwargs.get('node_types', None) - self.cluster_versions = kwargs.get('cluster_versions', None) - self.os_type = kwargs.get('os_type', None) - self.vm_sizes = kwargs.get('vm_sizes', None) - self.esp_applied = kwargs.get('esp_applied', None) - self.compute_isolation_supported = kwargs.get('compute_isolation_supported', None) - - -class VmSizeProperty(msrest.serialization.Model): - """The vm size property. - - :param name: The vm size name. - :type name: str - :param cores: The number of cores that the vm size has. - :type cores: int - :param data_disk_storage_tier: The data disk storage tier of the vm size. - :type data_disk_storage_tier: str - :param label: The label of the vm size. - :type label: str - :param max_data_disk_count: The max data disk count of the vm size. - :type max_data_disk_count: long - :param memory_in_mb: The memory whose unit is MB of the vm size. - :type memory_in_mb: long - :param supported_by_virtual_machines: This indicates this vm size is supported by virtual - machines or not. - :type supported_by_virtual_machines: bool - :param supported_by_web_worker_roles: The indicates this vm size is supported by web worker - roles or not. - :type supported_by_web_worker_roles: bool - :param virtual_machine_resource_disk_size_in_mb: The virtual machine resource disk size whose - unit is MB of the vm size. - :type virtual_machine_resource_disk_size_in_mb: long - :param web_worker_resource_disk_size_in_mb: The web worker resource disk size whose unit is MB - of the vm size. - :type web_worker_resource_disk_size_in_mb: long - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'cores': {'key': 'cores', 'type': 'int'}, - 'data_disk_storage_tier': {'key': 'dataDiskStorageTier', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'max_data_disk_count': {'key': 'maxDataDiskCount', 'type': 'long'}, - 'memory_in_mb': {'key': 'memoryInMb', 'type': 'long'}, - 'supported_by_virtual_machines': {'key': 'supportedByVirtualMachines', 'type': 'bool'}, - 'supported_by_web_worker_roles': {'key': 'supportedByWebWorkerRoles', 'type': 'bool'}, - 'virtual_machine_resource_disk_size_in_mb': {'key': 'virtualMachineResourceDiskSizeInMb', 'type': 'long'}, - 'web_worker_resource_disk_size_in_mb': {'key': 'webWorkerResourceDiskSizeInMb', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(VmSizeProperty, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.cores = kwargs.get('cores', None) - self.data_disk_storage_tier = kwargs.get('data_disk_storage_tier', None) - self.label = kwargs.get('label', None) - self.max_data_disk_count = kwargs.get('max_data_disk_count', None) - self.memory_in_mb = kwargs.get('memory_in_mb', None) - self.supported_by_virtual_machines = kwargs.get('supported_by_virtual_machines', None) - self.supported_by_web_worker_roles = kwargs.get('supported_by_web_worker_roles', None) - self.virtual_machine_resource_disk_size_in_mb = kwargs.get('virtual_machine_resource_disk_size_in_mb', None) - self.web_worker_resource_disk_size_in_mb = kwargs.get('web_worker_resource_disk_size_in_mb', None) diff --git a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/models/_models_py3.py b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/models/_models_py3.py index 26cf728993f53..cbef6e3e29f1c 100644 --- a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/models/_models_py3.py +++ b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,42 +8,48 @@ # -------------------------------------------------------------------------- import datetime -from typing import Any, Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from .. import _serialization -from ._hd_insight_management_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 AaddsResourceDetails(msrest.serialization.Model): +class AaddsResourceDetails(_serialization.Model): """The Azure active directory domain service resource details. - :param domain_name: The Azure active directory domain service name. - :type domain_name: str - :param initial_sync_complete: This indicates whether initial sync complete or not. - :type initial_sync_complete: bool - :param ldaps_enabled: This indicates whether enable ldaps or not. - :type ldaps_enabled: bool - :param ldaps_public_certificate_in_base64: The base 64 format string of public ldap - certificate. - :type ldaps_public_certificate_in_base64: str - :param resource_id: The resource id of azure active directory domain service. - :type resource_id: str - :param subnet_id: The subnet resource id. - :type subnet_id: str - :param tenant_id: The tenant id of azure active directory domain service . - :type tenant_id: str + :ivar domain_name: The Azure active directory domain service name. + :vartype domain_name: str + :ivar initial_sync_complete: This indicates whether initial sync complete or not. + :vartype initial_sync_complete: bool + :ivar ldaps_enabled: This indicates whether enable ldaps or not. + :vartype ldaps_enabled: bool + :ivar ldaps_public_certificate_in_base64: The base 64 format string of public ldap certificate. + :vartype ldaps_public_certificate_in_base64: str + :ivar resource_id: The resource id of azure active directory domain service. + :vartype resource_id: str + :ivar subnet_id: The subnet resource id. + :vartype subnet_id: str + :ivar tenant_id: The tenant id of azure active directory domain service . + :vartype tenant_id: str """ _attribute_map = { - 'domain_name': {'key': 'domainName', 'type': 'str'}, - 'initial_sync_complete': {'key': 'initialSyncComplete', 'type': 'bool'}, - 'ldaps_enabled': {'key': 'ldapsEnabled', 'type': 'bool'}, - 'ldaps_public_certificate_in_base64': {'key': 'ldapsPublicCertificateInBase64', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'subnet_id': {'key': 'subnetId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + "domain_name": {"key": "domainName", "type": "str"}, + "initial_sync_complete": {"key": "initialSyncComplete", "type": "bool"}, + "ldaps_enabled": {"key": "ldapsEnabled", "type": "bool"}, + "ldaps_public_certificate_in_base64": {"key": "ldapsPublicCertificateInBase64", "type": "str"}, + "resource_id": {"key": "resourceId", "type": "str"}, + "subnet_id": {"key": "subnetId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, } def __init__( @@ -57,7 +64,24 @@ def __init__( tenant_id: Optional[str] = None, **kwargs ): - super(AaddsResourceDetails, self).__init__(**kwargs) + """ + :keyword domain_name: The Azure active directory domain service name. + :paramtype domain_name: str + :keyword initial_sync_complete: This indicates whether initial sync complete or not. + :paramtype initial_sync_complete: bool + :keyword ldaps_enabled: This indicates whether enable ldaps or not. + :paramtype ldaps_enabled: bool + :keyword ldaps_public_certificate_in_base64: The base 64 format string of public ldap + certificate. + :paramtype ldaps_public_certificate_in_base64: str + :keyword resource_id: The resource id of azure active directory domain service. + :paramtype resource_id: str + :keyword subnet_id: The subnet resource id. + :paramtype subnet_id: str + :keyword tenant_id: The tenant id of azure active directory domain service . + :paramtype tenant_id: str + """ + super().__init__(**kwargs) self.domain_name = domain_name self.initial_sync_complete = initial_sync_complete self.ldaps_enabled = ldaps_enabled @@ -67,7 +91,7 @@ def __init__( self.tenant_id = tenant_id -class ResourceAutoGenerated(msrest.serialization.Model): +class Resource(_serialization.Model): """Common fields that are returned in the response for all Azure Resource Manager resources. Variables are only populated by the server, and will be ignored when sending a request. @@ -83,28 +107,26 @@ class ResourceAutoGenerated(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(ResourceAutoGenerated, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None -class ProxyResource(ResourceAutoGenerated): +class ProxyResource(Resource): """The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location. Variables are only populated by the server, and will be ignored when sending a request. @@ -120,22 +142,20 @@ class ProxyResource(ResourceAutoGenerated): """ _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 Application(ProxyResource): @@ -151,31 +171,31 @@ class Application(ProxyResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param etag: The ETag for the application. - :type etag: str - :param tags: A set of tags. The tags for the application. - :type tags: dict[str, str] - :param properties: The properties of the application. - :type properties: ~azure.mgmt.hdinsight.models.ApplicationProperties + :ivar etag: The ETag for the application. + :vartype etag: str + :ivar tags: The tags for the application. + :vartype tags: dict[str, str] + :ivar properties: The properties of the application. + :vartype properties: ~azure.mgmt.hdinsight.models.ApplicationProperties :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.hdinsight.models.SystemData """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'properties': {'key': 'properties', 'type': 'ApplicationProperties'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "properties": {"key": "properties", "type": "ApplicationProperties"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } def __init__( @@ -183,34 +203,42 @@ def __init__( *, etag: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - properties: Optional["ApplicationProperties"] = None, + properties: Optional["_models.ApplicationProperties"] = None, **kwargs ): - super(Application, self).__init__(**kwargs) + """ + :keyword etag: The ETag for the application. + :paramtype etag: str + :keyword tags: The tags for the application. + :paramtype tags: dict[str, str] + :keyword properties: The properties of the application. + :paramtype properties: ~azure.mgmt.hdinsight.models.ApplicationProperties + """ + super().__init__(**kwargs) self.etag = etag self.tags = tags self.properties = properties self.system_data = None -class ApplicationGetEndpoint(msrest.serialization.Model): +class ApplicationGetEndpoint(_serialization.Model): """Gets the application SSH endpoint. - :param location: The location of the endpoint. - :type location: str - :param destination_port: The destination port to connect to. - :type destination_port: int - :param public_port: The public port to connect to. - :type public_port: int - :param private_ip_address: The private ip address of the endpoint. - :type private_ip_address: str + :ivar location: The location of the endpoint. + :vartype location: str + :ivar destination_port: The destination port to connect to. + :vartype destination_port: int + :ivar public_port: The public port to connect to. + :vartype public_port: int + :ivar private_ip_address: The private ip address of the endpoint. + :vartype private_ip_address: str """ _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'destination_port': {'key': 'destinationPort', 'type': 'int'}, - 'public_port': {'key': 'publicPort', 'type': 'int'}, - 'private_ip_address': {'key': 'privateIPAddress', 'type': 'str'}, + "location": {"key": "location", "type": "str"}, + "destination_port": {"key": "destinationPort", "type": "int"}, + "public_port": {"key": "publicPort", "type": "int"}, + "private_ip_address": {"key": "privateIPAddress", "type": "str"}, } def __init__( @@ -222,47 +250,57 @@ def __init__( private_ip_address: Optional[str] = None, **kwargs ): - super(ApplicationGetEndpoint, self).__init__(**kwargs) + """ + :keyword location: The location of the endpoint. + :paramtype location: str + :keyword destination_port: The destination port to connect to. + :paramtype destination_port: int + :keyword public_port: The public port to connect to. + :paramtype public_port: int + :keyword private_ip_address: The private ip address of the endpoint. + :paramtype private_ip_address: str + """ + super().__init__(**kwargs) self.location = location self.destination_port = destination_port self.public_port = public_port self.private_ip_address = private_ip_address -class ApplicationGetHttpsEndpoint(msrest.serialization.Model): +class ApplicationGetHttpsEndpoint(_serialization.Model): """Gets the application HTTP endpoints. Variables are only populated by the server, and will be ignored when sending a request. - :param access_modes: The list of access modes for the application. - :type access_modes: list[str] + :ivar access_modes: The list of access modes for the application. + :vartype access_modes: list[str] :ivar location: The location of the endpoint. :vartype location: str - :param destination_port: The destination port to connect to. - :type destination_port: int + :ivar destination_port: The destination port to connect to. + :vartype destination_port: int :ivar public_port: The public port to connect to. :vartype public_port: int - :param private_ip_address: The private ip address of the endpoint. - :type private_ip_address: str - :param sub_domain_suffix: The subdomain suffix of the application. - :type sub_domain_suffix: str - :param disable_gateway_auth: The value indicates whether to disable GatewayAuth. - :type disable_gateway_auth: bool + :ivar private_ip_address: The private ip address of the endpoint. + :vartype private_ip_address: str + :ivar sub_domain_suffix: The subdomain suffix of the application. + :vartype sub_domain_suffix: str + :ivar disable_gateway_auth: The value indicates whether to disable GatewayAuth. + :vartype disable_gateway_auth: bool """ _validation = { - 'location': {'readonly': True}, - 'public_port': {'readonly': True}, + "location": {"readonly": True}, + "public_port": {"readonly": True}, } _attribute_map = { - 'access_modes': {'key': 'accessModes', 'type': '[str]'}, - 'location': {'key': 'location', 'type': 'str'}, - 'destination_port': {'key': 'destinationPort', 'type': 'int'}, - 'public_port': {'key': 'publicPort', 'type': 'int'}, - 'private_ip_address': {'key': 'privateIPAddress', 'type': 'str'}, - 'sub_domain_suffix': {'key': 'subDomainSuffix', 'type': 'str'}, - 'disable_gateway_auth': {'key': 'disableGatewayAuth', 'type': 'bool'}, + "access_modes": {"key": "accessModes", "type": "[str]"}, + "location": {"key": "location", "type": "str"}, + "destination_port": {"key": "destinationPort", "type": "int"}, + "public_port": {"key": "publicPort", "type": "int"}, + "private_ip_address": {"key": "privateIPAddress", "type": "str"}, + "sub_domain_suffix": {"key": "subDomainSuffix", "type": "str"}, + "disable_gateway_auth": {"key": "disableGatewayAuth", "type": "bool"}, } def __init__( @@ -275,7 +313,19 @@ def __init__( disable_gateway_auth: Optional[bool] = None, **kwargs ): - super(ApplicationGetHttpsEndpoint, self).__init__(**kwargs) + """ + :keyword access_modes: The list of access modes for the application. + :paramtype access_modes: list[str] + :keyword destination_port: The destination port to connect to. + :paramtype destination_port: int + :keyword private_ip_address: The private ip address of the endpoint. + :paramtype private_ip_address: str + :keyword sub_domain_suffix: The subdomain suffix of the application. + :paramtype sub_domain_suffix: str + :keyword disable_gateway_auth: The value indicates whether to disable GatewayAuth. + :paramtype disable_gateway_auth: bool + """ + super().__init__(**kwargs) self.access_modes = access_modes self.location = None self.destination_port = destination_port @@ -285,104 +335,123 @@ def __init__( self.disable_gateway_auth = disable_gateway_auth -class ApplicationListResult(msrest.serialization.Model): +class ApplicationListResult(_serialization.Model): """Result of the request to list cluster Applications. It contains a list of operations and a URL link to get the next set of results. Variables are only populated by the server, and will be ignored when sending a request. - :param value: The list of HDInsight applications installed on HDInsight cluster. - :type value: list[~azure.mgmt.hdinsight.models.Application] + :ivar value: The list of HDInsight applications installed on HDInsight cluster. + :vartype value: list[~azure.mgmt.hdinsight.models.Application] :ivar next_link: The URL to get the next set of operation list results if there are any. :vartype next_link: str """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Application]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Application]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Application"]] = None, - **kwargs - ): - super(ApplicationListResult, self).__init__(**kwargs) + def __init__(self, *, value: Optional[List["_models.Application"]] = None, **kwargs): + """ + :keyword value: The list of HDInsight applications installed on HDInsight cluster. + :paramtype value: list[~azure.mgmt.hdinsight.models.Application] + """ + super().__init__(**kwargs) self.value = value self.next_link = None -class ApplicationProperties(msrest.serialization.Model): +class ApplicationProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes """The HDInsight cluster application GET response. Variables are only populated by the server, and will be ignored when sending a request. - :param compute_profile: The list of roles in the cluster. - :type compute_profile: ~azure.mgmt.hdinsight.models.ComputeProfile - :param install_script_actions: The list of install script actions. - :type install_script_actions: list[~azure.mgmt.hdinsight.models.RuntimeScriptAction] - :param uninstall_script_actions: The list of uninstall script actions. - :type uninstall_script_actions: list[~azure.mgmt.hdinsight.models.RuntimeScriptAction] - :param https_endpoints: The list of application HTTPS endpoints. - :type https_endpoints: list[~azure.mgmt.hdinsight.models.ApplicationGetHttpsEndpoint] - :param ssh_endpoints: The list of application SSH endpoints. - :type ssh_endpoints: list[~azure.mgmt.hdinsight.models.ApplicationGetEndpoint] + :ivar compute_profile: The list of roles in the cluster. + :vartype compute_profile: ~azure.mgmt.hdinsight.models.ComputeProfile + :ivar install_script_actions: The list of install script actions. + :vartype install_script_actions: list[~azure.mgmt.hdinsight.models.RuntimeScriptAction] + :ivar uninstall_script_actions: The list of uninstall script actions. + :vartype uninstall_script_actions: list[~azure.mgmt.hdinsight.models.RuntimeScriptAction] + :ivar https_endpoints: The list of application HTTPS endpoints. + :vartype https_endpoints: list[~azure.mgmt.hdinsight.models.ApplicationGetHttpsEndpoint] + :ivar ssh_endpoints: The list of application SSH endpoints. + :vartype ssh_endpoints: list[~azure.mgmt.hdinsight.models.ApplicationGetEndpoint] :ivar provisioning_state: The provisioning state of the application. :vartype provisioning_state: str - :param application_type: The application type. - :type application_type: str + :ivar application_type: The application type. + :vartype application_type: str :ivar application_state: The application state. :vartype application_state: str - :param errors: The list of errors. - :type errors: list[~azure.mgmt.hdinsight.models.Errors] + :ivar errors: The list of errors. + :vartype errors: list[~azure.mgmt.hdinsight.models.Errors] :ivar created_date: The application create date time. :vartype created_date: str :ivar marketplace_identifier: The marketplace identifier. :vartype marketplace_identifier: str - :param private_link_configurations: The private link configurations. - :type private_link_configurations: list[~azure.mgmt.hdinsight.models.PrivateLinkConfiguration] + :ivar private_link_configurations: The private link configurations. + :vartype private_link_configurations: + list[~azure.mgmt.hdinsight.models.PrivateLinkConfiguration] """ _validation = { - 'provisioning_state': {'readonly': True}, - 'application_state': {'readonly': True}, - 'created_date': {'readonly': True}, - 'marketplace_identifier': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "application_state": {"readonly": True}, + "created_date": {"readonly": True}, + "marketplace_identifier": {"readonly": True}, } _attribute_map = { - 'compute_profile': {'key': 'computeProfile', 'type': 'ComputeProfile'}, - 'install_script_actions': {'key': 'installScriptActions', 'type': '[RuntimeScriptAction]'}, - 'uninstall_script_actions': {'key': 'uninstallScriptActions', 'type': '[RuntimeScriptAction]'}, - 'https_endpoints': {'key': 'httpsEndpoints', 'type': '[ApplicationGetHttpsEndpoint]'}, - 'ssh_endpoints': {'key': 'sshEndpoints', 'type': '[ApplicationGetEndpoint]'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'application_type': {'key': 'applicationType', 'type': 'str'}, - 'application_state': {'key': 'applicationState', 'type': 'str'}, - 'errors': {'key': 'errors', 'type': '[Errors]'}, - 'created_date': {'key': 'createdDate', 'type': 'str'}, - 'marketplace_identifier': {'key': 'marketplaceIdentifier', 'type': 'str'}, - 'private_link_configurations': {'key': 'privateLinkConfigurations', 'type': '[PrivateLinkConfiguration]'}, + "compute_profile": {"key": "computeProfile", "type": "ComputeProfile"}, + "install_script_actions": {"key": "installScriptActions", "type": "[RuntimeScriptAction]"}, + "uninstall_script_actions": {"key": "uninstallScriptActions", "type": "[RuntimeScriptAction]"}, + "https_endpoints": {"key": "httpsEndpoints", "type": "[ApplicationGetHttpsEndpoint]"}, + "ssh_endpoints": {"key": "sshEndpoints", "type": "[ApplicationGetEndpoint]"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "application_type": {"key": "applicationType", "type": "str"}, + "application_state": {"key": "applicationState", "type": "str"}, + "errors": {"key": "errors", "type": "[Errors]"}, + "created_date": {"key": "createdDate", "type": "str"}, + "marketplace_identifier": {"key": "marketplaceIdentifier", "type": "str"}, + "private_link_configurations": {"key": "privateLinkConfigurations", "type": "[PrivateLinkConfiguration]"}, } def __init__( self, *, - compute_profile: Optional["ComputeProfile"] = None, - install_script_actions: Optional[List["RuntimeScriptAction"]] = None, - uninstall_script_actions: Optional[List["RuntimeScriptAction"]] = None, - https_endpoints: Optional[List["ApplicationGetHttpsEndpoint"]] = None, - ssh_endpoints: Optional[List["ApplicationGetEndpoint"]] = None, + compute_profile: Optional["_models.ComputeProfile"] = None, + install_script_actions: Optional[List["_models.RuntimeScriptAction"]] = None, + uninstall_script_actions: Optional[List["_models.RuntimeScriptAction"]] = None, + https_endpoints: Optional[List["_models.ApplicationGetHttpsEndpoint"]] = None, + ssh_endpoints: Optional[List["_models.ApplicationGetEndpoint"]] = None, application_type: Optional[str] = None, - errors: Optional[List["Errors"]] = None, - private_link_configurations: Optional[List["PrivateLinkConfiguration"]] = None, + errors: Optional[List["_models.Errors"]] = None, + private_link_configurations: Optional[List["_models.PrivateLinkConfiguration"]] = None, **kwargs ): - super(ApplicationProperties, self).__init__(**kwargs) + """ + :keyword compute_profile: The list of roles in the cluster. + :paramtype compute_profile: ~azure.mgmt.hdinsight.models.ComputeProfile + :keyword install_script_actions: The list of install script actions. + :paramtype install_script_actions: list[~azure.mgmt.hdinsight.models.RuntimeScriptAction] + :keyword uninstall_script_actions: The list of uninstall script actions. + :paramtype uninstall_script_actions: list[~azure.mgmt.hdinsight.models.RuntimeScriptAction] + :keyword https_endpoints: The list of application HTTPS endpoints. + :paramtype https_endpoints: list[~azure.mgmt.hdinsight.models.ApplicationGetHttpsEndpoint] + :keyword ssh_endpoints: The list of application SSH endpoints. + :paramtype ssh_endpoints: list[~azure.mgmt.hdinsight.models.ApplicationGetEndpoint] + :keyword application_type: The application type. + :paramtype application_type: str + :keyword errors: The list of errors. + :paramtype errors: list[~azure.mgmt.hdinsight.models.Errors] + :keyword private_link_configurations: The private link configurations. + :paramtype private_link_configurations: + list[~azure.mgmt.hdinsight.models.PrivateLinkConfiguration] + """ + super().__init__(**kwargs) self.compute_profile = compute_profile self.install_script_actions = install_script_actions self.uninstall_script_actions = uninstall_script_actions @@ -397,173 +466,193 @@ def __init__( self.private_link_configurations = private_link_configurations -class AsyncOperationResult(msrest.serialization.Model): +class AsyncOperationResult(_serialization.Model): """The azure async operation response. - :param status: The async operation state. Possible values include: "InProgress", "Succeeded", + :ivar status: The async operation state. Known values are: "InProgress", "Succeeded", and "Failed". - :type status: str or ~azure.mgmt.hdinsight.models.AsyncOperationState - :param error: The operation error information. - :type error: ~azure.mgmt.hdinsight.models.Errors + :vartype status: str or ~azure.mgmt.hdinsight.models.AsyncOperationState + :ivar error: The operation error information. + :vartype error: ~azure.mgmt.hdinsight.models.Errors """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'error': {'key': 'error', 'type': 'Errors'}, + "status": {"key": "status", "type": "str"}, + "error": {"key": "error", "type": "Errors"}, } def __init__( self, *, - status: Optional[Union[str, "AsyncOperationState"]] = None, - error: Optional["Errors"] = None, + status: Optional[Union[str, "_models.AsyncOperationState"]] = None, + error: Optional["_models.Errors"] = None, **kwargs ): - super(AsyncOperationResult, self).__init__(**kwargs) + """ + :keyword status: The async operation state. Known values are: "InProgress", "Succeeded", and + "Failed". + :paramtype status: str or ~azure.mgmt.hdinsight.models.AsyncOperationState + :keyword error: The operation error information. + :paramtype error: ~azure.mgmt.hdinsight.models.Errors + """ + super().__init__(**kwargs) self.status = status self.error = error -class Autoscale(msrest.serialization.Model): +class Autoscale(_serialization.Model): """The autoscale request parameters. - :param capacity: Parameters for load-based autoscale. - :type capacity: ~azure.mgmt.hdinsight.models.AutoscaleCapacity - :param recurrence: Parameters for schedule-based autoscale. - :type recurrence: ~azure.mgmt.hdinsight.models.AutoscaleRecurrence + :ivar capacity: Parameters for load-based autoscale. + :vartype capacity: ~azure.mgmt.hdinsight.models.AutoscaleCapacity + :ivar recurrence: Parameters for schedule-based autoscale. + :vartype recurrence: ~azure.mgmt.hdinsight.models.AutoscaleRecurrence """ _attribute_map = { - 'capacity': {'key': 'capacity', 'type': 'AutoscaleCapacity'}, - 'recurrence': {'key': 'recurrence', 'type': 'AutoscaleRecurrence'}, + "capacity": {"key": "capacity", "type": "AutoscaleCapacity"}, + "recurrence": {"key": "recurrence", "type": "AutoscaleRecurrence"}, } def __init__( self, *, - capacity: Optional["AutoscaleCapacity"] = None, - recurrence: Optional["AutoscaleRecurrence"] = None, + capacity: Optional["_models.AutoscaleCapacity"] = None, + recurrence: Optional["_models.AutoscaleRecurrence"] = None, **kwargs ): - super(Autoscale, self).__init__(**kwargs) + """ + :keyword capacity: Parameters for load-based autoscale. + :paramtype capacity: ~azure.mgmt.hdinsight.models.AutoscaleCapacity + :keyword recurrence: Parameters for schedule-based autoscale. + :paramtype recurrence: ~azure.mgmt.hdinsight.models.AutoscaleRecurrence + """ + super().__init__(**kwargs) self.capacity = capacity self.recurrence = recurrence -class AutoscaleCapacity(msrest.serialization.Model): +class AutoscaleCapacity(_serialization.Model): """The load-based autoscale request parameters. - :param min_instance_count: The minimum instance count of the cluster. - :type min_instance_count: int - :param max_instance_count: The maximum instance count of the cluster. - :type max_instance_count: int + :ivar min_instance_count: The minimum instance count of the cluster. + :vartype min_instance_count: int + :ivar max_instance_count: The maximum instance count of the cluster. + :vartype max_instance_count: int """ _attribute_map = { - 'min_instance_count': {'key': 'minInstanceCount', 'type': 'int'}, - 'max_instance_count': {'key': 'maxInstanceCount', 'type': 'int'}, - } - - def __init__( - self, - *, - min_instance_count: Optional[int] = None, - max_instance_count: Optional[int] = None, - **kwargs - ): - super(AutoscaleCapacity, self).__init__(**kwargs) + "min_instance_count": {"key": "minInstanceCount", "type": "int"}, + "max_instance_count": {"key": "maxInstanceCount", "type": "int"}, + } + + def __init__(self, *, min_instance_count: Optional[int] = None, max_instance_count: Optional[int] = None, **kwargs): + """ + :keyword min_instance_count: The minimum instance count of the cluster. + :paramtype min_instance_count: int + :keyword max_instance_count: The maximum instance count of the cluster. + :paramtype max_instance_count: int + """ + super().__init__(**kwargs) self.min_instance_count = min_instance_count self.max_instance_count = max_instance_count -class AutoscaleConfigurationUpdateParameter(msrest.serialization.Model): +class AutoscaleConfigurationUpdateParameter(_serialization.Model): """The autoscale configuration update parameter. - :param autoscale: The autoscale configuration. - :type autoscale: ~azure.mgmt.hdinsight.models.Autoscale + :ivar autoscale: The autoscale configuration. + :vartype autoscale: ~azure.mgmt.hdinsight.models.Autoscale """ _attribute_map = { - 'autoscale': {'key': 'autoscale', 'type': 'Autoscale'}, + "autoscale": {"key": "autoscale", "type": "Autoscale"}, } - def __init__( - self, - *, - autoscale: Optional["Autoscale"] = None, - **kwargs - ): - super(AutoscaleConfigurationUpdateParameter, self).__init__(**kwargs) + def __init__(self, *, autoscale: Optional["_models.Autoscale"] = None, **kwargs): + """ + :keyword autoscale: The autoscale configuration. + :paramtype autoscale: ~azure.mgmt.hdinsight.models.Autoscale + """ + super().__init__(**kwargs) self.autoscale = autoscale -class AutoscaleRecurrence(msrest.serialization.Model): +class AutoscaleRecurrence(_serialization.Model): """Schedule-based autoscale request parameters. - :param time_zone: The time zone for the autoscale schedule times. - :type time_zone: str - :param schedule: Array of schedule-based autoscale rules. - :type schedule: list[~azure.mgmt.hdinsight.models.AutoscaleSchedule] + :ivar time_zone: The time zone for the autoscale schedule times. + :vartype time_zone: str + :ivar schedule: Array of schedule-based autoscale rules. + :vartype schedule: list[~azure.mgmt.hdinsight.models.AutoscaleSchedule] """ _attribute_map = { - 'time_zone': {'key': 'timeZone', 'type': 'str'}, - 'schedule': {'key': 'schedule', 'type': '[AutoscaleSchedule]'}, + "time_zone": {"key": "timeZone", "type": "str"}, + "schedule": {"key": "schedule", "type": "[AutoscaleSchedule]"}, } def __init__( - self, - *, - time_zone: Optional[str] = None, - schedule: Optional[List["AutoscaleSchedule"]] = None, - **kwargs + self, *, time_zone: Optional[str] = None, schedule: Optional[List["_models.AutoscaleSchedule"]] = None, **kwargs ): - super(AutoscaleRecurrence, self).__init__(**kwargs) + """ + :keyword time_zone: The time zone for the autoscale schedule times. + :paramtype time_zone: str + :keyword schedule: Array of schedule-based autoscale rules. + :paramtype schedule: list[~azure.mgmt.hdinsight.models.AutoscaleSchedule] + """ + super().__init__(**kwargs) self.time_zone = time_zone self.schedule = schedule -class AutoscaleSchedule(msrest.serialization.Model): +class AutoscaleSchedule(_serialization.Model): """Parameters for a schedule-based autoscale rule, consisting of an array of days + a time and capacity. - :param days: Days of the week for a schedule-based autoscale rule. - :type days: list[str or ~azure.mgmt.hdinsight.models.DaysOfWeek] - :param time_and_capacity: Time and capacity for a schedule-based autoscale rule. - :type time_and_capacity: ~azure.mgmt.hdinsight.models.AutoscaleTimeAndCapacity + :ivar days: Days of the week for a schedule-based autoscale rule. + :vartype days: list[str or ~azure.mgmt.hdinsight.models.DaysOfWeek] + :ivar time_and_capacity: Time and capacity for a schedule-based autoscale rule. + :vartype time_and_capacity: ~azure.mgmt.hdinsight.models.AutoscaleTimeAndCapacity """ _attribute_map = { - 'days': {'key': 'days', 'type': '[str]'}, - 'time_and_capacity': {'key': 'timeAndCapacity', 'type': 'AutoscaleTimeAndCapacity'}, + "days": {"key": "days", "type": "[str]"}, + "time_and_capacity": {"key": "timeAndCapacity", "type": "AutoscaleTimeAndCapacity"}, } def __init__( self, *, - days: Optional[List[Union[str, "DaysOfWeek"]]] = None, - time_and_capacity: Optional["AutoscaleTimeAndCapacity"] = None, + days: Optional[List[Union[str, "_models.DaysOfWeek"]]] = None, + time_and_capacity: Optional["_models.AutoscaleTimeAndCapacity"] = None, **kwargs ): - super(AutoscaleSchedule, self).__init__(**kwargs) + """ + :keyword days: Days of the week for a schedule-based autoscale rule. + :paramtype days: list[str or ~azure.mgmt.hdinsight.models.DaysOfWeek] + :keyword time_and_capacity: Time and capacity for a schedule-based autoscale rule. + :paramtype time_and_capacity: ~azure.mgmt.hdinsight.models.AutoscaleTimeAndCapacity + """ + super().__init__(**kwargs) self.days = days self.time_and_capacity = time_and_capacity -class AutoscaleTimeAndCapacity(msrest.serialization.Model): +class AutoscaleTimeAndCapacity(_serialization.Model): """Time and capacity request parameters. - :param time: 24-hour time in the form xx:xx. - :type time: str - :param min_instance_count: The minimum instance count of the cluster. - :type min_instance_count: int - :param max_instance_count: The maximum instance count of the cluster. - :type max_instance_count: int + :ivar time: 24-hour time in the form xx:xx. + :vartype time: str + :ivar min_instance_count: The minimum instance count of the cluster. + :vartype min_instance_count: int + :ivar max_instance_count: The maximum instance count of the cluster. + :vartype max_instance_count: int """ _attribute_map = { - 'time': {'key': 'time', 'type': 'str'}, - 'min_instance_count': {'key': 'minInstanceCount', 'type': 'int'}, - 'max_instance_count': {'key': 'maxInstanceCount', 'type': 'int'}, + "time": {"key": "time", "type": "str"}, + "min_instance_count": {"key": "minInstanceCount", "type": "int"}, + "max_instance_count": {"key": "maxInstanceCount", "type": "int"}, } def __init__( @@ -574,27 +663,36 @@ def __init__( max_instance_count: Optional[int] = None, **kwargs ): - super(AutoscaleTimeAndCapacity, self).__init__(**kwargs) + """ + :keyword time: 24-hour time in the form xx:xx. + :paramtype time: str + :keyword min_instance_count: The minimum instance count of the cluster. + :paramtype min_instance_count: int + :keyword max_instance_count: The maximum instance count of the cluster. + :paramtype max_instance_count: int + """ + super().__init__(**kwargs) self.time = time self.min_instance_count = min_instance_count self.max_instance_count = max_instance_count -class AzureMonitorRequest(msrest.serialization.Model): +class AzureMonitorRequest(_serialization.Model): """The azure monitor parameters. - :param workspace_id: The Log Analytics workspace ID. - :type workspace_id: str - :param primary_key: The Log Analytics workspace key. - :type primary_key: str - :param selected_configurations: The selected configurations. - :type selected_configurations: ~azure.mgmt.hdinsight.models.AzureMonitorSelectedConfigurations + :ivar workspace_id: The Log Analytics workspace ID. + :vartype workspace_id: str + :ivar primary_key: The Log Analytics workspace key. + :vartype primary_key: str + :ivar selected_configurations: The selected configurations. + :vartype selected_configurations: + ~azure.mgmt.hdinsight.models.AzureMonitorSelectedConfigurations """ _attribute_map = { - 'workspace_id': {'key': 'workspaceId', 'type': 'str'}, - 'primary_key': {'key': 'primaryKey', 'type': 'str'}, - 'selected_configurations': {'key': 'selectedConfigurations', 'type': 'AzureMonitorSelectedConfigurations'}, + "workspace_id": {"key": "workspaceId", "type": "str"}, + "primary_key": {"key": "primaryKey", "type": "str"}, + "selected_configurations": {"key": "selectedConfigurations", "type": "AzureMonitorSelectedConfigurations"}, } def __init__( @@ -602,30 +700,40 @@ def __init__( *, workspace_id: Optional[str] = None, primary_key: Optional[str] = None, - selected_configurations: Optional["AzureMonitorSelectedConfigurations"] = None, + selected_configurations: Optional["_models.AzureMonitorSelectedConfigurations"] = None, **kwargs ): - super(AzureMonitorRequest, self).__init__(**kwargs) + """ + :keyword workspace_id: The Log Analytics workspace ID. + :paramtype workspace_id: str + :keyword primary_key: The Log Analytics workspace key. + :paramtype primary_key: str + :keyword selected_configurations: The selected configurations. + :paramtype selected_configurations: + ~azure.mgmt.hdinsight.models.AzureMonitorSelectedConfigurations + """ + super().__init__(**kwargs) self.workspace_id = workspace_id self.primary_key = primary_key self.selected_configurations = selected_configurations -class AzureMonitorResponse(msrest.serialization.Model): +class AzureMonitorResponse(_serialization.Model): """The azure monitor status response. - :param cluster_monitoring_enabled: The status of the monitor on the HDInsight cluster. - :type cluster_monitoring_enabled: bool - :param workspace_id: The workspace ID of the monitor on the HDInsight cluster. - :type workspace_id: str - :param selected_configurations: The selected configurations. - :type selected_configurations: ~azure.mgmt.hdinsight.models.AzureMonitorSelectedConfigurations + :ivar cluster_monitoring_enabled: The status of the monitor on the HDInsight cluster. + :vartype cluster_monitoring_enabled: bool + :ivar workspace_id: The workspace ID of the monitor on the HDInsight cluster. + :vartype workspace_id: str + :ivar selected_configurations: The selected configurations. + :vartype selected_configurations: + ~azure.mgmt.hdinsight.models.AzureMonitorSelectedConfigurations """ _attribute_map = { - 'cluster_monitoring_enabled': {'key': 'clusterMonitoringEnabled', 'type': 'bool'}, - 'workspace_id': {'key': 'workspaceId', 'type': 'str'}, - 'selected_configurations': {'key': 'selectedConfigurations', 'type': 'AzureMonitorSelectedConfigurations'}, + "cluster_monitoring_enabled": {"key": "clusterMonitoringEnabled", "type": "bool"}, + "workspace_id": {"key": "workspaceId", "type": "str"}, + "selected_configurations": {"key": "selectedConfigurations", "type": "AzureMonitorSelectedConfigurations"}, } def __init__( @@ -633,30 +741,39 @@ def __init__( *, cluster_monitoring_enabled: Optional[bool] = None, workspace_id: Optional[str] = None, - selected_configurations: Optional["AzureMonitorSelectedConfigurations"] = None, + selected_configurations: Optional["_models.AzureMonitorSelectedConfigurations"] = None, **kwargs ): - super(AzureMonitorResponse, self).__init__(**kwargs) + """ + :keyword cluster_monitoring_enabled: The status of the monitor on the HDInsight cluster. + :paramtype cluster_monitoring_enabled: bool + :keyword workspace_id: The workspace ID of the monitor on the HDInsight cluster. + :paramtype workspace_id: str + :keyword selected_configurations: The selected configurations. + :paramtype selected_configurations: + ~azure.mgmt.hdinsight.models.AzureMonitorSelectedConfigurations + """ + super().__init__(**kwargs) self.cluster_monitoring_enabled = cluster_monitoring_enabled self.workspace_id = workspace_id self.selected_configurations = selected_configurations -class AzureMonitorSelectedConfigurations(msrest.serialization.Model): +class AzureMonitorSelectedConfigurations(_serialization.Model): """The selected configurations for azure monitor. - :param configuration_version: The configuration version. - :type configuration_version: str - :param global_configurations: The global configurations of selected configurations. - :type global_configurations: dict[str, str] - :param table_list: The table list. - :type table_list: list[~azure.mgmt.hdinsight.models.AzureMonitorTableConfiguration] + :ivar configuration_version: The configuration version. + :vartype configuration_version: str + :ivar global_configurations: The global configurations of selected configurations. + :vartype global_configurations: dict[str, str] + :ivar table_list: The table list. + :vartype table_list: list[~azure.mgmt.hdinsight.models.AzureMonitorTableConfiguration] """ _attribute_map = { - 'configuration_version': {'key': 'configurationVersion', 'type': 'str'}, - 'global_configurations': {'key': 'globalConfigurations', 'type': '{str}'}, - 'table_list': {'key': 'tableList', 'type': '[AzureMonitorTableConfiguration]'}, + "configuration_version": {"key": "configurationVersion", "type": "str"}, + "global_configurations": {"key": "globalConfigurations", "type": "{str}"}, + "table_list": {"key": "tableList", "type": "[AzureMonitorTableConfiguration]"}, } def __init__( @@ -664,51 +781,58 @@ def __init__( *, configuration_version: Optional[str] = None, global_configurations: Optional[Dict[str, str]] = None, - table_list: Optional[List["AzureMonitorTableConfiguration"]] = None, + table_list: Optional[List["_models.AzureMonitorTableConfiguration"]] = None, **kwargs ): - super(AzureMonitorSelectedConfigurations, self).__init__(**kwargs) + """ + :keyword configuration_version: The configuration version. + :paramtype configuration_version: str + :keyword global_configurations: The global configurations of selected configurations. + :paramtype global_configurations: dict[str, str] + :keyword table_list: The table list. + :paramtype table_list: list[~azure.mgmt.hdinsight.models.AzureMonitorTableConfiguration] + """ + super().__init__(**kwargs) self.configuration_version = configuration_version self.global_configurations = global_configurations self.table_list = table_list -class AzureMonitorTableConfiguration(msrest.serialization.Model): +class AzureMonitorTableConfiguration(_serialization.Model): """The table configuration for the Log Analytics integration. - :param name: The name. - :type name: str + :ivar name: The name. + :vartype name: str """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - **kwargs - ): - super(AzureMonitorTableConfiguration, self).__init__(**kwargs) + def __init__(self, *, name: Optional[str] = None, **kwargs): + """ + :keyword name: The name. + :paramtype name: str + """ + super().__init__(**kwargs) self.name = name -class BillingMeters(msrest.serialization.Model): +class BillingMeters(_serialization.Model): """The billing meters. - :param meter_parameter: The virtual machine sizes. - :type meter_parameter: str - :param meter: The HDInsight meter guid. - :type meter: str - :param unit: The unit of meter, VMHours or CoreHours. - :type unit: str + :ivar meter_parameter: The virtual machine sizes. + :vartype meter_parameter: str + :ivar meter: The HDInsight meter guid. + :vartype meter: str + :ivar unit: The unit of meter, VMHours or CoreHours. + :vartype unit: str """ _attribute_map = { - 'meter_parameter': {'key': 'meterParameter', 'type': 'str'}, - 'meter': {'key': 'meter', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, + "meter_parameter": {"key": "meterParameter", "type": "str"}, + "meter": {"key": "meter", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, } def __init__( @@ -719,71 +843,87 @@ def __init__( unit: Optional[str] = None, **kwargs ): - super(BillingMeters, self).__init__(**kwargs) + """ + :keyword meter_parameter: The virtual machine sizes. + :paramtype meter_parameter: str + :keyword meter: The HDInsight meter guid. + :paramtype meter: str + :keyword unit: The unit of meter, VMHours or CoreHours. + :paramtype unit: str + """ + super().__init__(**kwargs) self.meter_parameter = meter_parameter self.meter = meter self.unit = unit -class BillingResources(msrest.serialization.Model): +class BillingResources(_serialization.Model): """The billing resources. - :param region: The region or location. - :type region: str - :param billing_meters: The billing meter information. - :type billing_meters: list[~azure.mgmt.hdinsight.models.BillingMeters] - :param disk_billing_meters: The managed disk billing information. - :type disk_billing_meters: list[~azure.mgmt.hdinsight.models.DiskBillingMeters] + :ivar region: The region or location. + :vartype region: str + :ivar billing_meters: The billing meter information. + :vartype billing_meters: list[~azure.mgmt.hdinsight.models.BillingMeters] + :ivar disk_billing_meters: The managed disk billing information. + :vartype disk_billing_meters: list[~azure.mgmt.hdinsight.models.DiskBillingMeters] """ _attribute_map = { - 'region': {'key': 'region', 'type': 'str'}, - 'billing_meters': {'key': 'billingMeters', 'type': '[BillingMeters]'}, - 'disk_billing_meters': {'key': 'diskBillingMeters', 'type': '[DiskBillingMeters]'}, + "region": {"key": "region", "type": "str"}, + "billing_meters": {"key": "billingMeters", "type": "[BillingMeters]"}, + "disk_billing_meters": {"key": "diskBillingMeters", "type": "[DiskBillingMeters]"}, } def __init__( self, *, region: Optional[str] = None, - billing_meters: Optional[List["BillingMeters"]] = None, - disk_billing_meters: Optional[List["DiskBillingMeters"]] = None, + billing_meters: Optional[List["_models.BillingMeters"]] = None, + disk_billing_meters: Optional[List["_models.DiskBillingMeters"]] = None, **kwargs ): - super(BillingResources, self).__init__(**kwargs) + """ + :keyword region: The region or location. + :paramtype region: str + :keyword billing_meters: The billing meter information. + :paramtype billing_meters: list[~azure.mgmt.hdinsight.models.BillingMeters] + :keyword disk_billing_meters: The managed disk billing information. + :paramtype disk_billing_meters: list[~azure.mgmt.hdinsight.models.DiskBillingMeters] + """ + super().__init__(**kwargs) self.region = region self.billing_meters = billing_meters self.disk_billing_meters = disk_billing_meters -class BillingResponseListResult(msrest.serialization.Model): +class BillingResponseListResult(_serialization.Model): """The response for the operation to get regional billingSpecs for a subscription. Variables are only populated by the server, and will be ignored when sending a request. - :param vm_sizes: The virtual machine sizes to include or exclude. - :type vm_sizes: list[str] - :param vm_sizes_with_encryption_at_host: The vm sizes which enable encryption at host. - :type vm_sizes_with_encryption_at_host: list[str] - :param vm_size_filters: The virtual machine filtering mode. Effectively this can enabling or + :ivar vm_sizes: The virtual machine sizes to include or exclude. + :vartype vm_sizes: list[str] + :ivar vm_sizes_with_encryption_at_host: The vm sizes which enable encryption at host. + :vartype vm_sizes_with_encryption_at_host: list[str] + :ivar vm_size_filters: The virtual machine filtering mode. Effectively this can enabling or disabling the virtual machine sizes in a particular set. - :type vm_size_filters: list[~azure.mgmt.hdinsight.models.VmSizeCompatibilityFilterV2] + :vartype vm_size_filters: list[~azure.mgmt.hdinsight.models.VmSizeCompatibilityFilterV2] :ivar vm_size_properties: The vm size properties. :vartype vm_size_properties: list[~azure.mgmt.hdinsight.models.VmSizeProperty] - :param billing_resources: The billing and managed disk billing resources for a region. - :type billing_resources: list[~azure.mgmt.hdinsight.models.BillingResources] + :ivar billing_resources: The billing and managed disk billing resources for a region. + :vartype billing_resources: list[~azure.mgmt.hdinsight.models.BillingResources] """ _validation = { - 'vm_size_properties': {'readonly': True}, + "vm_size_properties": {"readonly": True}, } _attribute_map = { - 'vm_sizes': {'key': 'vmSizes', 'type': '[str]'}, - 'vm_sizes_with_encryption_at_host': {'key': 'vmSizesWithEncryptionAtHost', 'type': '[str]'}, - 'vm_size_filters': {'key': 'vmSizeFilters', 'type': '[VmSizeCompatibilityFilterV2]'}, - 'vm_size_properties': {'key': 'vmSizeProperties', 'type': '[VmSizeProperty]'}, - 'billing_resources': {'key': 'billingResources', 'type': '[BillingResources]'}, + "vm_sizes": {"key": "vmSizes", "type": "[str]"}, + "vm_sizes_with_encryption_at_host": {"key": "vmSizesWithEncryptionAtHost", "type": "[str]"}, + "vm_size_filters": {"key": "vmSizeFilters", "type": "[VmSizeCompatibilityFilterV2]"}, + "vm_size_properties": {"key": "vmSizeProperties", "type": "[VmSizeProperty]"}, + "billing_resources": {"key": "billingResources", "type": "[BillingResources]"}, } def __init__( @@ -791,11 +931,22 @@ def __init__( *, vm_sizes: Optional[List[str]] = None, vm_sizes_with_encryption_at_host: Optional[List[str]] = None, - vm_size_filters: Optional[List["VmSizeCompatibilityFilterV2"]] = None, - billing_resources: Optional[List["BillingResources"]] = None, + vm_size_filters: Optional[List["_models.VmSizeCompatibilityFilterV2"]] = None, + billing_resources: Optional[List["_models.BillingResources"]] = None, **kwargs ): - super(BillingResponseListResult, self).__init__(**kwargs) + """ + :keyword vm_sizes: The virtual machine sizes to include or exclude. + :paramtype vm_sizes: list[str] + :keyword vm_sizes_with_encryption_at_host: The vm sizes which enable encryption at host. + :paramtype vm_sizes_with_encryption_at_host: list[str] + :keyword vm_size_filters: The virtual machine filtering mode. Effectively this can enabling or + disabling the virtual machine sizes in a particular set. + :paramtype vm_size_filters: list[~azure.mgmt.hdinsight.models.VmSizeCompatibilityFilterV2] + :keyword billing_resources: The billing and managed disk billing resources for a region. + :paramtype billing_resources: list[~azure.mgmt.hdinsight.models.BillingResources] + """ + super().__init__(**kwargs) self.vm_sizes = vm_sizes self.vm_sizes_with_encryption_at_host = vm_sizes_with_encryption_at_host self.vm_size_filters = vm_size_filters @@ -803,74 +954,82 @@ def __init__( self.billing_resources = billing_resources -class CapabilitiesResult(msrest.serialization.Model): +class CapabilitiesResult(_serialization.Model): """The Get Capabilities operation response. Variables are only populated by the server, and will be ignored when sending a request. - :param versions: The version capability. - :type versions: dict[str, ~azure.mgmt.hdinsight.models.VersionsCapability] - :param regions: The virtual machine size compatibility features. - :type regions: dict[str, ~azure.mgmt.hdinsight.models.RegionsCapability] - :param features: The capability features. - :type features: list[str] + :ivar versions: The version capability. + :vartype versions: dict[str, ~azure.mgmt.hdinsight.models.VersionsCapability] + :ivar regions: The virtual machine size compatibility features. + :vartype regions: dict[str, ~azure.mgmt.hdinsight.models.RegionsCapability] + :ivar features: The capability features. + :vartype features: list[str] :ivar quota: The quota capability. :vartype quota: ~azure.mgmt.hdinsight.models.QuotaCapability """ _validation = { - 'quota': {'readonly': True}, + "quota": {"readonly": True}, } _attribute_map = { - 'versions': {'key': 'versions', 'type': '{VersionsCapability}'}, - 'regions': {'key': 'regions', 'type': '{RegionsCapability}'}, - 'features': {'key': 'features', 'type': '[str]'}, - 'quota': {'key': 'quota', 'type': 'QuotaCapability'}, + "versions": {"key": "versions", "type": "{VersionsCapability}"}, + "regions": {"key": "regions", "type": "{RegionsCapability}"}, + "features": {"key": "features", "type": "[str]"}, + "quota": {"key": "quota", "type": "QuotaCapability"}, } def __init__( self, *, - versions: Optional[Dict[str, "VersionsCapability"]] = None, - regions: Optional[Dict[str, "RegionsCapability"]] = None, + versions: Optional[Dict[str, "_models.VersionsCapability"]] = None, + regions: Optional[Dict[str, "_models.RegionsCapability"]] = None, features: Optional[List[str]] = None, **kwargs ): - super(CapabilitiesResult, self).__init__(**kwargs) + """ + :keyword versions: The version capability. + :paramtype versions: dict[str, ~azure.mgmt.hdinsight.models.VersionsCapability] + :keyword regions: The virtual machine size compatibility features. + :paramtype regions: dict[str, ~azure.mgmt.hdinsight.models.RegionsCapability] + :keyword features: The capability features. + :paramtype features: list[str] + """ + super().__init__(**kwargs) self.versions = versions self.regions = regions self.features = features self.quota = None -class ClientGroupInfo(msrest.serialization.Model): +class ClientGroupInfo(_serialization.Model): """The information of AAD security group. - :param group_name: The AAD security group name. - :type group_name: str - :param group_id: The AAD security group id. - :type group_id: str + :ivar group_name: The AAD security group name. + :vartype group_name: str + :ivar group_id: The AAD security group id. + :vartype group_id: str """ _attribute_map = { - 'group_name': {'key': 'groupName', 'type': 'str'}, - 'group_id': {'key': 'groupId', 'type': 'str'}, - } - - def __init__( - self, - *, - group_name: Optional[str] = None, - group_id: Optional[str] = None, - **kwargs - ): - super(ClientGroupInfo, self).__init__(**kwargs) + "group_name": {"key": "groupName", "type": "str"}, + "group_id": {"key": "groupId", "type": "str"}, + } + + def __init__(self, *, group_name: Optional[str] = None, group_id: Optional[str] = None, **kwargs): + """ + :keyword group_name: The AAD security group name. + :paramtype group_name: str + :keyword group_id: The AAD security group id. + :paramtype group_id: str + """ + super().__init__(**kwargs) self.group_name = group_name self.group_id = group_id -class Resource(msrest.serialization.Model): +class ResourceAutoGenerated(_serialization.Model): """Common fields that are returned in the response for all Azure Resource Manager resources. Variables are only populated by the server, and will be ignored when sending a request. @@ -886,28 +1045,26 @@ 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 -class TrackedResource(Resource): +class TrackedResource(ResourceAutoGenerated): """The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'. Variables are only populated by the server, and will be ignored when sending a request. @@ -922,35 +1079,35 @@ class TrackedResource(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - } - - def __init__( - self, - *, - location: str, - 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"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + } + + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + """ + super().__init__(**kwargs) self.tags = tags self.location = location @@ -970,41 +1127,41 @@ class Cluster(TrackedResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - :param etag: The ETag for the resource. - :type etag: str - :param zones: The availability zones. - :type zones: list[str] - :param properties: The properties of the cluster. - :type properties: ~azure.mgmt.hdinsight.models.ClusterGetProperties - :param identity: The identity of the cluster, if configured. - :type identity: ~azure.mgmt.hdinsight.models.ClusterIdentity + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar etag: The ETag for the resource. + :vartype etag: str + :ivar zones: The availability zones. + :vartype zones: list[str] + :ivar properties: The properties of the cluster. + :vartype properties: ~azure.mgmt.hdinsight.models.ClusterGetProperties + :ivar identity: The identity of the cluster, if configured. + :vartype identity: ~azure.mgmt.hdinsight.models.ClusterIdentity :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.hdinsight.models.SystemData """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'zones': {'key': 'zones', 'type': '[str]'}, - 'properties': {'key': 'properties', 'type': 'ClusterGetProperties'}, - 'identity': {'key': 'identity', 'type': 'ClusterIdentity'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "zones": {"key": "zones", "type": "[str]"}, + "properties": {"key": "properties", "type": "ClusterGetProperties"}, + "identity": {"key": "identity", "type": "ClusterIdentity"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } def __init__( @@ -1014,11 +1171,25 @@ def __init__( tags: Optional[Dict[str, str]] = None, etag: Optional[str] = None, zones: Optional[List[str]] = None, - properties: Optional["ClusterGetProperties"] = None, - identity: Optional["ClusterIdentity"] = None, + properties: Optional["_models.ClusterGetProperties"] = None, + identity: Optional["_models.ClusterIdentity"] = None, **kwargs ): - super(Cluster, self).__init__(tags=tags, location=location, **kwargs) + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword etag: The ETag for the resource. + :paramtype etag: str + :keyword zones: The availability zones. + :paramtype zones: list[str] + :keyword properties: The properties of the cluster. + :paramtype properties: ~azure.mgmt.hdinsight.models.ClusterGetProperties + :keyword identity: The identity of the cluster, if configured. + :paramtype identity: ~azure.mgmt.hdinsight.models.ClusterIdentity + """ + super().__init__(tags=tags, location=location, **kwargs) self.etag = etag self.zones = zones self.properties = properties @@ -1026,49 +1197,49 @@ def __init__( self.system_data = None -class ClusterConfigurations(msrest.serialization.Model): +class ClusterConfigurations(_serialization.Model): """The configuration object for the specified cluster. - :param configurations: The configuration object for the specified configuration for the + :ivar configurations: The configuration object for the specified configuration for the specified cluster. - :type configurations: dict[str, dict[str, str]] + :vartype configurations: dict[str, dict[str, str]] """ _attribute_map = { - 'configurations': {'key': 'configurations', 'type': '{{str}}'}, + "configurations": {"key": "configurations", "type": "{{str}}"}, } - def __init__( - self, - *, - configurations: Optional[Dict[str, Dict[str, str]]] = None, - **kwargs - ): - super(ClusterConfigurations, self).__init__(**kwargs) + def __init__(self, *, configurations: Optional[Dict[str, Dict[str, str]]] = None, **kwargs): + """ + :keyword configurations: The configuration object for the specified configuration for the + specified cluster. + :paramtype configurations: dict[str, dict[str, str]] + """ + super().__init__(**kwargs) self.configurations = configurations -class ClusterCreateParametersExtended(msrest.serialization.Model): +class ClusterCreateParametersExtended(_serialization.Model): """The CreateCluster request parameters. - :param location: The location of the cluster. - :type location: str - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] - :param zones: The availability zones. - :type zones: list[str] - :param properties: The cluster create parameters. - :type properties: ~azure.mgmt.hdinsight.models.ClusterCreateProperties - :param identity: The identity of the cluster, if configured. - :type identity: ~azure.mgmt.hdinsight.models.ClusterIdentity + :ivar location: The location of the cluster. + :vartype location: str + :ivar tags: The resource tags. + :vartype tags: dict[str, str] + :ivar zones: The availability zones. + :vartype zones: list[str] + :ivar properties: The cluster create parameters. + :vartype properties: ~azure.mgmt.hdinsight.models.ClusterCreateProperties + :ivar identity: The identity of the cluster, if configured. + :vartype identity: ~azure.mgmt.hdinsight.models.ClusterIdentity """ _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'zones': {'key': 'zones', 'type': '[str]'}, - 'properties': {'key': 'properties', 'type': 'ClusterCreateProperties'}, - 'identity': {'key': 'identity', 'type': 'ClusterIdentity'}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "zones": {"key": "zones", "type": "[str]"}, + "properties": {"key": "properties", "type": "ClusterCreateProperties"}, + "identity": {"key": "identity", "type": "ClusterIdentity"}, } def __init__( @@ -1077,11 +1248,23 @@ def __init__( location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, zones: Optional[List[str]] = None, - properties: Optional["ClusterCreateProperties"] = None, - identity: Optional["ClusterIdentity"] = None, + properties: Optional["_models.ClusterCreateProperties"] = None, + identity: Optional["_models.ClusterIdentity"] = None, **kwargs ): - super(ClusterCreateParametersExtended, self).__init__(**kwargs) + """ + :keyword location: The location of the cluster. + :paramtype location: str + :keyword tags: The resource tags. + :paramtype tags: dict[str, str] + :keyword zones: The availability zones. + :paramtype zones: list[str] + :keyword properties: The cluster create parameters. + :paramtype properties: ~azure.mgmt.hdinsight.models.ClusterCreateProperties + :keyword identity: The identity of the cluster, if configured. + :paramtype identity: ~azure.mgmt.hdinsight.models.ClusterIdentity + """ + super().__init__(**kwargs) self.location = location self.tags = tags self.zones = zones @@ -1089,77 +1272,114 @@ def __init__( self.identity = identity -class ClusterCreateProperties(msrest.serialization.Model): +class ClusterCreateProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes """The cluster create parameters. - :param cluster_version: The version of the cluster. - :type cluster_version: str - :param os_type: The type of operating system. Possible values include: "Windows", "Linux". - :type os_type: str or ~azure.mgmt.hdinsight.models.OSType - :param tier: The cluster tier. Possible values include: "Standard", "Premium". - :type tier: str or ~azure.mgmt.hdinsight.models.Tier - :param cluster_definition: The cluster definition. - :type cluster_definition: ~azure.mgmt.hdinsight.models.ClusterDefinition - :param kafka_rest_properties: The cluster kafka rest proxy configuration. - :type kafka_rest_properties: ~azure.mgmt.hdinsight.models.KafkaRestProperties - :param security_profile: The security profile. - :type security_profile: ~azure.mgmt.hdinsight.models.SecurityProfile - :param compute_profile: The compute profile. - :type compute_profile: ~azure.mgmt.hdinsight.models.ComputeProfile - :param storage_profile: The storage profile. - :type storage_profile: ~azure.mgmt.hdinsight.models.StorageProfile - :param disk_encryption_properties: The disk encryption properties. - :type disk_encryption_properties: ~azure.mgmt.hdinsight.models.DiskEncryptionProperties - :param encryption_in_transit_properties: The encryption-in-transit properties. - :type encryption_in_transit_properties: + :ivar cluster_version: The version of the cluster. + :vartype cluster_version: str + :ivar os_type: The type of operating system. Known values are: "Windows" and "Linux". + :vartype os_type: str or ~azure.mgmt.hdinsight.models.OSType + :ivar tier: The cluster tier. Known values are: "Standard" and "Premium". + :vartype tier: str or ~azure.mgmt.hdinsight.models.Tier + :ivar cluster_definition: The cluster definition. + :vartype cluster_definition: ~azure.mgmt.hdinsight.models.ClusterDefinition + :ivar kafka_rest_properties: The cluster kafka rest proxy configuration. + :vartype kafka_rest_properties: ~azure.mgmt.hdinsight.models.KafkaRestProperties + :ivar security_profile: The security profile. + :vartype security_profile: ~azure.mgmt.hdinsight.models.SecurityProfile + :ivar compute_profile: The compute profile. + :vartype compute_profile: ~azure.mgmt.hdinsight.models.ComputeProfile + :ivar storage_profile: The storage profile. + :vartype storage_profile: ~azure.mgmt.hdinsight.models.StorageProfile + :ivar disk_encryption_properties: The disk encryption properties. + :vartype disk_encryption_properties: ~azure.mgmt.hdinsight.models.DiskEncryptionProperties + :ivar encryption_in_transit_properties: The encryption-in-transit properties. + :vartype encryption_in_transit_properties: ~azure.mgmt.hdinsight.models.EncryptionInTransitProperties - :param min_supported_tls_version: The minimal supported tls version. - :type min_supported_tls_version: str - :param network_properties: The network properties. - :type network_properties: ~azure.mgmt.hdinsight.models.NetworkProperties - :param compute_isolation_properties: The compute isolation properties. - :type compute_isolation_properties: ~azure.mgmt.hdinsight.models.ComputeIsolationProperties - :param private_link_configurations: The private link configurations. - :type private_link_configurations: list[~azure.mgmt.hdinsight.models.PrivateLinkConfiguration] + :ivar min_supported_tls_version: The minimal supported tls version. + :vartype min_supported_tls_version: str + :ivar network_properties: The network properties. + :vartype network_properties: ~azure.mgmt.hdinsight.models.NetworkProperties + :ivar compute_isolation_properties: The compute isolation properties. + :vartype compute_isolation_properties: ~azure.mgmt.hdinsight.models.ComputeIsolationProperties + :ivar private_link_configurations: The private link configurations. + :vartype private_link_configurations: + list[~azure.mgmt.hdinsight.models.PrivateLinkConfiguration] """ _attribute_map = { - 'cluster_version': {'key': 'clusterVersion', 'type': 'str'}, - 'os_type': {'key': 'osType', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'cluster_definition': {'key': 'clusterDefinition', 'type': 'ClusterDefinition'}, - 'kafka_rest_properties': {'key': 'kafkaRestProperties', 'type': 'KafkaRestProperties'}, - 'security_profile': {'key': 'securityProfile', 'type': 'SecurityProfile'}, - 'compute_profile': {'key': 'computeProfile', 'type': 'ComputeProfile'}, - 'storage_profile': {'key': 'storageProfile', 'type': 'StorageProfile'}, - 'disk_encryption_properties': {'key': 'diskEncryptionProperties', 'type': 'DiskEncryptionProperties'}, - 'encryption_in_transit_properties': {'key': 'encryptionInTransitProperties', 'type': 'EncryptionInTransitProperties'}, - 'min_supported_tls_version': {'key': 'minSupportedTlsVersion', 'type': 'str'}, - 'network_properties': {'key': 'networkProperties', 'type': 'NetworkProperties'}, - 'compute_isolation_properties': {'key': 'computeIsolationProperties', 'type': 'ComputeIsolationProperties'}, - 'private_link_configurations': {'key': 'privateLinkConfigurations', 'type': '[PrivateLinkConfiguration]'}, + "cluster_version": {"key": "clusterVersion", "type": "str"}, + "os_type": {"key": "osType", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "cluster_definition": {"key": "clusterDefinition", "type": "ClusterDefinition"}, + "kafka_rest_properties": {"key": "kafkaRestProperties", "type": "KafkaRestProperties"}, + "security_profile": {"key": "securityProfile", "type": "SecurityProfile"}, + "compute_profile": {"key": "computeProfile", "type": "ComputeProfile"}, + "storage_profile": {"key": "storageProfile", "type": "StorageProfile"}, + "disk_encryption_properties": {"key": "diskEncryptionProperties", "type": "DiskEncryptionProperties"}, + "encryption_in_transit_properties": { + "key": "encryptionInTransitProperties", + "type": "EncryptionInTransitProperties", + }, + "min_supported_tls_version": {"key": "minSupportedTlsVersion", "type": "str"}, + "network_properties": {"key": "networkProperties", "type": "NetworkProperties"}, + "compute_isolation_properties": {"key": "computeIsolationProperties", "type": "ComputeIsolationProperties"}, + "private_link_configurations": {"key": "privateLinkConfigurations", "type": "[PrivateLinkConfiguration]"}, } def __init__( self, *, cluster_version: Optional[str] = None, - os_type: Optional[Union[str, "OSType"]] = None, - tier: Optional[Union[str, "Tier"]] = None, - cluster_definition: Optional["ClusterDefinition"] = None, - kafka_rest_properties: Optional["KafkaRestProperties"] = None, - security_profile: Optional["SecurityProfile"] = None, - compute_profile: Optional["ComputeProfile"] = None, - storage_profile: Optional["StorageProfile"] = None, - disk_encryption_properties: Optional["DiskEncryptionProperties"] = None, - encryption_in_transit_properties: Optional["EncryptionInTransitProperties"] = None, + os_type: Optional[Union[str, "_models.OSType"]] = None, + tier: Optional[Union[str, "_models.Tier"]] = None, + cluster_definition: Optional["_models.ClusterDefinition"] = None, + kafka_rest_properties: Optional["_models.KafkaRestProperties"] = None, + security_profile: Optional["_models.SecurityProfile"] = None, + compute_profile: Optional["_models.ComputeProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + disk_encryption_properties: Optional["_models.DiskEncryptionProperties"] = None, + encryption_in_transit_properties: Optional["_models.EncryptionInTransitProperties"] = None, min_supported_tls_version: Optional[str] = None, - network_properties: Optional["NetworkProperties"] = None, - compute_isolation_properties: Optional["ComputeIsolationProperties"] = None, - private_link_configurations: Optional[List["PrivateLinkConfiguration"]] = None, + network_properties: Optional["_models.NetworkProperties"] = None, + compute_isolation_properties: Optional["_models.ComputeIsolationProperties"] = None, + private_link_configurations: Optional[List["_models.PrivateLinkConfiguration"]] = None, **kwargs ): - super(ClusterCreateProperties, self).__init__(**kwargs) + """ + :keyword cluster_version: The version of the cluster. + :paramtype cluster_version: str + :keyword os_type: The type of operating system. Known values are: "Windows" and "Linux". + :paramtype os_type: str or ~azure.mgmt.hdinsight.models.OSType + :keyword tier: The cluster tier. Known values are: "Standard" and "Premium". + :paramtype tier: str or ~azure.mgmt.hdinsight.models.Tier + :keyword cluster_definition: The cluster definition. + :paramtype cluster_definition: ~azure.mgmt.hdinsight.models.ClusterDefinition + :keyword kafka_rest_properties: The cluster kafka rest proxy configuration. + :paramtype kafka_rest_properties: ~azure.mgmt.hdinsight.models.KafkaRestProperties + :keyword security_profile: The security profile. + :paramtype security_profile: ~azure.mgmt.hdinsight.models.SecurityProfile + :keyword compute_profile: The compute profile. + :paramtype compute_profile: ~azure.mgmt.hdinsight.models.ComputeProfile + :keyword storage_profile: The storage profile. + :paramtype storage_profile: ~azure.mgmt.hdinsight.models.StorageProfile + :keyword disk_encryption_properties: The disk encryption properties. + :paramtype disk_encryption_properties: ~azure.mgmt.hdinsight.models.DiskEncryptionProperties + :keyword encryption_in_transit_properties: The encryption-in-transit properties. + :paramtype encryption_in_transit_properties: + ~azure.mgmt.hdinsight.models.EncryptionInTransitProperties + :keyword min_supported_tls_version: The minimal supported tls version. + :paramtype min_supported_tls_version: str + :keyword network_properties: The network properties. + :paramtype network_properties: ~azure.mgmt.hdinsight.models.NetworkProperties + :keyword compute_isolation_properties: The compute isolation properties. + :paramtype compute_isolation_properties: + ~azure.mgmt.hdinsight.models.ComputeIsolationProperties + :keyword private_link_configurations: The private link configurations. + :paramtype private_link_configurations: + list[~azure.mgmt.hdinsight.models.PrivateLinkConfiguration] + """ + super().__init__(**kwargs) self.cluster_version = cluster_version self.os_type = os_type self.tier = tier @@ -1179,36 +1399,36 @@ def __init__( class ClusterCreateRequestValidationParameters(ClusterCreateParametersExtended): """The cluster create request specification. - :param location: The location of the cluster. - :type location: str - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] - :param zones: The availability zones. - :type zones: list[str] - :param properties: The cluster create parameters. - :type properties: ~azure.mgmt.hdinsight.models.ClusterCreateProperties - :param identity: The identity of the cluster, if configured. - :type identity: ~azure.mgmt.hdinsight.models.ClusterIdentity - :param name: The cluster name. - :type name: str - :param type: The resource type. - :type type: str - :param tenant_id: The tenant id. - :type tenant_id: str - :param fetch_aadds_resource: This indicates whether fetch Aadds resource or not. - :type fetch_aadds_resource: bool + :ivar location: The location of the cluster. + :vartype location: str + :ivar tags: The resource tags. + :vartype tags: dict[str, str] + :ivar zones: The availability zones. + :vartype zones: list[str] + :ivar properties: The cluster create parameters. + :vartype properties: ~azure.mgmt.hdinsight.models.ClusterCreateProperties + :ivar identity: The identity of the cluster, if configured. + :vartype identity: ~azure.mgmt.hdinsight.models.ClusterIdentity + :ivar name: The cluster name. + :vartype name: str + :ivar type: The resource type. + :vartype type: str + :ivar tenant_id: The tenant id. + :vartype tenant_id: str + :ivar fetch_aadds_resource: This indicates whether fetch Aadds resource or not. + :vartype fetch_aadds_resource: bool """ _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'zones': {'key': 'zones', 'type': '[str]'}, - 'properties': {'key': 'properties', 'type': 'ClusterCreateProperties'}, - 'identity': {'key': 'identity', 'type': 'ClusterIdentity'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'fetch_aadds_resource': {'key': 'fetchAaddsResource', 'type': 'bool'}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "zones": {"key": "zones", "type": "[str]"}, + "properties": {"key": "properties", "type": "ClusterCreateProperties"}, + "identity": {"key": "identity", "type": "ClusterIdentity"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "fetch_aadds_resource": {"key": "fetchAaddsResource", "type": "bool"}, } def __init__( @@ -1217,75 +1437,105 @@ def __init__( location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, zones: Optional[List[str]] = None, - properties: Optional["ClusterCreateProperties"] = None, - identity: Optional["ClusterIdentity"] = None, + properties: Optional["_models.ClusterCreateProperties"] = None, + identity: Optional["_models.ClusterIdentity"] = None, name: Optional[str] = None, type: Optional[str] = None, tenant_id: Optional[str] = None, fetch_aadds_resource: Optional[bool] = None, **kwargs ): - super(ClusterCreateRequestValidationParameters, self).__init__(location=location, tags=tags, zones=zones, properties=properties, identity=identity, **kwargs) + """ + :keyword location: The location of the cluster. + :paramtype location: str + :keyword tags: The resource tags. + :paramtype tags: dict[str, str] + :keyword zones: The availability zones. + :paramtype zones: list[str] + :keyword properties: The cluster create parameters. + :paramtype properties: ~azure.mgmt.hdinsight.models.ClusterCreateProperties + :keyword identity: The identity of the cluster, if configured. + :paramtype identity: ~azure.mgmt.hdinsight.models.ClusterIdentity + :keyword name: The cluster name. + :paramtype name: str + :keyword type: The resource type. + :paramtype type: str + :keyword tenant_id: The tenant id. + :paramtype tenant_id: str + :keyword fetch_aadds_resource: This indicates whether fetch Aadds resource or not. + :paramtype fetch_aadds_resource: bool + """ + super().__init__(location=location, tags=tags, zones=zones, properties=properties, identity=identity, **kwargs) self.name = name self.type = type self.tenant_id = tenant_id self.fetch_aadds_resource = fetch_aadds_resource -class ClusterCreateValidationResult(msrest.serialization.Model): +class ClusterCreateValidationResult(_serialization.Model): """The response of cluster create request validation. - :param validation_errors: The validation errors. - :type validation_errors: list[~azure.mgmt.hdinsight.models.ValidationErrorInfo] - :param validation_warnings: The validation warnings. - :type validation_warnings: list[~azure.mgmt.hdinsight.models.ValidationErrorInfo] - :param estimated_creation_duration: The estimated creation duration. - :type estimated_creation_duration: ~datetime.timedelta - :param aadds_resources_details: The Azure active directory domain service resource details. - :type aadds_resources_details: list[~azure.mgmt.hdinsight.models.AaddsResourceDetails] + :ivar validation_errors: The validation errors. + :vartype validation_errors: list[~azure.mgmt.hdinsight.models.ValidationErrorInfo] + :ivar validation_warnings: The validation warnings. + :vartype validation_warnings: list[~azure.mgmt.hdinsight.models.ValidationErrorInfo] + :ivar estimated_creation_duration: The estimated creation duration. + :vartype estimated_creation_duration: ~datetime.timedelta + :ivar aadds_resources_details: The Azure active directory domain service resource details. + :vartype aadds_resources_details: list[~azure.mgmt.hdinsight.models.AaddsResourceDetails] """ _attribute_map = { - 'validation_errors': {'key': 'validationErrors', 'type': '[ValidationErrorInfo]'}, - 'validation_warnings': {'key': 'validationWarnings', 'type': '[ValidationErrorInfo]'}, - 'estimated_creation_duration': {'key': 'estimatedCreationDuration', 'type': 'duration'}, - 'aadds_resources_details': {'key': 'aaddsResourcesDetails', 'type': '[AaddsResourceDetails]'}, + "validation_errors": {"key": "validationErrors", "type": "[ValidationErrorInfo]"}, + "validation_warnings": {"key": "validationWarnings", "type": "[ValidationErrorInfo]"}, + "estimated_creation_duration": {"key": "estimatedCreationDuration", "type": "duration"}, + "aadds_resources_details": {"key": "aaddsResourcesDetails", "type": "[AaddsResourceDetails]"}, } def __init__( self, *, - validation_errors: Optional[List["ValidationErrorInfo"]] = None, - validation_warnings: Optional[List["ValidationErrorInfo"]] = None, + validation_errors: Optional[List["_models.ValidationErrorInfo"]] = None, + validation_warnings: Optional[List["_models.ValidationErrorInfo"]] = None, estimated_creation_duration: Optional[datetime.timedelta] = None, - aadds_resources_details: Optional[List["AaddsResourceDetails"]] = None, + aadds_resources_details: Optional[List["_models.AaddsResourceDetails"]] = None, **kwargs ): - super(ClusterCreateValidationResult, self).__init__(**kwargs) + """ + :keyword validation_errors: The validation errors. + :paramtype validation_errors: list[~azure.mgmt.hdinsight.models.ValidationErrorInfo] + :keyword validation_warnings: The validation warnings. + :paramtype validation_warnings: list[~azure.mgmt.hdinsight.models.ValidationErrorInfo] + :keyword estimated_creation_duration: The estimated creation duration. + :paramtype estimated_creation_duration: ~datetime.timedelta + :keyword aadds_resources_details: The Azure active directory domain service resource details. + :paramtype aadds_resources_details: list[~azure.mgmt.hdinsight.models.AaddsResourceDetails] + """ + super().__init__(**kwargs) self.validation_errors = validation_errors self.validation_warnings = validation_warnings self.estimated_creation_duration = estimated_creation_duration self.aadds_resources_details = aadds_resources_details -class ClusterDefinition(msrest.serialization.Model): +class ClusterDefinition(_serialization.Model): """The cluster definition. - :param blueprint: The link to the blueprint. - :type blueprint: str - :param kind: The type of cluster. - :type kind: str - :param component_version: The versions of different services in the cluster. - :type component_version: dict[str, str] - :param configurations: The cluster configurations. - :type configurations: any + :ivar blueprint: The link to the blueprint. + :vartype blueprint: str + :ivar kind: The type of cluster. + :vartype kind: str + :ivar component_version: The versions of different services in the cluster. + :vartype component_version: dict[str, str] + :ivar configurations: The cluster configurations. + :vartype configurations: JSON """ _attribute_map = { - 'blueprint': {'key': 'blueprint', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'component_version': {'key': 'componentVersion', 'type': '{str}'}, - 'configurations': {'key': 'configurations', 'type': 'object'}, + "blueprint": {"key": "blueprint", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "component_version": {"key": "componentVersion", "type": "{str}"}, + "configurations": {"key": "configurations", "type": "object"}, } def __init__( @@ -1294,32 +1544,42 @@ def __init__( blueprint: Optional[str] = None, kind: Optional[str] = None, component_version: Optional[Dict[str, str]] = None, - configurations: Optional[Any] = None, + configurations: Optional[JSON] = None, **kwargs ): - super(ClusterDefinition, self).__init__(**kwargs) + """ + :keyword blueprint: The link to the blueprint. + :paramtype blueprint: str + :keyword kind: The type of cluster. + :paramtype kind: str + :keyword component_version: The versions of different services in the cluster. + :paramtype component_version: dict[str, str] + :keyword configurations: The cluster configurations. + :paramtype configurations: JSON + """ + super().__init__(**kwargs) self.blueprint = blueprint self.kind = kind self.component_version = component_version self.configurations = configurations -class ClusterDiskEncryptionParameters(msrest.serialization.Model): +class ClusterDiskEncryptionParameters(_serialization.Model): """The Disk Encryption Cluster request parameters. - :param vault_uri: Base key vault URI where the customers key is located eg. + :ivar vault_uri: Base key vault URI where the customers key is located eg. https://myvault.vault.azure.net. - :type vault_uri: str - :param key_name: Key name that is used for enabling disk encryption. - :type key_name: str - :param key_version: Specific key version that is used for enabling disk encryption. - :type key_version: str + :vartype vault_uri: str + :ivar key_name: Key name that is used for enabling disk encryption. + :vartype key_name: str + :ivar key_version: Specific key version that is used for enabling disk encryption. + :vartype key_version: str """ _attribute_map = { - 'vault_uri': {'key': 'vaultUri', 'type': 'str'}, - 'key_name': {'key': 'keyName', 'type': 'str'}, - 'key_version': {'key': 'keyVersion', 'type': 'str'}, + "vault_uri": {"key": "vaultUri", "type": "str"}, + "key_name": {"key": "keyName", "type": "str"}, + "key_version": {"key": "keyVersion", "type": "str"}, } def __init__( @@ -1330,133 +1590,200 @@ def __init__( key_version: Optional[str] = None, **kwargs ): - super(ClusterDiskEncryptionParameters, self).__init__(**kwargs) + """ + :keyword vault_uri: Base key vault URI where the customers key is located eg. + https://myvault.vault.azure.net. + :paramtype vault_uri: str + :keyword key_name: Key name that is used for enabling disk encryption. + :paramtype key_name: str + :keyword key_version: Specific key version that is used for enabling disk encryption. + :paramtype key_version: str + """ + super().__init__(**kwargs) self.vault_uri = vault_uri self.key_name = key_name self.key_version = key_version -class ClusterGetProperties(msrest.serialization.Model): +class ClusterGetProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes """The properties of cluster. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :param cluster_version: The version of the cluster. - :type cluster_version: str - :param cluster_hdp_version: The hdp version of the cluster. - :type cluster_hdp_version: str - :param os_type: The type of operating system. Possible values include: "Windows", "Linux". - :type os_type: str or ~azure.mgmt.hdinsight.models.OSType - :param tier: The cluster tier. Possible values include: "Standard", "Premium". - :type tier: str or ~azure.mgmt.hdinsight.models.Tier - :param cluster_id: The cluster id. - :type cluster_id: str - :param cluster_definition: Required. The cluster definition. - :type cluster_definition: ~azure.mgmt.hdinsight.models.ClusterDefinition - :param kafka_rest_properties: The cluster kafka rest proxy configuration. - :type kafka_rest_properties: ~azure.mgmt.hdinsight.models.KafkaRestProperties - :param security_profile: The security profile. - :type security_profile: ~azure.mgmt.hdinsight.models.SecurityProfile - :param compute_profile: The compute profile. - :type compute_profile: ~azure.mgmt.hdinsight.models.ComputeProfile - :param provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "InProgress", "Failed", "Succeeded", "Canceled", "Deleting". - :type provisioning_state: str or ~azure.mgmt.hdinsight.models.HDInsightClusterProvisioningState - :param created_date: The date on which the cluster was created. - :type created_date: str - :param cluster_state: The state of the cluster. - :type cluster_state: str - :param quota_info: The quota information. - :type quota_info: ~azure.mgmt.hdinsight.models.QuotaInfo - :param errors: The list of errors. - :type errors: list[~azure.mgmt.hdinsight.models.Errors] - :param connectivity_endpoints: The list of connectivity endpoints. - :type connectivity_endpoints: list[~azure.mgmt.hdinsight.models.ConnectivityEndpoint] - :param disk_encryption_properties: The disk encryption properties. - :type disk_encryption_properties: ~azure.mgmt.hdinsight.models.DiskEncryptionProperties - :param encryption_in_transit_properties: The encryption-in-transit properties. - :type encryption_in_transit_properties: + :ivar cluster_version: The version of the cluster. + :vartype cluster_version: str + :ivar cluster_hdp_version: The hdp version of the cluster. + :vartype cluster_hdp_version: str + :ivar os_type: The type of operating system. Known values are: "Windows" and "Linux". + :vartype os_type: str or ~azure.mgmt.hdinsight.models.OSType + :ivar tier: The cluster tier. Known values are: "Standard" and "Premium". + :vartype tier: str or ~azure.mgmt.hdinsight.models.Tier + :ivar cluster_id: The cluster id. + :vartype cluster_id: str + :ivar cluster_definition: The cluster definition. Required. + :vartype cluster_definition: ~azure.mgmt.hdinsight.models.ClusterDefinition + :ivar kafka_rest_properties: The cluster kafka rest proxy configuration. + :vartype kafka_rest_properties: ~azure.mgmt.hdinsight.models.KafkaRestProperties + :ivar security_profile: The security profile. + :vartype security_profile: ~azure.mgmt.hdinsight.models.SecurityProfile + :ivar compute_profile: The compute profile. + :vartype compute_profile: ~azure.mgmt.hdinsight.models.ComputeProfile + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "InProgress", "Failed", "Succeeded", "Canceled", and "Deleting". + :vartype provisioning_state: str or + ~azure.mgmt.hdinsight.models.HDInsightClusterProvisioningState + :ivar created_date: The date on which the cluster was created. + :vartype created_date: str + :ivar cluster_state: The state of the cluster. + :vartype cluster_state: str + :ivar quota_info: The quota information. + :vartype quota_info: ~azure.mgmt.hdinsight.models.QuotaInfo + :ivar errors: The list of errors. + :vartype errors: list[~azure.mgmt.hdinsight.models.Errors] + :ivar connectivity_endpoints: The list of connectivity endpoints. + :vartype connectivity_endpoints: list[~azure.mgmt.hdinsight.models.ConnectivityEndpoint] + :ivar disk_encryption_properties: The disk encryption properties. + :vartype disk_encryption_properties: ~azure.mgmt.hdinsight.models.DiskEncryptionProperties + :ivar encryption_in_transit_properties: The encryption-in-transit properties. + :vartype encryption_in_transit_properties: ~azure.mgmt.hdinsight.models.EncryptionInTransitProperties - :param storage_profile: The storage profile. - :type storage_profile: ~azure.mgmt.hdinsight.models.StorageProfile - :param min_supported_tls_version: The minimal supported tls version. - :type min_supported_tls_version: str - :param excluded_services_config: The excluded services config. - :type excluded_services_config: ~azure.mgmt.hdinsight.models.ExcludedServicesConfig - :param network_properties: The network properties. - :type network_properties: ~azure.mgmt.hdinsight.models.NetworkProperties - :param compute_isolation_properties: The compute isolation properties. - :type compute_isolation_properties: ~azure.mgmt.hdinsight.models.ComputeIsolationProperties - :param private_link_configurations: The private link configurations. - :type private_link_configurations: list[~azure.mgmt.hdinsight.models.PrivateLinkConfiguration] + :ivar storage_profile: The storage profile. + :vartype storage_profile: ~azure.mgmt.hdinsight.models.StorageProfile + :ivar min_supported_tls_version: The minimal supported tls version. + :vartype min_supported_tls_version: str + :ivar excluded_services_config: The excluded services config. + :vartype excluded_services_config: ~azure.mgmt.hdinsight.models.ExcludedServicesConfig + :ivar network_properties: The network properties. + :vartype network_properties: ~azure.mgmt.hdinsight.models.NetworkProperties + :ivar compute_isolation_properties: The compute isolation properties. + :vartype compute_isolation_properties: ~azure.mgmt.hdinsight.models.ComputeIsolationProperties + :ivar private_link_configurations: The private link configurations. + :vartype private_link_configurations: + list[~azure.mgmt.hdinsight.models.PrivateLinkConfiguration] :ivar private_endpoint_connections: The list of private endpoint connections. :vartype private_endpoint_connections: list[~azure.mgmt.hdinsight.models.PrivateEndpointConnection] """ _validation = { - 'cluster_definition': {'required': True}, - 'private_endpoint_connections': {'readonly': True}, + "cluster_definition": {"required": True}, + "private_endpoint_connections": {"readonly": True}, } _attribute_map = { - 'cluster_version': {'key': 'clusterVersion', 'type': 'str'}, - 'cluster_hdp_version': {'key': 'clusterHdpVersion', 'type': 'str'}, - 'os_type': {'key': 'osType', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'cluster_id': {'key': 'clusterId', 'type': 'str'}, - 'cluster_definition': {'key': 'clusterDefinition', 'type': 'ClusterDefinition'}, - 'kafka_rest_properties': {'key': 'kafkaRestProperties', 'type': 'KafkaRestProperties'}, - 'security_profile': {'key': 'securityProfile', 'type': 'SecurityProfile'}, - 'compute_profile': {'key': 'computeProfile', 'type': 'ComputeProfile'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'created_date': {'key': 'createdDate', 'type': 'str'}, - 'cluster_state': {'key': 'clusterState', 'type': 'str'}, - 'quota_info': {'key': 'quotaInfo', 'type': 'QuotaInfo'}, - 'errors': {'key': 'errors', 'type': '[Errors]'}, - 'connectivity_endpoints': {'key': 'connectivityEndpoints', 'type': '[ConnectivityEndpoint]'}, - 'disk_encryption_properties': {'key': 'diskEncryptionProperties', 'type': 'DiskEncryptionProperties'}, - 'encryption_in_transit_properties': {'key': 'encryptionInTransitProperties', 'type': 'EncryptionInTransitProperties'}, - 'storage_profile': {'key': 'storageProfile', 'type': 'StorageProfile'}, - 'min_supported_tls_version': {'key': 'minSupportedTlsVersion', 'type': 'str'}, - 'excluded_services_config': {'key': 'excludedServicesConfig', 'type': 'ExcludedServicesConfig'}, - 'network_properties': {'key': 'networkProperties', 'type': 'NetworkProperties'}, - 'compute_isolation_properties': {'key': 'computeIsolationProperties', 'type': 'ComputeIsolationProperties'}, - 'private_link_configurations': {'key': 'privateLinkConfigurations', 'type': '[PrivateLinkConfiguration]'}, - 'private_endpoint_connections': {'key': 'privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, - } - - def __init__( + "cluster_version": {"key": "clusterVersion", "type": "str"}, + "cluster_hdp_version": {"key": "clusterHdpVersion", "type": "str"}, + "os_type": {"key": "osType", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "cluster_id": {"key": "clusterId", "type": "str"}, + "cluster_definition": {"key": "clusterDefinition", "type": "ClusterDefinition"}, + "kafka_rest_properties": {"key": "kafkaRestProperties", "type": "KafkaRestProperties"}, + "security_profile": {"key": "securityProfile", "type": "SecurityProfile"}, + "compute_profile": {"key": "computeProfile", "type": "ComputeProfile"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "created_date": {"key": "createdDate", "type": "str"}, + "cluster_state": {"key": "clusterState", "type": "str"}, + "quota_info": {"key": "quotaInfo", "type": "QuotaInfo"}, + "errors": {"key": "errors", "type": "[Errors]"}, + "connectivity_endpoints": {"key": "connectivityEndpoints", "type": "[ConnectivityEndpoint]"}, + "disk_encryption_properties": {"key": "diskEncryptionProperties", "type": "DiskEncryptionProperties"}, + "encryption_in_transit_properties": { + "key": "encryptionInTransitProperties", + "type": "EncryptionInTransitProperties", + }, + "storage_profile": {"key": "storageProfile", "type": "StorageProfile"}, + "min_supported_tls_version": {"key": "minSupportedTlsVersion", "type": "str"}, + "excluded_services_config": {"key": "excludedServicesConfig", "type": "ExcludedServicesConfig"}, + "network_properties": {"key": "networkProperties", "type": "NetworkProperties"}, + "compute_isolation_properties": {"key": "computeIsolationProperties", "type": "ComputeIsolationProperties"}, + "private_link_configurations": {"key": "privateLinkConfigurations", "type": "[PrivateLinkConfiguration]"}, + "private_endpoint_connections": {"key": "privateEndpointConnections", "type": "[PrivateEndpointConnection]"}, + } + + def __init__( # pylint: disable=too-many-locals self, *, - cluster_definition: "ClusterDefinition", + cluster_definition: "_models.ClusterDefinition", cluster_version: Optional[str] = None, cluster_hdp_version: Optional[str] = None, - os_type: Optional[Union[str, "OSType"]] = None, - tier: Optional[Union[str, "Tier"]] = None, + os_type: Optional[Union[str, "_models.OSType"]] = None, + tier: Optional[Union[str, "_models.Tier"]] = None, cluster_id: Optional[str] = None, - kafka_rest_properties: Optional["KafkaRestProperties"] = None, - security_profile: Optional["SecurityProfile"] = None, - compute_profile: Optional["ComputeProfile"] = None, - provisioning_state: Optional[Union[str, "HDInsightClusterProvisioningState"]] = None, + kafka_rest_properties: Optional["_models.KafkaRestProperties"] = None, + security_profile: Optional["_models.SecurityProfile"] = None, + compute_profile: Optional["_models.ComputeProfile"] = None, + provisioning_state: Optional[Union[str, "_models.HDInsightClusterProvisioningState"]] = None, created_date: Optional[str] = None, cluster_state: Optional[str] = None, - quota_info: Optional["QuotaInfo"] = None, - errors: Optional[List["Errors"]] = None, - connectivity_endpoints: Optional[List["ConnectivityEndpoint"]] = None, - disk_encryption_properties: Optional["DiskEncryptionProperties"] = None, - encryption_in_transit_properties: Optional["EncryptionInTransitProperties"] = None, - storage_profile: Optional["StorageProfile"] = None, + quota_info: Optional["_models.QuotaInfo"] = None, + errors: Optional[List["_models.Errors"]] = None, + connectivity_endpoints: Optional[List["_models.ConnectivityEndpoint"]] = None, + disk_encryption_properties: Optional["_models.DiskEncryptionProperties"] = None, + encryption_in_transit_properties: Optional["_models.EncryptionInTransitProperties"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, min_supported_tls_version: Optional[str] = None, - excluded_services_config: Optional["ExcludedServicesConfig"] = None, - network_properties: Optional["NetworkProperties"] = None, - compute_isolation_properties: Optional["ComputeIsolationProperties"] = None, - private_link_configurations: Optional[List["PrivateLinkConfiguration"]] = None, + excluded_services_config: Optional["_models.ExcludedServicesConfig"] = None, + network_properties: Optional["_models.NetworkProperties"] = None, + compute_isolation_properties: Optional["_models.ComputeIsolationProperties"] = None, + private_link_configurations: Optional[List["_models.PrivateLinkConfiguration"]] = None, **kwargs ): - super(ClusterGetProperties, self).__init__(**kwargs) + """ + :keyword cluster_version: The version of the cluster. + :paramtype cluster_version: str + :keyword cluster_hdp_version: The hdp version of the cluster. + :paramtype cluster_hdp_version: str + :keyword os_type: The type of operating system. Known values are: "Windows" and "Linux". + :paramtype os_type: str or ~azure.mgmt.hdinsight.models.OSType + :keyword tier: The cluster tier. Known values are: "Standard" and "Premium". + :paramtype tier: str or ~azure.mgmt.hdinsight.models.Tier + :keyword cluster_id: The cluster id. + :paramtype cluster_id: str + :keyword cluster_definition: The cluster definition. Required. + :paramtype cluster_definition: ~azure.mgmt.hdinsight.models.ClusterDefinition + :keyword kafka_rest_properties: The cluster kafka rest proxy configuration. + :paramtype kafka_rest_properties: ~azure.mgmt.hdinsight.models.KafkaRestProperties + :keyword security_profile: The security profile. + :paramtype security_profile: ~azure.mgmt.hdinsight.models.SecurityProfile + :keyword compute_profile: The compute profile. + :paramtype compute_profile: ~azure.mgmt.hdinsight.models.ComputeProfile + :keyword provisioning_state: The provisioning state, which only appears in the response. Known + values are: "InProgress", "Failed", "Succeeded", "Canceled", and "Deleting". + :paramtype provisioning_state: str or + ~azure.mgmt.hdinsight.models.HDInsightClusterProvisioningState + :keyword created_date: The date on which the cluster was created. + :paramtype created_date: str + :keyword cluster_state: The state of the cluster. + :paramtype cluster_state: str + :keyword quota_info: The quota information. + :paramtype quota_info: ~azure.mgmt.hdinsight.models.QuotaInfo + :keyword errors: The list of errors. + :paramtype errors: list[~azure.mgmt.hdinsight.models.Errors] + :keyword connectivity_endpoints: The list of connectivity endpoints. + :paramtype connectivity_endpoints: list[~azure.mgmt.hdinsight.models.ConnectivityEndpoint] + :keyword disk_encryption_properties: The disk encryption properties. + :paramtype disk_encryption_properties: ~azure.mgmt.hdinsight.models.DiskEncryptionProperties + :keyword encryption_in_transit_properties: The encryption-in-transit properties. + :paramtype encryption_in_transit_properties: + ~azure.mgmt.hdinsight.models.EncryptionInTransitProperties + :keyword storage_profile: The storage profile. + :paramtype storage_profile: ~azure.mgmt.hdinsight.models.StorageProfile + :keyword min_supported_tls_version: The minimal supported tls version. + :paramtype min_supported_tls_version: str + :keyword excluded_services_config: The excluded services config. + :paramtype excluded_services_config: ~azure.mgmt.hdinsight.models.ExcludedServicesConfig + :keyword network_properties: The network properties. + :paramtype network_properties: ~azure.mgmt.hdinsight.models.NetworkProperties + :keyword compute_isolation_properties: The compute isolation properties. + :paramtype compute_isolation_properties: + ~azure.mgmt.hdinsight.models.ComputeIsolationProperties + :keyword private_link_configurations: The private link configurations. + :paramtype private_link_configurations: + list[~azure.mgmt.hdinsight.models.PrivateLinkConfiguration] + """ + super().__init__(**kwargs) self.cluster_version = cluster_version self.cluster_hdp_version = cluster_hdp_version self.os_type = os_type @@ -1483,7 +1810,7 @@ def __init__( self.private_endpoint_connections = None -class ClusterIdentity(msrest.serialization.Model): +class ClusterIdentity(_serialization.Model): """Identity for the cluster. Variables are only populated by the server, and will be ignored when sending a request. @@ -1494,266 +1821,275 @@ class ClusterIdentity(msrest.serialization.Model): :ivar tenant_id: The tenant id associated with the cluster. This property will only be provided for a system assigned identity. :vartype tenant_id: str - :param type: The type of identity used for the cluster. The type 'SystemAssigned, UserAssigned' - includes both an implicitly created identity and a set of user assigned identities. Possible - values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". - :type type: str or ~azure.mgmt.hdinsight.models.ResourceIdentityType - :param user_assigned_identities: The list of user identities associated with the cluster. The + :ivar type: The type of identity used for the cluster. The type 'SystemAssigned, UserAssigned' + includes both an implicitly created identity and a set of user assigned identities. Known + values are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", and "None". + :vartype type: str or ~azure.mgmt.hdinsight.models.ResourceIdentityType + :ivar user_assigned_identities: The list of user identities associated with the cluster. The user identity dictionary key references will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. - :type user_assigned_identities: dict[str, ~azure.mgmt.hdinsight.models.UserAssignedIdentity] + :vartype user_assigned_identities: dict[str, ~azure.mgmt.hdinsight.models.UserAssignedIdentity] """ _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'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserAssignedIdentity}'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedIdentity}"}, } def __init__( self, *, - type: Optional[Union[str, "ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "UserAssignedIdentity"]] = None, + type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentity"]] = None, **kwargs ): - super(ClusterIdentity, self).__init__(**kwargs) + """ + :keyword type: The type of identity used for the cluster. The type 'SystemAssigned, + UserAssigned' includes both an implicitly created identity and a set of user assigned + identities. Known values are: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", + and "None". + :paramtype type: str or ~azure.mgmt.hdinsight.models.ResourceIdentityType + :keyword user_assigned_identities: The list of user identities associated with the cluster. The + user identity dictionary key references will be ARM resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + :paramtype user_assigned_identities: dict[str, + ~azure.mgmt.hdinsight.models.UserAssignedIdentity] + """ + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type self.user_assigned_identities = user_assigned_identities -class ClusterListPersistedScriptActionsResult(msrest.serialization.Model): +class ClusterListPersistedScriptActionsResult(_serialization.Model): """The ListPersistedScriptActions operation response. Variables are only populated by the server, and will be ignored when sending a request. - :param value: The list of Persisted Script Actions. - :type value: list[~azure.mgmt.hdinsight.models.RuntimeScriptAction] + :ivar value: The list of Persisted Script Actions. + :vartype value: list[~azure.mgmt.hdinsight.models.RuntimeScriptAction] :ivar next_link: The link (url) to the next page of results. :vartype next_link: str """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[RuntimeScriptAction]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[RuntimeScriptAction]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["RuntimeScriptAction"]] = None, - **kwargs - ): - super(ClusterListPersistedScriptActionsResult, self).__init__(**kwargs) + def __init__(self, *, value: Optional[List["_models.RuntimeScriptAction"]] = None, **kwargs): + """ + :keyword value: The list of Persisted Script Actions. + :paramtype value: list[~azure.mgmt.hdinsight.models.RuntimeScriptAction] + """ + super().__init__(**kwargs) self.value = value self.next_link = None -class ClusterListResult(msrest.serialization.Model): +class ClusterListResult(_serialization.Model): """The List Cluster operation response. Variables are only populated by the server, and will be ignored when sending a request. - :param value: The list of Clusters. - :type value: list[~azure.mgmt.hdinsight.models.Cluster] + :ivar value: The list of Clusters. + :vartype value: list[~azure.mgmt.hdinsight.models.Cluster] :ivar next_link: The link (url) to the next page of results. :vartype next_link: str """ _validation = { - 'next_link': {'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, - *, - value: Optional[List["Cluster"]] = None, - **kwargs - ): - super(ClusterListResult, self).__init__(**kwargs) + def __init__(self, *, value: Optional[List["_models.Cluster"]] = None, **kwargs): + """ + :keyword value: The list of Clusters. + :paramtype value: list[~azure.mgmt.hdinsight.models.Cluster] + """ + super().__init__(**kwargs) self.value = value self.next_link = None -class ClusterMonitoringRequest(msrest.serialization.Model): +class ClusterMonitoringRequest(_serialization.Model): """The cluster monitor parameters. - :param workspace_id: The cluster monitor workspace ID. - :type workspace_id: str - :param primary_key: The cluster monitor workspace key. - :type primary_key: str + :ivar workspace_id: The cluster monitor workspace ID. + :vartype workspace_id: str + :ivar primary_key: The cluster monitor workspace key. + :vartype primary_key: str """ _attribute_map = { - 'workspace_id': {'key': 'workspaceId', 'type': 'str'}, - 'primary_key': {'key': 'primaryKey', 'type': 'str'}, - } - - def __init__( - self, - *, - workspace_id: Optional[str] = None, - primary_key: Optional[str] = None, - **kwargs - ): - super(ClusterMonitoringRequest, self).__init__(**kwargs) + "workspace_id": {"key": "workspaceId", "type": "str"}, + "primary_key": {"key": "primaryKey", "type": "str"}, + } + + def __init__(self, *, workspace_id: Optional[str] = None, primary_key: Optional[str] = None, **kwargs): + """ + :keyword workspace_id: The cluster monitor workspace ID. + :paramtype workspace_id: str + :keyword primary_key: The cluster monitor workspace key. + :paramtype primary_key: str + """ + super().__init__(**kwargs) self.workspace_id = workspace_id self.primary_key = primary_key -class ClusterMonitoringResponse(msrest.serialization.Model): +class ClusterMonitoringResponse(_serialization.Model): """The cluster monitoring status response. - :param cluster_monitoring_enabled: The status of the monitor on the HDInsight cluster. - :type cluster_monitoring_enabled: bool - :param workspace_id: The workspace ID of the monitor on the HDInsight cluster. - :type workspace_id: str + :ivar cluster_monitoring_enabled: The status of the monitor on the HDInsight cluster. + :vartype cluster_monitoring_enabled: bool + :ivar workspace_id: The workspace ID of the monitor on the HDInsight cluster. + :vartype workspace_id: str """ _attribute_map = { - 'cluster_monitoring_enabled': {'key': 'clusterMonitoringEnabled', 'type': 'bool'}, - 'workspace_id': {'key': 'workspaceId', 'type': 'str'}, + "cluster_monitoring_enabled": {"key": "clusterMonitoringEnabled", "type": "bool"}, + "workspace_id": {"key": "workspaceId", "type": "str"}, } def __init__( - self, - *, - cluster_monitoring_enabled: Optional[bool] = None, - workspace_id: Optional[str] = None, - **kwargs + self, *, cluster_monitoring_enabled: Optional[bool] = None, workspace_id: Optional[str] = None, **kwargs ): - super(ClusterMonitoringResponse, self).__init__(**kwargs) + """ + :keyword cluster_monitoring_enabled: The status of the monitor on the HDInsight cluster. + :paramtype cluster_monitoring_enabled: bool + :keyword workspace_id: The workspace ID of the monitor on the HDInsight cluster. + :paramtype workspace_id: str + """ + super().__init__(**kwargs) self.cluster_monitoring_enabled = cluster_monitoring_enabled self.workspace_id = workspace_id -class ClusterPatchParameters(msrest.serialization.Model): +class ClusterPatchParameters(_serialization.Model): """The PatchCluster request parameters. - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] + :ivar tags: The resource tags. + :vartype tags: dict[str, str] """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): - super(ClusterPatchParameters, self).__init__(**kwargs) + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): + """ + :keyword tags: The resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) self.tags = tags -class ClusterResizeParameters(msrest.serialization.Model): +class ClusterResizeParameters(_serialization.Model): """The Resize Cluster request parameters. - :param target_instance_count: The target instance count for the operation. - :type target_instance_count: int + :ivar target_instance_count: The target instance count for the operation. + :vartype target_instance_count: int """ _attribute_map = { - 'target_instance_count': {'key': 'targetInstanceCount', 'type': 'int'}, + "target_instance_count": {"key": "targetInstanceCount", "type": "int"}, } - def __init__( - self, - *, - target_instance_count: Optional[int] = None, - **kwargs - ): - super(ClusterResizeParameters, self).__init__(**kwargs) + def __init__(self, *, target_instance_count: Optional[int] = None, **kwargs): + """ + :keyword target_instance_count: The target instance count for the operation. + :paramtype target_instance_count: int + """ + super().__init__(**kwargs) self.target_instance_count = target_instance_count -class ComputeIsolationProperties(msrest.serialization.Model): +class ComputeIsolationProperties(_serialization.Model): """The compute isolation properties. - :param enable_compute_isolation: The flag indicates whether enable compute isolation or not. - :type enable_compute_isolation: bool - :param host_sku: The host sku. - :type host_sku: str + :ivar enable_compute_isolation: The flag indicates whether enable compute isolation or not. + :vartype enable_compute_isolation: bool + :ivar host_sku: The host sku. + :vartype host_sku: str """ _attribute_map = { - 'enable_compute_isolation': {'key': 'enableComputeIsolation', 'type': 'bool'}, - 'host_sku': {'key': 'hostSku', 'type': 'str'}, - } - - def __init__( - self, - *, - enable_compute_isolation: Optional[bool] = False, - host_sku: Optional[str] = None, - **kwargs - ): - super(ComputeIsolationProperties, self).__init__(**kwargs) + "enable_compute_isolation": {"key": "enableComputeIsolation", "type": "bool"}, + "host_sku": {"key": "hostSku", "type": "str"}, + } + + def __init__(self, *, enable_compute_isolation: bool = False, host_sku: Optional[str] = None, **kwargs): + """ + :keyword enable_compute_isolation: The flag indicates whether enable compute isolation or not. + :paramtype enable_compute_isolation: bool + :keyword host_sku: The host sku. + :paramtype host_sku: str + """ + super().__init__(**kwargs) self.enable_compute_isolation = enable_compute_isolation self.host_sku = host_sku -class ComputeProfile(msrest.serialization.Model): +class ComputeProfile(_serialization.Model): """Describes the compute profile. - :param roles: The list of roles in the cluster. - :type roles: list[~azure.mgmt.hdinsight.models.Role] + :ivar roles: The list of roles in the cluster. + :vartype roles: list[~azure.mgmt.hdinsight.models.Role] """ _attribute_map = { - 'roles': {'key': 'roles', 'type': '[Role]'}, + "roles": {"key": "roles", "type": "[Role]"}, } - def __init__( - self, - *, - roles: Optional[List["Role"]] = None, - **kwargs - ): - super(ComputeProfile, self).__init__(**kwargs) + def __init__(self, *, roles: Optional[List["_models.Role"]] = None, **kwargs): + """ + :keyword roles: The list of roles in the cluster. + :paramtype roles: list[~azure.mgmt.hdinsight.models.Role] + """ + super().__init__(**kwargs) self.roles = roles -class ConnectivityEndpoint(msrest.serialization.Model): +class ConnectivityEndpoint(_serialization.Model): """The connectivity properties. - :param name: The name of the endpoint. - :type name: str - :param protocol: The protocol of the endpoint. - :type protocol: str - :param location: The location of the endpoint. - :type location: str - :param port: The port to connect to. - :type port: int - :param private_ip_address: The private ip address of the endpoint. - :type private_ip_address: str + :ivar name: The name of the endpoint. + :vartype name: str + :ivar protocol: The protocol of the endpoint. + :vartype protocol: str + :ivar location: The location of the endpoint. + :vartype location: str + :ivar port: The port to connect to. + :vartype port: int + :ivar private_ip_address: The private ip address of the endpoint. + :vartype private_ip_address: str """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'protocol': {'key': 'protocol', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'port': {'key': 'port', 'type': 'int'}, - 'private_ip_address': {'key': 'privateIPAddress', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "protocol": {"key": "protocol", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "port": {"key": "port", "type": "int"}, + "private_ip_address": {"key": "privateIPAddress", "type": "str"}, } def __init__( @@ -1766,7 +2102,19 @@ def __init__( private_ip_address: Optional[str] = None, **kwargs ): - super(ConnectivityEndpoint, self).__init__(**kwargs) + """ + :keyword name: The name of the endpoint. + :paramtype name: str + :keyword protocol: The protocol of the endpoint. + :paramtype protocol: str + :keyword location: The location of the endpoint. + :paramtype location: str + :keyword port: The port to connect to. + :paramtype port: int + :keyword private_ip_address: The private ip address of the endpoint. + :paramtype private_ip_address: str + """ + super().__init__(**kwargs) self.name = name self.protocol = protocol self.location = location @@ -1774,13 +2122,13 @@ def __init__( self.private_ip_address = private_ip_address -class DataDisksGroups(msrest.serialization.Model): +class DataDisksGroups(_serialization.Model): """The data disks groups for the role. Variables are only populated by the server, and will be ignored when sending a request. - :param disks_per_node: The number of disks per node. - :type disks_per_node: int + :ivar disks_per_node: The number of disks per node. + :vartype disks_per_node: int :ivar storage_account_type: ReadOnly. The storage account type. Do not set this value. :vartype storage_account_type: str :ivar disk_size_gb: ReadOnly. The DiskSize in GB. Do not set this value. @@ -1788,47 +2136,46 @@ class DataDisksGroups(msrest.serialization.Model): """ _validation = { - 'storage_account_type': {'readonly': True}, - 'disk_size_gb': {'readonly': True}, + "storage_account_type": {"readonly": True}, + "disk_size_gb": {"readonly": True}, } _attribute_map = { - 'disks_per_node': {'key': 'disksPerNode', 'type': 'int'}, - 'storage_account_type': {'key': 'storageAccountType', 'type': 'str'}, - 'disk_size_gb': {'key': 'diskSizeGB', 'type': 'int'}, + "disks_per_node": {"key": "disksPerNode", "type": "int"}, + "storage_account_type": {"key": "storageAccountType", "type": "str"}, + "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, } - def __init__( - self, - *, - disks_per_node: Optional[int] = None, - **kwargs - ): - super(DataDisksGroups, self).__init__(**kwargs) + def __init__(self, *, disks_per_node: Optional[int] = None, **kwargs): + """ + :keyword disks_per_node: The number of disks per node. + :paramtype disks_per_node: int + """ + super().__init__(**kwargs) self.disks_per_node = disks_per_node self.storage_account_type = None self.disk_size_gb = None -class Dimension(msrest.serialization.Model): +class Dimension(_serialization.Model): """The definition of Dimension. - :param name: The name of the dimension. - :type name: str - :param display_name: The display name of the dimension. - :type display_name: str - :param internal_name: The display name of the dimension. - :type internal_name: str - :param to_be_exported_for_shoebox: The flag indicates whether the metric will be exported for + :ivar name: The name of the dimension. + :vartype name: str + :ivar display_name: The display name of the dimension. + :vartype display_name: str + :ivar internal_name: The display name of the dimension. + :vartype internal_name: str + :ivar to_be_exported_for_shoebox: The flag indicates whether the metric will be exported for shoebox or not. - :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__( @@ -1840,29 +2187,40 @@ def __init__( to_be_exported_for_shoebox: Optional[bool] = None, **kwargs ): - super(Dimension, self).__init__(**kwargs) + """ + :keyword name: The name of the dimension. + :paramtype name: str + :keyword display_name: The display name of the dimension. + :paramtype display_name: str + :keyword internal_name: The display name of the dimension. + :paramtype internal_name: str + :keyword to_be_exported_for_shoebox: The flag indicates whether the metric will be exported for + shoebox or not. + :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 DiskBillingMeters(msrest.serialization.Model): +class DiskBillingMeters(_serialization.Model): """The disk billing meters. - :param disk_rp_meter: The managed disk meter guid. - :type disk_rp_meter: str - :param sku: The managed disk billing sku, P30 or S30. - :type sku: str - :param tier: The managed disk billing tier, Standard or Premium. Possible values include: - "Standard", "Premium". - :type tier: str or ~azure.mgmt.hdinsight.models.Tier + :ivar disk_rp_meter: The managed disk meter guid. + :vartype disk_rp_meter: str + :ivar sku: The managed disk billing sku, P30 or S30. + :vartype sku: str + :ivar tier: The managed disk billing tier, Standard or Premium. Known values are: "Standard" + and "Premium". + :vartype tier: str or ~azure.mgmt.hdinsight.models.Tier """ _attribute_map = { - 'disk_rp_meter': {'key': 'diskRpMeter', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, + "disk_rp_meter": {"key": "diskRpMeter", "type": "str"}, + "sku": {"key": "sku", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, } def __init__( @@ -1870,41 +2228,51 @@ def __init__( *, disk_rp_meter: Optional[str] = None, sku: Optional[str] = None, - tier: Optional[Union[str, "Tier"]] = None, + tier: Optional[Union[str, "_models.Tier"]] = None, **kwargs ): - super(DiskBillingMeters, self).__init__(**kwargs) + """ + :keyword disk_rp_meter: The managed disk meter guid. + :paramtype disk_rp_meter: str + :keyword sku: The managed disk billing sku, P30 or S30. + :paramtype sku: str + :keyword tier: The managed disk billing tier, Standard or Premium. Known values are: "Standard" + and "Premium". + :paramtype tier: str or ~azure.mgmt.hdinsight.models.Tier + """ + super().__init__(**kwargs) self.disk_rp_meter = disk_rp_meter self.sku = sku self.tier = tier -class DiskEncryptionProperties(msrest.serialization.Model): +class DiskEncryptionProperties(_serialization.Model): """The disk encryption properties. - :param vault_uri: Base key vault URI where the customers key is located eg. + :ivar vault_uri: Base key vault URI where the customers key is located eg. https://myvault.vault.azure.net. - :type vault_uri: str - :param key_name: Key name that is used for enabling disk encryption. - :type key_name: str - :param key_version: Specific key version that is used for enabling disk encryption. - :type key_version: str - :param encryption_algorithm: Algorithm identifier for encryption, default RSA-OAEP. Possible - values include: "RSA-OAEP", "RSA-OAEP-256", "RSA1_5". - :type encryption_algorithm: str or ~azure.mgmt.hdinsight.models.JsonWebKeyEncryptionAlgorithm - :param msi_resource_id: Resource ID of Managed Identity that is used to access the key vault. - :type msi_resource_id: str - :param encryption_at_host: Indicates whether or not resource disk encryption is enabled. - :type encryption_at_host: bool + :vartype vault_uri: str + :ivar key_name: Key name that is used for enabling disk encryption. + :vartype key_name: str + :ivar key_version: Specific key version that is used for enabling disk encryption. + :vartype key_version: str + :ivar encryption_algorithm: Algorithm identifier for encryption, default RSA-OAEP. Known values + are: "RSA-OAEP", "RSA-OAEP-256", and "RSA1_5". + :vartype encryption_algorithm: str or + ~azure.mgmt.hdinsight.models.JsonWebKeyEncryptionAlgorithm + :ivar msi_resource_id: Resource ID of Managed Identity that is used to access the key vault. + :vartype msi_resource_id: str + :ivar encryption_at_host: Indicates whether or not resource disk encryption is enabled. + :vartype encryption_at_host: bool """ _attribute_map = { - 'vault_uri': {'key': 'vaultUri', 'type': 'str'}, - 'key_name': {'key': 'keyName', 'type': 'str'}, - 'key_version': {'key': 'keyVersion', 'type': 'str'}, - 'encryption_algorithm': {'key': 'encryptionAlgorithm', 'type': 'str'}, - 'msi_resource_id': {'key': 'msiResourceId', 'type': 'str'}, - 'encryption_at_host': {'key': 'encryptionAtHost', 'type': 'bool'}, + "vault_uri": {"key": "vaultUri", "type": "str"}, + "key_name": {"key": "keyName", "type": "str"}, + "key_version": {"key": "keyVersion", "type": "str"}, + "encryption_algorithm": {"key": "encryptionAlgorithm", "type": "str"}, + "msi_resource_id": {"key": "msiResourceId", "type": "str"}, + "encryption_at_host": {"key": "encryptionAtHost", "type": "bool"}, } def __init__( @@ -1913,12 +2281,29 @@ def __init__( vault_uri: Optional[str] = None, key_name: Optional[str] = None, key_version: Optional[str] = None, - encryption_algorithm: Optional[Union[str, "JsonWebKeyEncryptionAlgorithm"]] = None, + encryption_algorithm: Optional[Union[str, "_models.JsonWebKeyEncryptionAlgorithm"]] = None, msi_resource_id: Optional[str] = None, - encryption_at_host: Optional[bool] = False, + encryption_at_host: bool = False, **kwargs ): - super(DiskEncryptionProperties, self).__init__(**kwargs) + """ + :keyword vault_uri: Base key vault URI where the customers key is located eg. + https://myvault.vault.azure.net. + :paramtype vault_uri: str + :keyword key_name: Key name that is used for enabling disk encryption. + :paramtype key_name: str + :keyword key_version: Specific key version that is used for enabling disk encryption. + :paramtype key_version: str + :keyword encryption_algorithm: Algorithm identifier for encryption, default RSA-OAEP. Known + values are: "RSA-OAEP", "RSA-OAEP-256", and "RSA1_5". + :paramtype encryption_algorithm: str or + ~azure.mgmt.hdinsight.models.JsonWebKeyEncryptionAlgorithm + :keyword msi_resource_id: Resource ID of Managed Identity that is used to access the key vault. + :paramtype msi_resource_id: str + :keyword encryption_at_host: Indicates whether or not resource disk encryption is enabled. + :paramtype encryption_at_host: bool + """ + super().__init__(**kwargs) self.vault_uri = vault_uri self.key_name = key_name self.key_version = key_version @@ -1927,92 +2312,92 @@ def __init__( self.encryption_at_host = encryption_at_host -class EncryptionInTransitProperties(msrest.serialization.Model): +class EncryptionInTransitProperties(_serialization.Model): """The encryption-in-transit properties. - :param is_encryption_in_transit_enabled: Indicates whether or not inter cluster node + :ivar is_encryption_in_transit_enabled: Indicates whether or not inter cluster node communication is encrypted in transit. - :type is_encryption_in_transit_enabled: bool + :vartype is_encryption_in_transit_enabled: bool """ _attribute_map = { - 'is_encryption_in_transit_enabled': {'key': 'isEncryptionInTransitEnabled', 'type': 'bool'}, + "is_encryption_in_transit_enabled": {"key": "isEncryptionInTransitEnabled", "type": "bool"}, } - def __init__( - self, - *, - is_encryption_in_transit_enabled: Optional[bool] = False, - **kwargs - ): - super(EncryptionInTransitProperties, self).__init__(**kwargs) + def __init__(self, *, is_encryption_in_transit_enabled: bool = False, **kwargs): + """ + :keyword is_encryption_in_transit_enabled: Indicates whether or not inter cluster node + communication is encrypted in transit. + :paramtype is_encryption_in_transit_enabled: bool + """ + super().__init__(**kwargs) self.is_encryption_in_transit_enabled = is_encryption_in_transit_enabled -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """Describes the format of Error response. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + } + + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ + super().__init__(**kwargs) self.code = code self.message = message -class Errors(msrest.serialization.Model): +class Errors(_serialization.Model): """The error message associated with the cluster creation. - :param code: The error code. - :type code: str - :param message: The error message. - :type message: str + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - **kwargs - ): - super(Errors, self).__init__(**kwargs) + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + } + + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): + """ + :keyword code: The error code. + :paramtype code: str + :keyword message: The error message. + :paramtype message: str + """ + super().__init__(**kwargs) self.code = code self.message = message -class ExcludedServicesConfig(msrest.serialization.Model): +class ExcludedServicesConfig(_serialization.Model): """The configuration that services will be excluded when creating cluster. - :param excluded_services_config_id: The config id of excluded services. - :type excluded_services_config_id: str - :param excluded_services_list: The list of excluded services. - :type excluded_services_list: str + :ivar excluded_services_config_id: The config id of excluded services. + :vartype excluded_services_config_id: str + :ivar excluded_services_list: The list of excluded services. + :vartype excluded_services_list: str """ _attribute_map = { - 'excluded_services_config_id': {'key': 'excludedServicesConfigId', 'type': 'str'}, - 'excluded_services_list': {'key': 'excludedServicesList', 'type': 'str'}, + "excluded_services_config_id": {"key": "excludedServicesConfigId", "type": "str"}, + "excluded_services_list": {"key": "excludedServicesList", "type": "str"}, } def __init__( @@ -2022,70 +2407,82 @@ def __init__( excluded_services_list: Optional[str] = None, **kwargs ): - super(ExcludedServicesConfig, self).__init__(**kwargs) + """ + :keyword excluded_services_config_id: The config id of excluded services. + :paramtype excluded_services_config_id: str + :keyword excluded_services_list: The list of excluded services. + :paramtype excluded_services_list: str + """ + super().__init__(**kwargs) self.excluded_services_config_id = excluded_services_config_id self.excluded_services_list = excluded_services_list -class ExecuteScriptActionParameters(msrest.serialization.Model): +class ExecuteScriptActionParameters(_serialization.Model): """The parameters for the script actions to execute on a running cluster. All required parameters must be populated in order to send to Azure. - :param script_actions: The list of run time script actions. - :type script_actions: list[~azure.mgmt.hdinsight.models.RuntimeScriptAction] - :param persist_on_success: Required. Gets or sets if the scripts needs to be persisted. - :type persist_on_success: bool + :ivar script_actions: The list of run time script actions. + :vartype script_actions: list[~azure.mgmt.hdinsight.models.RuntimeScriptAction] + :ivar persist_on_success: Gets or sets if the scripts needs to be persisted. Required. + :vartype persist_on_success: bool """ _validation = { - 'persist_on_success': {'required': True}, + "persist_on_success": {"required": True}, } _attribute_map = { - 'script_actions': {'key': 'scriptActions', 'type': '[RuntimeScriptAction]'}, - 'persist_on_success': {'key': 'persistOnSuccess', 'type': 'bool'}, + "script_actions": {"key": "scriptActions", "type": "[RuntimeScriptAction]"}, + "persist_on_success": {"key": "persistOnSuccess", "type": "bool"}, } def __init__( self, *, persist_on_success: bool, - script_actions: Optional[List["RuntimeScriptAction"]] = None, + script_actions: Optional[List["_models.RuntimeScriptAction"]] = None, **kwargs ): - super(ExecuteScriptActionParameters, self).__init__(**kwargs) + """ + :keyword script_actions: The list of run time script actions. + :paramtype script_actions: list[~azure.mgmt.hdinsight.models.RuntimeScriptAction] + :keyword persist_on_success: Gets or sets if the scripts needs to be persisted. Required. + :paramtype persist_on_success: bool + """ + super().__init__(**kwargs) self.script_actions = script_actions self.persist_on_success = persist_on_success -class Extension(msrest.serialization.Model): +class Extension(_serialization.Model): """Cluster monitoring extensions. - :param workspace_id: The workspace ID for the cluster monitoring extension. - :type workspace_id: str - :param primary_key: The certificate for the cluster monitoring extensions. - :type primary_key: str + :ivar workspace_id: The workspace ID for the cluster monitoring extension. + :vartype workspace_id: str + :ivar primary_key: The certificate for the cluster monitoring extensions. + :vartype primary_key: str """ _attribute_map = { - 'workspace_id': {'key': 'workspaceId', 'type': 'str'}, - 'primary_key': {'key': 'primaryKey', 'type': 'str'}, - } - - def __init__( - self, - *, - workspace_id: Optional[str] = None, - primary_key: Optional[str] = None, - **kwargs - ): - super(Extension, self).__init__(**kwargs) + "workspace_id": {"key": "workspaceId", "type": "str"}, + "primary_key": {"key": "primaryKey", "type": "str"}, + } + + def __init__(self, *, workspace_id: Optional[str] = None, primary_key: Optional[str] = None, **kwargs): + """ + :keyword workspace_id: The workspace ID for the cluster monitoring extension. + :paramtype workspace_id: str + :keyword primary_key: The certificate for the cluster monitoring extensions. + :paramtype primary_key: str + """ + super().__init__(**kwargs) self.workspace_id = workspace_id self.primary_key = primary_key -class GatewaySettings(msrest.serialization.Model): +class GatewaySettings(_serialization.Model): """Gateway settings. Variables are only populated by the server, and will be ignored when sending a request. @@ -2100,64 +2497,61 @@ class GatewaySettings(msrest.serialization.Model): """ _validation = { - 'is_credential_enabled': {'readonly': True}, - 'user_name': {'readonly': True}, - 'password': {'readonly': True}, + "is_credential_enabled": {"readonly": True}, + "user_name": {"readonly": True}, + "password": {"readonly": True}, } _attribute_map = { - 'is_credential_enabled': {'key': 'restAuthCredential\\.isEnabled', 'type': 'str'}, - 'user_name': {'key': 'restAuthCredential\\.username', 'type': 'str'}, - 'password': {'key': 'restAuthCredential\\.password', 'type': 'str'}, + "is_credential_enabled": {"key": "restAuthCredential\\.isEnabled", "type": "str"}, + "user_name": {"key": "restAuthCredential\\.username", "type": "str"}, + "password": {"key": "restAuthCredential\\.password", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(GatewaySettings, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.is_credential_enabled = None self.user_name = None self.password = None -class HardwareProfile(msrest.serialization.Model): +class HardwareProfile(_serialization.Model): """The hardware profile. - :param vm_size: The size of the VM. - :type vm_size: str + :ivar vm_size: The size of the VM. + :vartype vm_size: str """ _attribute_map = { - 'vm_size': {'key': 'vmSize', 'type': 'str'}, + "vm_size": {"key": "vmSize", "type": "str"}, } - def __init__( - self, - *, - vm_size: Optional[str] = None, - **kwargs - ): - super(HardwareProfile, self).__init__(**kwargs) + def __init__(self, *, vm_size: Optional[str] = None, **kwargs): + """ + :keyword vm_size: The size of the VM. + :paramtype vm_size: str + """ + super().__init__(**kwargs) self.vm_size = vm_size -class HostInfo(msrest.serialization.Model): +class HostInfo(_serialization.Model): """The cluster host information. - :param name: The host name. - :type name: str - :param fqdn: The Fully Qualified Domain Name of host. - :type fqdn: str - :param effective_disk_encryption_key_url: The effective disk encryption key URL used by the + :ivar name: The host name. + :vartype name: str + :ivar fqdn: The Fully Qualified Domain Name of host. + :vartype fqdn: str + :ivar effective_disk_encryption_key_url: The effective disk encryption key URL used by the host. - :type effective_disk_encryption_key_url: str + :vartype effective_disk_encryption_key_url: str """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'fqdn': {'key': 'fqdn', 'type': 'str'}, - 'effective_disk_encryption_key_url': {'key': 'effectiveDiskEncryptionKeyUrl', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "fqdn": {"key": "fqdn", "type": "str"}, + "effective_disk_encryption_key_url": {"key": "effectiveDiskEncryptionKeyUrl", "type": "str"}, } def __init__( @@ -2168,13 +2562,22 @@ def __init__( effective_disk_encryption_key_url: Optional[str] = None, **kwargs ): - super(HostInfo, self).__init__(**kwargs) + """ + :keyword name: The host name. + :paramtype name: str + :keyword fqdn: The Fully Qualified Domain Name of host. + :paramtype fqdn: str + :keyword effective_disk_encryption_key_url: The effective disk encryption key URL used by the + host. + :paramtype effective_disk_encryption_key_url: str + """ + super().__init__(**kwargs) self.name = name self.fqdn = fqdn self.effective_disk_encryption_key_url = effective_disk_encryption_key_url -class IPConfiguration(msrest.serialization.Model): +class IPConfiguration(_serialization.Model): """The ip configurations for the private link service. Variables are only populated by the server, and will be ignored when sending a request. @@ -2183,43 +2586,43 @@ class IPConfiguration(msrest.serialization.Model): :ivar id: The private link IP configuration id. :vartype id: str - :param name: Required. The name of private link IP configuration. - :type name: str + :ivar name: The name of private link IP configuration. Required. + :vartype name: str :ivar type: The type of the private link IP configuration. :vartype type: str :ivar provisioning_state: The private link configuration provisioning state, which only appears - in the response. Possible values include: "InProgress", "Failed", "Succeeded", "Canceled", + in the response. Known values are: "InProgress", "Failed", "Succeeded", "Canceled", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.hdinsight.models.PrivateLinkConfigurationProvisioningState - :param primary: Indicates whether this IP configuration is primary for the corresponding NIC. - :type primary: bool - :param private_ip_address: The IP address. - :type private_ip_address: str - :param private_ip_allocation_method: The method that private IP address is allocated. Possible - values include: "dynamic", "static". - :type private_ip_allocation_method: str or + :ivar primary: Indicates whether this IP configuration is primary for the corresponding NIC. + :vartype primary: bool + :ivar private_ip_address: The IP address. + :vartype private_ip_address: str + :ivar private_ip_allocation_method: The method that private IP address is allocated. Known + values are: "dynamic" and "static". + :vartype private_ip_allocation_method: str or ~azure.mgmt.hdinsight.models.PrivateIPAllocationMethod - :param subnet: The subnet resource id. - :type subnet: ~azure.mgmt.hdinsight.models.ResourceId + :ivar subnet: The subnet resource id. + :vartype subnet: ~azure.mgmt.hdinsight.models.ResourceId """ _validation = { - 'id': {'readonly': True}, - 'name': {'required': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"required": 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'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'primary': {'key': 'properties.primary', 'type': 'bool'}, - 'private_ip_address': {'key': 'properties.privateIPAddress', 'type': 'str'}, - 'private_ip_allocation_method': {'key': 'properties.privateIPAllocationMethod', 'type': 'str'}, - 'subnet': {'key': 'properties.subnet', 'type': 'ResourceId'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "primary": {"key": "properties.primary", "type": "bool"}, + "private_ip_address": {"key": "properties.privateIPAddress", "type": "str"}, + "private_ip_allocation_method": {"key": "properties.privateIPAllocationMethod", "type": "str"}, + "subnet": {"key": "properties.subnet", "type": "ResourceId"}, } def __init__( @@ -2228,11 +2631,25 @@ def __init__( name: str, primary: Optional[bool] = None, private_ip_address: Optional[str] = None, - private_ip_allocation_method: Optional[Union[str, "PrivateIPAllocationMethod"]] = None, - subnet: Optional["ResourceId"] = None, + private_ip_allocation_method: Optional[Union[str, "_models.PrivateIPAllocationMethod"]] = None, + subnet: Optional["_models.ResourceId"] = None, **kwargs ): - super(IPConfiguration, self).__init__(**kwargs) + """ + :keyword name: The name of private link IP configuration. Required. + :paramtype name: str + :keyword primary: Indicates whether this IP configuration is primary for the corresponding NIC. + :paramtype primary: bool + :keyword private_ip_address: The IP address. + :paramtype private_ip_address: str + :keyword private_ip_allocation_method: The method that private IP address is allocated. Known + values are: "dynamic" and "static". + :paramtype private_ip_allocation_method: str or + ~azure.mgmt.hdinsight.models.PrivateIPAllocationMethod + :keyword subnet: The subnet resource id. + :paramtype subnet: ~azure.mgmt.hdinsight.models.ResourceId + """ + super().__init__(**kwargs) self.id = None self.name = name self.type = None @@ -2243,47 +2660,53 @@ def __init__( self.subnet = subnet -class KafkaRestProperties(msrest.serialization.Model): +class KafkaRestProperties(_serialization.Model): """The kafka rest proxy configuration which contains AAD security group information. - :param client_group_info: The information of AAD security group. - :type client_group_info: ~azure.mgmt.hdinsight.models.ClientGroupInfo - :param configuration_override: The configurations that need to be overriden. - :type configuration_override: dict[str, str] + :ivar client_group_info: The information of AAD security group. + :vartype client_group_info: ~azure.mgmt.hdinsight.models.ClientGroupInfo + :ivar configuration_override: The configurations that need to be overriden. + :vartype configuration_override: dict[str, str] """ _attribute_map = { - 'client_group_info': {'key': 'clientGroupInfo', 'type': 'ClientGroupInfo'}, - 'configuration_override': {'key': 'configurationOverride', 'type': '{str}'}, + "client_group_info": {"key": "clientGroupInfo", "type": "ClientGroupInfo"}, + "configuration_override": {"key": "configurationOverride", "type": "{str}"}, } def __init__( self, *, - client_group_info: Optional["ClientGroupInfo"] = None, + client_group_info: Optional["_models.ClientGroupInfo"] = None, configuration_override: Optional[Dict[str, str]] = None, **kwargs ): - super(KafkaRestProperties, self).__init__(**kwargs) + """ + :keyword client_group_info: The information of AAD security group. + :paramtype client_group_info: ~azure.mgmt.hdinsight.models.ClientGroupInfo + :keyword configuration_override: The configurations that need to be overriden. + :paramtype configuration_override: dict[str, str] + """ + super().__init__(**kwargs) self.client_group_info = client_group_info self.configuration_override = configuration_override -class LinuxOperatingSystemProfile(msrest.serialization.Model): +class LinuxOperatingSystemProfile(_serialization.Model): """The ssh username, password, and ssh public key. - :param username: The username. - :type username: str - :param password: The password. - :type password: str - :param ssh_profile: The SSH profile. - :type ssh_profile: ~azure.mgmt.hdinsight.models.SshProfile + :ivar username: The username. + :vartype username: str + :ivar password: The password. + :vartype password: str + :ivar ssh_profile: The SSH profile. + :vartype ssh_profile: ~azure.mgmt.hdinsight.models.SshProfile """ _attribute_map = { - 'username': {'key': 'username', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, - 'ssh_profile': {'key': 'sshProfile', 'type': 'SshProfile'}, + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, + "ssh_profile": {"key": "sshProfile", "type": "SshProfile"}, } def __init__( @@ -2291,100 +2714,107 @@ def __init__( *, username: Optional[str] = None, password: Optional[str] = None, - ssh_profile: Optional["SshProfile"] = None, + ssh_profile: Optional["_models.SshProfile"] = None, **kwargs ): - super(LinuxOperatingSystemProfile, self).__init__(**kwargs) + """ + :keyword username: The username. + :paramtype username: str + :keyword password: The password. + :paramtype password: str + :keyword ssh_profile: The SSH profile. + :paramtype ssh_profile: ~azure.mgmt.hdinsight.models.SshProfile + """ + super().__init__(**kwargs) self.username = username self.password = password self.ssh_profile = ssh_profile -class LocalizedName(msrest.serialization.Model): +class LocalizedName(_serialization.Model): """The details about the localizable name of a type of usage. - :param value: The name of the used resource. - :type value: str - :param localized_value: The localized name of the used resource. - :type localized_value: str + :ivar value: The name of the used resource. + :vartype value: str + :ivar localized_value: The localized name of the used resource. + :vartype localized_value: str """ _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, - } - - def __init__( - self, - *, - value: Optional[str] = None, - localized_value: Optional[str] = None, - **kwargs - ): - super(LocalizedName, self).__init__(**kwargs) + "value": {"key": "value", "type": "str"}, + "localized_value": {"key": "localizedValue", "type": "str"}, + } + + def __init__(self, *, value: Optional[str] = None, localized_value: Optional[str] = None, **kwargs): + """ + :keyword value: The name of the used resource. + :paramtype value: str + :keyword localized_value: The localized name of the used resource. + :paramtype localized_value: str + """ + super().__init__(**kwargs) self.value = value self.localized_value = localized_value -class MetricSpecifications(msrest.serialization.Model): +class MetricSpecifications(_serialization.Model): # pylint: disable=too-many-instance-attributes """The details of metric specifications. - :param name: The name of the metric specification. - :type name: str - :param display_name: The display name of the metric specification. - :type display_name: str - :param display_description: The display description of the metric specification. - :type display_description: str - :param unit: The unit of the metric specification. - :type unit: str - :param aggregation_type: The aggregation type of the metric specification. - :type aggregation_type: str - :param supported_aggregation_types: The supported aggregation types of the metric - specification. - :type supported_aggregation_types: list[str] - :param supported_time_grain_types: The supported time grain types of the metric specification. - :type supported_time_grain_types: list[str] - :param enable_regional_mdm_account: The flag indicates whether enable regional mdm account or + :ivar name: The name of the metric specification. + :vartype name: str + :ivar display_name: The display name of the metric specification. + :vartype display_name: str + :ivar display_description: The display description of the metric specification. + :vartype display_description: str + :ivar unit: The unit of the metric specification. + :vartype unit: str + :ivar aggregation_type: The aggregation type of the metric specification. + :vartype aggregation_type: str + :ivar supported_aggregation_types: The supported aggregation types of the metric specification. + :vartype supported_aggregation_types: list[str] + :ivar supported_time_grain_types: The supported time grain types of the metric specification. + :vartype supported_time_grain_types: list[str] + :ivar enable_regional_mdm_account: The flag indicates whether enable regional mdm account or not. - :type enable_regional_mdm_account: bool - :param source_mdm_account: The source mdm account. - :type source_mdm_account: str - :param source_mdm_namespace: The source mdm namespace. - :type source_mdm_namespace: str - :param metric_filter_pattern: The metric filter pattern. - :type metric_filter_pattern: str - :param fill_gap_with_zero: The flag indicates whether filling gap with zero. - :type fill_gap_with_zero: bool - :param category: The category of the metric. - :type category: str - :param resource_id_dimension_name_override: The override name of resource id dimension name. - :type resource_id_dimension_name_override: str - :param is_internal: The flag indicates whether the metric is internal or not. - :type is_internal: bool - :param delegate_metric_name_override: The override name of delegate metric. - :type delegate_metric_name_override: str - :param dimensions: The dimensions of the metric specification. - :type dimensions: list[~azure.mgmt.hdinsight.models.Dimension] + :vartype enable_regional_mdm_account: bool + :ivar source_mdm_account: The source mdm account. + :vartype source_mdm_account: str + :ivar source_mdm_namespace: The source mdm namespace. + :vartype source_mdm_namespace: str + :ivar metric_filter_pattern: The metric filter pattern. + :vartype metric_filter_pattern: str + :ivar fill_gap_with_zero: The flag indicates whether filling gap with zero. + :vartype fill_gap_with_zero: bool + :ivar category: The category of the metric. + :vartype category: str + :ivar resource_id_dimension_name_override: The override name of resource id dimension name. + :vartype resource_id_dimension_name_override: str + :ivar is_internal: The flag indicates whether the metric is internal or not. + :vartype is_internal: bool + :ivar delegate_metric_name_override: The override name of delegate metric. + :vartype delegate_metric_name_override: str + :ivar dimensions: The dimensions of the metric specification. + :vartype dimensions: list[~azure.mgmt.hdinsight.models.Dimension] """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, - 'supported_aggregation_types': {'key': 'supportedAggregationTypes', 'type': '[str]'}, - 'supported_time_grain_types': {'key': 'supportedTimeGrainTypes', 'type': '[str]'}, - 'enable_regional_mdm_account': {'key': 'enableRegionalMdmAccount', 'type': 'bool'}, - 'source_mdm_account': {'key': 'sourceMdmAccount', 'type': 'str'}, - 'source_mdm_namespace': {'key': 'sourceMdmNamespace', 'type': 'str'}, - 'metric_filter_pattern': {'key': 'metricFilterPattern', 'type': 'str'}, - 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'bool'}, - 'category': {'key': 'category', 'type': 'str'}, - 'resource_id_dimension_name_override': {'key': 'resourceIdDimensionNameOverride', 'type': 'str'}, - 'is_internal': {'key': 'isInternal', 'type': 'bool'}, - 'delegate_metric_name_override': {'key': 'delegateMetricNameOverride', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[Dimension]'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "display_description": {"key": "displayDescription", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "aggregation_type": {"key": "aggregationType", "type": "str"}, + "supported_aggregation_types": {"key": "supportedAggregationTypes", "type": "[str]"}, + "supported_time_grain_types": {"key": "supportedTimeGrainTypes", "type": "[str]"}, + "enable_regional_mdm_account": {"key": "enableRegionalMdmAccount", "type": "bool"}, + "source_mdm_account": {"key": "sourceMdmAccount", "type": "str"}, + "source_mdm_namespace": {"key": "sourceMdmNamespace", "type": "str"}, + "metric_filter_pattern": {"key": "metricFilterPattern", "type": "str"}, + "fill_gap_with_zero": {"key": "fillGapWithZero", "type": "bool"}, + "category": {"key": "category", "type": "str"}, + "resource_id_dimension_name_override": {"key": "resourceIdDimensionNameOverride", "type": "str"}, + "is_internal": {"key": "isInternal", "type": "bool"}, + "delegate_metric_name_override": {"key": "delegateMetricNameOverride", "type": "str"}, + "dimensions": {"key": "dimensions", "type": "[Dimension]"}, } def __init__( @@ -2406,10 +2836,49 @@ def __init__( resource_id_dimension_name_override: Optional[str] = None, is_internal: Optional[bool] = None, delegate_metric_name_override: Optional[str] = None, - dimensions: Optional[List["Dimension"]] = None, + dimensions: Optional[List["_models.Dimension"]] = None, **kwargs ): - super(MetricSpecifications, self).__init__(**kwargs) + """ + :keyword name: The name of the metric specification. + :paramtype name: str + :keyword display_name: The display name of the metric specification. + :paramtype display_name: str + :keyword display_description: The display description of the metric specification. + :paramtype display_description: str + :keyword unit: The unit of the metric specification. + :paramtype unit: str + :keyword aggregation_type: The aggregation type of the metric specification. + :paramtype aggregation_type: str + :keyword supported_aggregation_types: The supported aggregation types of the metric + specification. + :paramtype supported_aggregation_types: list[str] + :keyword supported_time_grain_types: The supported time grain types of the metric + specification. + :paramtype supported_time_grain_types: list[str] + :keyword enable_regional_mdm_account: The flag indicates whether enable regional mdm account or + not. + :paramtype enable_regional_mdm_account: bool + :keyword source_mdm_account: The source mdm account. + :paramtype source_mdm_account: str + :keyword source_mdm_namespace: The source mdm namespace. + :paramtype source_mdm_namespace: str + :keyword metric_filter_pattern: The metric filter pattern. + :paramtype metric_filter_pattern: str + :keyword fill_gap_with_zero: The flag indicates whether filling gap with zero. + :paramtype fill_gap_with_zero: bool + :keyword category: The category of the metric. + :paramtype category: str + :keyword resource_id_dimension_name_override: The override name of resource id dimension name. + :paramtype resource_id_dimension_name_override: str + :keyword is_internal: The flag indicates whether the metric is internal or not. + :paramtype is_internal: bool + :keyword delegate_metric_name_override: The override name of delegate metric. + :paramtype delegate_metric_name_override: str + :keyword dimensions: The dimensions of the metric specification. + :paramtype dimensions: list[~azure.mgmt.hdinsight.models.Dimension] + """ + super().__init__(**kwargs) self.name = name self.display_name = display_name self.display_description = display_description @@ -2429,39 +2898,39 @@ def __init__( self.dimensions = dimensions -class NameAvailabilityCheckRequestParameters(msrest.serialization.Model): +class NameAvailabilityCheckRequestParameters(_serialization.Model): """The request spec of checking name availability. - :param name: The resource name. - :type name: str - :param type: The resource type. - :type type: str + :ivar name: The resource name. + :vartype name: str + :ivar type: The resource type. + :vartype type: str """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - type: Optional[str] = None, - **kwargs - ): - super(NameAvailabilityCheckRequestParameters, self).__init__(**kwargs) + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, *, name: Optional[str] = None, type: Optional[str] = None, **kwargs): + """ + :keyword name: The resource name. + :paramtype name: str + :keyword type: The resource type. + :paramtype type: str + """ + super().__init__(**kwargs) self.name = name self.type = type -class NameAvailabilityCheckResult(msrest.serialization.Model): +class NameAvailabilityCheckResult(_serialization.Model): """The response spec of checking name availability. Variables are only populated by the server, and will be ignored when sending a request. - :param name_available: This indicates whether the name is available. - :type name_available: bool + :ivar name_available: This indicates whether the name is available. + :vartype name_available: bool :ivar reason: The reason of the result. :vartype reason: str :ivar message: The related message. @@ -2469,106 +2938,122 @@ class NameAvailabilityCheckResult(msrest.serialization.Model): """ _validation = { - 'reason': {'readonly': True}, - 'message': {'readonly': True}, + "reason": {"readonly": True}, + "message": {"readonly": True}, } _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - name_available: Optional[bool] = None, - **kwargs - ): - super(NameAvailabilityCheckResult, self).__init__(**kwargs) + def __init__(self, *, name_available: Optional[bool] = None, **kwargs): + """ + :keyword name_available: This indicates whether the name is available. + :paramtype name_available: bool + """ + super().__init__(**kwargs) self.name_available = name_available self.reason = None self.message = None -class NetworkProperties(msrest.serialization.Model): +class NetworkProperties(_serialization.Model): """The network properties. - :param resource_provider_connection: The direction for the resource provider connection. - Possible values include: "Inbound", "Outbound". - :type resource_provider_connection: str or + :ivar resource_provider_connection: The direction for the resource provider connection. Known + values are: "Inbound" and "Outbound". + :vartype resource_provider_connection: str or ~azure.mgmt.hdinsight.models.ResourceProviderConnection - :param private_link: Indicates whether or not private link is enabled. Possible values include: - "Disabled", "Enabled". - :type private_link: str or ~azure.mgmt.hdinsight.models.PrivateLink + :ivar private_link: Indicates whether or not private link is enabled. Known values are: + "Disabled" and "Enabled". + :vartype private_link: str or ~azure.mgmt.hdinsight.models.PrivateLink """ _attribute_map = { - 'resource_provider_connection': {'key': 'resourceProviderConnection', 'type': 'str'}, - 'private_link': {'key': 'privateLink', 'type': 'str'}, + "resource_provider_connection": {"key": "resourceProviderConnection", "type": "str"}, + "private_link": {"key": "privateLink", "type": "str"}, } def __init__( self, *, - resource_provider_connection: Optional[Union[str, "ResourceProviderConnection"]] = None, - private_link: Optional[Union[str, "PrivateLink"]] = None, + resource_provider_connection: Optional[Union[str, "_models.ResourceProviderConnection"]] = None, + private_link: Optional[Union[str, "_models.PrivateLink"]] = None, **kwargs ): - super(NetworkProperties, self).__init__(**kwargs) + """ + :keyword resource_provider_connection: The direction for the resource provider connection. + Known values are: "Inbound" and "Outbound". + :paramtype resource_provider_connection: str or + ~azure.mgmt.hdinsight.models.ResourceProviderConnection + :keyword private_link: Indicates whether or not private link is enabled. Known values are: + "Disabled" and "Enabled". + :paramtype private_link: str or ~azure.mgmt.hdinsight.models.PrivateLink + """ + super().__init__(**kwargs) self.resource_provider_connection = resource_provider_connection self.private_link = private_link -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """The HDInsight REST API operation. - :param name: The operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: The display of operation. - :type display: ~azure.mgmt.hdinsight.models.OperationDisplay - :param properties: The operation properties. - :type properties: ~azure.mgmt.hdinsight.models.OperationProperties + :ivar name: The operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The display of operation. + :vartype display: ~azure.mgmt.hdinsight.models.OperationDisplay + :ivar properties: The operation properties. + :vartype properties: ~azure.mgmt.hdinsight.models.OperationProperties """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'properties': {'key': 'properties', 'type': 'OperationProperties'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "properties": {"key": "properties", "type": "OperationProperties"}, } def __init__( self, *, name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, - properties: Optional["OperationProperties"] = None, + display: Optional["_models.OperationDisplay"] = None, + properties: Optional["_models.OperationProperties"] = None, **kwargs ): - super(Operation, self).__init__(**kwargs) + """ + :keyword name: The operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: The display of operation. + :paramtype display: ~azure.mgmt.hdinsight.models.OperationDisplay + :keyword properties: The operation properties. + :paramtype properties: ~azure.mgmt.hdinsight.models.OperationProperties + """ + super().__init__(**kwargs) self.name = name self.display = display self.properties = properties -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """The object that represents the operation. - :param provider: The service provider: Microsoft.HDInsight. - :type provider: str - :param resource: The resource on which the operation is performed: Cluster, Applications, etc. - :type resource: str - :param operation: The operation type: read, write, delete, etc. - :type operation: str - :param description: Localized friendly description for the operation. - :type description: str + :ivar provider: The service provider: Microsoft.HDInsight. + :vartype provider: str + :ivar resource: The resource on which the operation is performed: Cluster, Applications, etc. + :vartype resource: str + :ivar operation: The operation type: read, write, delete, etc. + :vartype operation: str + :ivar description: Localized friendly description for the operation. + :vartype description: str """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -2580,103 +3065,115 @@ def __init__( description: Optional[str] = None, **kwargs ): - super(OperationDisplay, self).__init__(**kwargs) + """ + :keyword provider: The service provider: Microsoft.HDInsight. + :paramtype provider: str + :keyword resource: The resource on which the operation is performed: Cluster, Applications, + etc. + :paramtype resource: str + :keyword operation: The operation type: read, write, delete, etc. + :paramtype operation: str + :keyword description: Localized friendly description for the operation. + :paramtype description: str + """ + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list HDInsight operations. It contains a list of operations and a URL link to get the next set of results. - :param value: The list of HDInsight operations supported by the HDInsight resource provider. - :type value: list[~azure.mgmt.hdinsight.models.Operation] - :param next_link: The URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: The list of HDInsight operations supported by the HDInsight resource provider. + :vartype value: list[~azure.mgmt.hdinsight.models.Operation] + :ivar next_link: The URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - *, - value: Optional[List["Operation"]] = None, - next_link: Optional[str] = None, - **kwargs - ): - super(OperationListResult, self).__init__(**kwargs) + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs): + """ + :keyword value: The list of HDInsight operations supported by the HDInsight resource provider. + :paramtype value: list[~azure.mgmt.hdinsight.models.Operation] + :keyword next_link: The URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ + super().__init__(**kwargs) self.value = value self.next_link = next_link -class OperationProperties(msrest.serialization.Model): +class OperationProperties(_serialization.Model): """The details of operation. - :param service_specification: The specification of the service. - :type service_specification: ~azure.mgmt.hdinsight.models.ServiceSpecification + :ivar service_specification: The specification of the service. + :vartype service_specification: ~azure.mgmt.hdinsight.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: The specification of the service. + :paramtype service_specification: ~azure.mgmt.hdinsight.models.ServiceSpecification + """ + super().__init__(**kwargs) self.service_specification = service_specification -class OsProfile(msrest.serialization.Model): +class OsProfile(_serialization.Model): """The Linux operation systems profile. - :param linux_operating_system_profile: The Linux OS profile. - :type linux_operating_system_profile: ~azure.mgmt.hdinsight.models.LinuxOperatingSystemProfile + :ivar linux_operating_system_profile: The Linux OS profile. + :vartype linux_operating_system_profile: + ~azure.mgmt.hdinsight.models.LinuxOperatingSystemProfile """ _attribute_map = { - 'linux_operating_system_profile': {'key': 'linuxOperatingSystemProfile', 'type': 'LinuxOperatingSystemProfile'}, + "linux_operating_system_profile": {"key": "linuxOperatingSystemProfile", "type": "LinuxOperatingSystemProfile"}, } def __init__( - self, - *, - linux_operating_system_profile: Optional["LinuxOperatingSystemProfile"] = None, - **kwargs + self, *, linux_operating_system_profile: Optional["_models.LinuxOperatingSystemProfile"] = None, **kwargs ): - super(OsProfile, self).__init__(**kwargs) + """ + :keyword linux_operating_system_profile: The Linux OS profile. + :paramtype linux_operating_system_profile: + ~azure.mgmt.hdinsight.models.LinuxOperatingSystemProfile + """ + super().__init__(**kwargs) self.linux_operating_system_profile = linux_operating_system_profile -class PrivateEndpoint(msrest.serialization.Model): +class PrivateEndpoint(_serialization.Model): """The private endpoint. - :param id: The private endpoint id. - :type id: str + :ivar id: The private endpoint id. + :vartype id: str """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: Optional[str] = None, - **kwargs - ): - super(PrivateEndpoint, self).__init__(**kwargs) + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin + """ + :keyword id: The private endpoint id. + :paramtype id: str + """ + super().__init__(**kwargs) self.id = id -class PrivateEndpointConnection(ResourceAutoGenerated): +class PrivateEndpointConnection(Resource): """The private endpoint connection. Variables are only populated by the server, and will be ignored when sending a request. @@ -2695,47 +3192,51 @@ class PrivateEndpointConnection(ResourceAutoGenerated): :vartype system_data: ~azure.mgmt.hdinsight.models.SystemData :ivar private_endpoint: The private endpoint of the private endpoint connection. :vartype private_endpoint: ~azure.mgmt.hdinsight.models.PrivateEndpoint - :param private_link_service_connection_state: Required. The private link service connection - state. - :type private_link_service_connection_state: + :ivar private_link_service_connection_state: The private link service connection state. + Required. + :vartype private_link_service_connection_state: ~azure.mgmt.hdinsight.models.PrivateLinkServiceConnectionState :ivar link_identifier: The link identifier. :vartype link_identifier: str - :ivar provisioning_state: The provisioning state, which only appears in the response. Possible - values include: "InProgress", "Updating", "Failed", "Succeeded", "Canceled", "Deleting". + :ivar provisioning_state: The provisioning state, which only appears in the response. Known + values are: "InProgress", "Updating", "Failed", "Succeeded", "Canceled", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.hdinsight.models.PrivateEndpointConnectionProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'private_endpoint': {'readonly': True}, - 'private_link_service_connection_state': {'required': True}, - 'link_identifier': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "private_endpoint": {"readonly": True}, + "private_link_service_connection_state": {"required": True}, + "link_identifier": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'private_endpoint': {'key': 'properties.privateEndpoint', 'type': 'PrivateEndpoint'}, - 'private_link_service_connection_state': {'key': 'properties.privateLinkServiceConnectionState', 'type': 'PrivateLinkServiceConnectionState'}, - 'link_identifier': {'key': 'properties.linkIdentifier', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - *, - private_link_service_connection_state: "PrivateLinkServiceConnectionState", - **kwargs - ): - super(PrivateEndpointConnection, self).__init__(**kwargs) + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpoint"}, + "private_link_service_connection_state": { + "key": "properties.privateLinkServiceConnectionState", + "type": "PrivateLinkServiceConnectionState", + }, + "link_identifier": {"key": "properties.linkIdentifier", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + } + + def __init__(self, *, private_link_service_connection_state: "_models.PrivateLinkServiceConnectionState", **kwargs): + """ + :keyword private_link_service_connection_state: The private link service connection state. + Required. + :paramtype private_link_service_connection_state: + ~azure.mgmt.hdinsight.models.PrivateLinkServiceConnectionState + """ + super().__init__(**kwargs) self.system_data = None self.private_endpoint = None self.private_link_service_connection_state = private_link_service_connection_state @@ -2743,38 +3244,37 @@ def __init__( self.provisioning_state = None -class PrivateEndpointConnectionListResult(msrest.serialization.Model): +class PrivateEndpointConnectionListResult(_serialization.Model): """The list private endpoint connections response. Variables are only populated by the server, and will be ignored when sending a request. - :param value: The list of private endpoint connections. - :type value: list[~azure.mgmt.hdinsight.models.PrivateEndpointConnection] + :ivar value: The list of private endpoint connections. + :vartype value: list[~azure.mgmt.hdinsight.models.PrivateEndpointConnection] :ivar next_link: The link (url) to the next page of results. :vartype next_link: str """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateEndpointConnection]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["PrivateEndpointConnection"]] = None, - **kwargs - ): - super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) + def __init__(self, *, value: Optional[List["_models.PrivateEndpointConnection"]] = None, **kwargs): + """ + :keyword value: The list of private endpoint connections. + :paramtype value: list[~azure.mgmt.hdinsight.models.PrivateEndpointConnection] + """ + super().__init__(**kwargs) self.value = value self.next_link = None -class PrivateLinkConfiguration(msrest.serialization.Model): +class PrivateLinkConfiguration(_serialization.Model): """The private link configuration. Variables are only populated by the server, and will be ignored when sending a request. @@ -2783,49 +3283,51 @@ class PrivateLinkConfiguration(msrest.serialization.Model): :ivar id: The private link configuration id. :vartype id: str - :param name: Required. The name of private link configuration. - :type name: str + :ivar name: The name of private link configuration. Required. + :vartype name: str :ivar type: The type of the private link configuration. :vartype type: str - :param group_id: Required. The HDInsight private linkable sub-resource name to apply the - private link configuration to. For example, 'headnode', 'gateway', 'edgenode'. - :type group_id: str + :ivar group_id: The HDInsight private linkable sub-resource name to apply the private link + configuration to. For example, 'headnode', 'gateway', 'edgenode'. Required. + :vartype group_id: str :ivar provisioning_state: The private link configuration provisioning state, which only appears - in the response. Possible values include: "InProgress", "Failed", "Succeeded", "Canceled", + in the response. Known values are: "InProgress", "Failed", "Succeeded", "Canceled", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.hdinsight.models.PrivateLinkConfigurationProvisioningState - :param ip_configurations: Required. The IP configurations for the private link service. - :type ip_configurations: list[~azure.mgmt.hdinsight.models.IPConfiguration] + :ivar ip_configurations: The IP configurations for the private link service. Required. + :vartype ip_configurations: list[~azure.mgmt.hdinsight.models.IPConfiguration] """ _validation = { - 'id': {'readonly': True}, - 'name': {'required': True}, - 'type': {'readonly': True}, - 'group_id': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'ip_configurations': {'required': True}, + "id": {"readonly": True}, + "name": {"required": True}, + "type": {"readonly": True}, + "group_id": {"required": True}, + "provisioning_state": {"readonly": True}, + "ip_configurations": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'group_id': {'key': 'properties.groupId', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'ip_configurations': {'key': 'properties.ipConfigurations', 'type': '[IPConfiguration]'}, - } - - def __init__( - self, - *, - name: str, - group_id: str, - ip_configurations: List["IPConfiguration"], - **kwargs - ): - super(PrivateLinkConfiguration, self).__init__(**kwargs) + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "group_id": {"key": "properties.groupId", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "ip_configurations": {"key": "properties.ipConfigurations", "type": "[IPConfiguration]"}, + } + + def __init__(self, *, name: str, group_id: str, ip_configurations: List["_models.IPConfiguration"], **kwargs): + """ + :keyword name: The name of private link configuration. Required. + :paramtype name: str + :keyword group_id: The HDInsight private linkable sub-resource name to apply the private link + configuration to. For example, 'headnode', 'gateway', 'edgenode'. Required. + :paramtype group_id: str + :keyword ip_configurations: The IP configurations for the private link service. Required. + :paramtype ip_configurations: list[~azure.mgmt.hdinsight.models.IPConfiguration] + """ + super().__init__(**kwargs) self.id = None self.name = name self.type = None @@ -2834,7 +3336,7 @@ def __init__( self.ip_configurations = ip_configurations -class PrivateLinkResource(Resource): +class PrivateLinkResource(ResourceAutoGenerated): """A private link resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2853,116 +3355,123 @@ class PrivateLinkResource(Resource): :vartype group_id: str :ivar required_members: The private link resource required member names. :vartype required_members: list[str] - :param required_zone_names: The private link resource Private link DNS zone name. - :type required_zone_names: list[str] + :ivar required_zone_names: The private link resource Private link DNS zone name. + :vartype required_zone_names: list[str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'group_id': {'readonly': True}, - 'required_members': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "group_id": {"readonly": True}, + "required_members": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'group_id': {'key': 'properties.groupId', 'type': 'str'}, - 'required_members': {'key': 'properties.requiredMembers', 'type': '[str]'}, - 'required_zone_names': {'key': 'properties.requiredZoneNames', 'type': '[str]'}, - } - - def __init__( - self, - *, - required_zone_names: Optional[List[str]] = None, - **kwargs - ): - super(PrivateLinkResource, self).__init__(**kwargs) + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "group_id": {"key": "properties.groupId", "type": "str"}, + "required_members": {"key": "properties.requiredMembers", "type": "[str]"}, + "required_zone_names": {"key": "properties.requiredZoneNames", "type": "[str]"}, + } + + def __init__(self, *, required_zone_names: Optional[List[str]] = None, **kwargs): + """ + :keyword required_zone_names: The private link resource Private link DNS zone name. + :paramtype required_zone_names: list[str] + """ + super().__init__(**kwargs) self.system_data = None self.group_id = None self.required_members = None self.required_zone_names = required_zone_names -class PrivateLinkResourceListResult(msrest.serialization.Model): +class PrivateLinkResourceListResult(_serialization.Model): """A list of private link resources. - :param value: Array of private link resources. - :type value: list[~azure.mgmt.hdinsight.models.PrivateLinkResource] + :ivar value: Array of private link resources. + :vartype value: list[~azure.mgmt.hdinsight.models.PrivateLinkResource] """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateLinkResource]'}, + "value": {"key": "value", "type": "[PrivateLinkResource]"}, } - def __init__( - self, - *, - value: Optional[List["PrivateLinkResource"]] = None, - **kwargs - ): - super(PrivateLinkResourceListResult, self).__init__(**kwargs) + def __init__(self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, **kwargs): + """ + :keyword value: Array of private link resources. + :paramtype value: list[~azure.mgmt.hdinsight.models.PrivateLinkResource] + """ + super().__init__(**kwargs) self.value = value -class PrivateLinkServiceConnectionState(msrest.serialization.Model): +class PrivateLinkServiceConnectionState(_serialization.Model): """The private link service connection state. All required parameters must be populated in order to send to Azure. - :param status: Required. The concrete private link service connection. Possible values include: - "Approved", "Rejected", "Pending", "Removed". - :type status: str or ~azure.mgmt.hdinsight.models.PrivateLinkServiceConnectionStatus - :param description: The optional description of the status. - :type description: str - :param actions_required: Whether there is further actions. - :type actions_required: str + :ivar status: The concrete private link service connection. Required. Known values are: + "Approved", "Rejected", "Pending", and "Removed". + :vartype status: str or ~azure.mgmt.hdinsight.models.PrivateLinkServiceConnectionStatus + :ivar description: The optional description of the status. + :vartype description: str + :ivar actions_required: Whether there is further actions. + :vartype actions_required: str """ _validation = { - 'status': {'required': True}, + "status": {"required": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'actions_required': {'key': 'actionsRequired', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "actions_required": {"key": "actionsRequired", "type": "str"}, } def __init__( self, *, - status: Union[str, "PrivateLinkServiceConnectionStatus"], + status: Union[str, "_models.PrivateLinkServiceConnectionStatus"], description: Optional[str] = None, actions_required: Optional[str] = None, **kwargs ): - super(PrivateLinkServiceConnectionState, self).__init__(**kwargs) + """ + :keyword status: The concrete private link service connection. Required. Known values are: + "Approved", "Rejected", "Pending", and "Removed". + :paramtype status: str or ~azure.mgmt.hdinsight.models.PrivateLinkServiceConnectionStatus + :keyword description: The optional description of the status. + :paramtype description: str + :keyword actions_required: Whether there is further actions. + :paramtype actions_required: str + """ + super().__init__(**kwargs) self.status = status self.description = description self.actions_required = actions_required -class QuotaCapability(msrest.serialization.Model): +class QuotaCapability(_serialization.Model): """The regional quota capability. - :param cores_used: The number of cores used in the subscription. - :type cores_used: long - :param max_cores_allowed: The number of cores that the subscription allowed. - :type max_cores_allowed: long - :param regional_quotas: The list of region quota capabilities. - :type regional_quotas: list[~azure.mgmt.hdinsight.models.RegionalQuotaCapability] + :ivar cores_used: The number of cores used in the subscription. + :vartype cores_used: int + :ivar max_cores_allowed: The number of cores that the subscription allowed. + :vartype max_cores_allowed: int + :ivar regional_quotas: The list of region quota capabilities. + :vartype regional_quotas: list[~azure.mgmt.hdinsight.models.RegionalQuotaCapability] """ _attribute_map = { - 'cores_used': {'key': 'coresUsed', 'type': 'long'}, - 'max_cores_allowed': {'key': 'maxCoresAllowed', 'type': 'long'}, - 'regional_quotas': {'key': 'regionalQuotas', 'type': '[RegionalQuotaCapability]'}, + "cores_used": {"key": "coresUsed", "type": "int"}, + "max_cores_allowed": {"key": "maxCoresAllowed", "type": "int"}, + "regional_quotas": {"key": "regionalQuotas", "type": "[RegionalQuotaCapability]"}, } def __init__( @@ -2970,51 +3479,58 @@ def __init__( *, cores_used: Optional[int] = None, max_cores_allowed: Optional[int] = None, - regional_quotas: Optional[List["RegionalQuotaCapability"]] = None, + regional_quotas: Optional[List["_models.RegionalQuotaCapability"]] = None, **kwargs ): - super(QuotaCapability, self).__init__(**kwargs) + """ + :keyword cores_used: The number of cores used in the subscription. + :paramtype cores_used: int + :keyword max_cores_allowed: The number of cores that the subscription allowed. + :paramtype max_cores_allowed: int + :keyword regional_quotas: The list of region quota capabilities. + :paramtype regional_quotas: list[~azure.mgmt.hdinsight.models.RegionalQuotaCapability] + """ + super().__init__(**kwargs) self.cores_used = cores_used self.max_cores_allowed = max_cores_allowed self.regional_quotas = regional_quotas -class QuotaInfo(msrest.serialization.Model): +class QuotaInfo(_serialization.Model): """The quota properties for the cluster. - :param cores_used: The cores used by the cluster. - :type cores_used: int + :ivar cores_used: The cores used by the cluster. + :vartype cores_used: int """ _attribute_map = { - 'cores_used': {'key': 'coresUsed', 'type': 'int'}, + "cores_used": {"key": "coresUsed", "type": "int"}, } - def __init__( - self, - *, - cores_used: Optional[int] = None, - **kwargs - ): - super(QuotaInfo, self).__init__(**kwargs) + def __init__(self, *, cores_used: Optional[int] = None, **kwargs): + """ + :keyword cores_used: The cores used by the cluster. + :paramtype cores_used: int + """ + super().__init__(**kwargs) self.cores_used = cores_used -class RegionalQuotaCapability(msrest.serialization.Model): +class RegionalQuotaCapability(_serialization.Model): """The regional quota capacity. - :param region_name: The region name. - :type region_name: str - :param cores_used: The number of cores used in the region. - :type cores_used: long - :param cores_available: The number of cores available in the region. - :type cores_available: long + :ivar region_name: The region name. + :vartype region_name: str + :ivar cores_used: The number of cores used in the region. + :vartype cores_used: int + :ivar cores_available: The number of cores available in the region. + :vartype cores_available: int """ _attribute_map = { - 'region_name': {'key': 'regionName', 'type': 'str'}, - 'cores_used': {'key': 'coresUsed', 'type': 'long'}, - 'cores_available': {'key': 'coresAvailable', 'type': 'long'}, + "region_name": {"key": "regionName", "type": "str"}, + "cores_used": {"key": "coresUsed", "type": "int"}, + "cores_available": {"key": "coresAvailable", "type": "int"}, } def __init__( @@ -3025,93 +3541,99 @@ def __init__( cores_available: Optional[int] = None, **kwargs ): - super(RegionalQuotaCapability, self).__init__(**kwargs) + """ + :keyword region_name: The region name. + :paramtype region_name: str + :keyword cores_used: The number of cores used in the region. + :paramtype cores_used: int + :keyword cores_available: The number of cores available in the region. + :paramtype cores_available: int + """ + super().__init__(**kwargs) self.region_name = region_name self.cores_used = cores_used self.cores_available = cores_available -class RegionsCapability(msrest.serialization.Model): +class RegionsCapability(_serialization.Model): """The regions capability. - :param available: The list of region capabilities. - :type available: list[str] + :ivar available: The list of region capabilities. + :vartype available: list[str] """ _attribute_map = { - 'available': {'key': 'available', 'type': '[str]'}, + "available": {"key": "available", "type": "[str]"}, } - def __init__( - self, - *, - available: Optional[List[str]] = None, - **kwargs - ): - super(RegionsCapability, self).__init__(**kwargs) + def __init__(self, *, available: Optional[List[str]] = None, **kwargs): + """ + :keyword available: The list of region capabilities. + :paramtype available: list[str] + """ + super().__init__(**kwargs) self.available = available -class ResourceId(msrest.serialization.Model): +class ResourceId(_serialization.Model): """The azure resource id. - :param id: The azure resource id. - :type id: str + :ivar id: The azure resource id. + :vartype id: str """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: Optional[str] = None, - **kwargs - ): - super(ResourceId, self).__init__(**kwargs) + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin + """ + :keyword id: The azure resource id. + :paramtype id: str + """ + super().__init__(**kwargs) self.id = id -class Role(msrest.serialization.Model): +class Role(_serialization.Model): # pylint: disable=too-many-instance-attributes """Describes a role on the cluster. - :param name: The name of the role. - :type name: str - :param min_instance_count: The minimum instance count of the cluster. - :type min_instance_count: int - :param target_instance_count: The instance count of the cluster. - :type target_instance_count: int - :param vm_group_name: The name of the virtual machine group. - :type vm_group_name: str - :param autoscale_configuration: The autoscale configurations. - :type autoscale_configuration: ~azure.mgmt.hdinsight.models.Autoscale - :param hardware_profile: The hardware profile. - :type hardware_profile: ~azure.mgmt.hdinsight.models.HardwareProfile - :param os_profile: The operating system profile. - :type os_profile: ~azure.mgmt.hdinsight.models.OsProfile - :param virtual_network_profile: The virtual network profile. - :type virtual_network_profile: ~azure.mgmt.hdinsight.models.VirtualNetworkProfile - :param data_disks_groups: The data disks groups for the role. - :type data_disks_groups: list[~azure.mgmt.hdinsight.models.DataDisksGroups] - :param script_actions: The list of script actions on the role. - :type script_actions: list[~azure.mgmt.hdinsight.models.ScriptAction] - :param encrypt_data_disks: Indicates whether encrypt the data disks. - :type encrypt_data_disks: bool + :ivar name: The name of the role. + :vartype name: str + :ivar min_instance_count: The minimum instance count of the cluster. + :vartype min_instance_count: int + :ivar target_instance_count: The instance count of the cluster. + :vartype target_instance_count: int + :ivar vm_group_name: The name of the virtual machine group. + :vartype vm_group_name: str + :ivar autoscale_configuration: The autoscale configurations. + :vartype autoscale_configuration: ~azure.mgmt.hdinsight.models.Autoscale + :ivar hardware_profile: The hardware profile. + :vartype hardware_profile: ~azure.mgmt.hdinsight.models.HardwareProfile + :ivar os_profile: The operating system profile. + :vartype os_profile: ~azure.mgmt.hdinsight.models.OsProfile + :ivar virtual_network_profile: The virtual network profile. + :vartype virtual_network_profile: ~azure.mgmt.hdinsight.models.VirtualNetworkProfile + :ivar data_disks_groups: The data disks groups for the role. + :vartype data_disks_groups: list[~azure.mgmt.hdinsight.models.DataDisksGroups] + :ivar script_actions: The list of script actions on the role. + :vartype script_actions: list[~azure.mgmt.hdinsight.models.ScriptAction] + :ivar encrypt_data_disks: Indicates whether encrypt the data disks. + :vartype encrypt_data_disks: bool """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'min_instance_count': {'key': 'minInstanceCount', 'type': 'int'}, - 'target_instance_count': {'key': 'targetInstanceCount', 'type': 'int'}, - 'vm_group_name': {'key': 'VMGroupName', 'type': 'str'}, - 'autoscale_configuration': {'key': 'autoscale', 'type': 'Autoscale'}, - 'hardware_profile': {'key': 'hardwareProfile', 'type': 'HardwareProfile'}, - 'os_profile': {'key': 'osProfile', 'type': 'OsProfile'}, - 'virtual_network_profile': {'key': 'virtualNetworkProfile', 'type': 'VirtualNetworkProfile'}, - 'data_disks_groups': {'key': 'dataDisksGroups', 'type': '[DataDisksGroups]'}, - 'script_actions': {'key': 'scriptActions', 'type': '[ScriptAction]'}, - 'encrypt_data_disks': {'key': 'encryptDataDisks', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "min_instance_count": {"key": "minInstanceCount", "type": "int"}, + "target_instance_count": {"key": "targetInstanceCount", "type": "int"}, + "vm_group_name": {"key": "VMGroupName", "type": "str"}, + "autoscale_configuration": {"key": "autoscale", "type": "Autoscale"}, + "hardware_profile": {"key": "hardwareProfile", "type": "HardwareProfile"}, + "os_profile": {"key": "osProfile", "type": "OsProfile"}, + "virtual_network_profile": {"key": "virtualNetworkProfile", "type": "VirtualNetworkProfile"}, + "data_disks_groups": {"key": "dataDisksGroups", "type": "[DataDisksGroups]"}, + "script_actions": {"key": "scriptActions", "type": "[ScriptAction]"}, + "encrypt_data_disks": {"key": "encryptDataDisks", "type": "bool"}, } def __init__( @@ -3121,16 +3643,40 @@ def __init__( min_instance_count: Optional[int] = None, target_instance_count: Optional[int] = None, vm_group_name: Optional[str] = None, - autoscale_configuration: Optional["Autoscale"] = None, - hardware_profile: Optional["HardwareProfile"] = None, - os_profile: Optional["OsProfile"] = None, - virtual_network_profile: Optional["VirtualNetworkProfile"] = None, - data_disks_groups: Optional[List["DataDisksGroups"]] = None, - script_actions: Optional[List["ScriptAction"]] = None, - encrypt_data_disks: Optional[bool] = False, + autoscale_configuration: Optional["_models.Autoscale"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + os_profile: Optional["_models.OsProfile"] = None, + virtual_network_profile: Optional["_models.VirtualNetworkProfile"] = None, + data_disks_groups: Optional[List["_models.DataDisksGroups"]] = None, + script_actions: Optional[List["_models.ScriptAction"]] = None, + encrypt_data_disks: bool = False, **kwargs ): - super(Role, self).__init__(**kwargs) + """ + :keyword name: The name of the role. + :paramtype name: str + :keyword min_instance_count: The minimum instance count of the cluster. + :paramtype min_instance_count: int + :keyword target_instance_count: The instance count of the cluster. + :paramtype target_instance_count: int + :keyword vm_group_name: The name of the virtual machine group. + :paramtype vm_group_name: str + :keyword autoscale_configuration: The autoscale configurations. + :paramtype autoscale_configuration: ~azure.mgmt.hdinsight.models.Autoscale + :keyword hardware_profile: The hardware profile. + :paramtype hardware_profile: ~azure.mgmt.hdinsight.models.HardwareProfile + :keyword os_profile: The operating system profile. + :paramtype os_profile: ~azure.mgmt.hdinsight.models.OsProfile + :keyword virtual_network_profile: The virtual network profile. + :paramtype virtual_network_profile: ~azure.mgmt.hdinsight.models.VirtualNetworkProfile + :keyword data_disks_groups: The data disks groups for the role. + :paramtype data_disks_groups: list[~azure.mgmt.hdinsight.models.DataDisksGroups] + :keyword script_actions: The list of script actions on the role. + :paramtype script_actions: list[~azure.mgmt.hdinsight.models.ScriptAction] + :keyword encrypt_data_disks: Indicates whether encrypt the data disks. + :paramtype encrypt_data_disks: bool + """ + super().__init__(**kwargs) self.name = name self.min_instance_count = min_instance_count self.target_instance_count = target_instance_count @@ -3144,50 +3690,52 @@ def __init__( self.encrypt_data_disks = encrypt_data_disks -class RuntimeScriptAction(msrest.serialization.Model): +class RuntimeScriptAction(_serialization.Model): """Describes a script action on a running cluster. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the script action. - :type name: str - :param uri: Required. The URI to the script. - :type uri: str - :param parameters: The parameters for the script. - :type parameters: str - :param roles: Required. The list of roles where script will be executed. - :type roles: list[str] + :ivar name: The name of the script action. Required. + :vartype name: str + :ivar uri: The URI to the script. Required. + :vartype uri: str + :ivar parameters: The parameters for the script. + :vartype parameters: str + :ivar roles: The list of roles where script will be executed. Required. + :vartype roles: list[str] :ivar application_name: The application name of the script action, if any. :vartype application_name: str """ _validation = { - 'name': {'required': True}, - 'uri': {'required': True}, - 'roles': {'required': True}, - 'application_name': {'readonly': True}, + "name": {"required": True}, + "uri": {"required": True}, + "roles": {"required": True}, + "application_name": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'parameters': {'key': 'parameters', 'type': 'str'}, - 'roles': {'key': 'roles', 'type': '[str]'}, - 'application_name': {'key': 'applicationName', 'type': 'str'}, - } - - def __init__( - self, - *, - name: str, - uri: str, - roles: List[str], - parameters: Optional[str] = None, - **kwargs - ): - super(RuntimeScriptAction, self).__init__(**kwargs) + "name": {"key": "name", "type": "str"}, + "uri": {"key": "uri", "type": "str"}, + "parameters": {"key": "parameters", "type": "str"}, + "roles": {"key": "roles", "type": "[str]"}, + "application_name": {"key": "applicationName", "type": "str"}, + } + + def __init__(self, *, name: str, uri: str, roles: List[str], parameters: Optional[str] = None, **kwargs): + """ + :keyword name: The name of the script action. Required. + :paramtype name: str + :keyword uri: The URI to the script. Required. + :paramtype uri: str + :keyword parameters: The parameters for the script. + :paramtype parameters: str + :keyword roles: The list of roles where script will be executed. Required. + :paramtype roles: list[str] + """ + super().__init__(**kwargs) self.name = name self.uri = uri self.parameters = parameters @@ -3195,25 +3743,25 @@ def __init__( self.application_name = None -class RuntimeScriptActionDetail(RuntimeScriptAction): +class RuntimeScriptActionDetail(RuntimeScriptAction): # pylint: disable=too-many-instance-attributes """The execution details of a script action. 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 name: Required. The name of the script action. - :type name: str - :param uri: Required. The URI to the script. - :type uri: str - :param parameters: The parameters for the script. - :type parameters: str - :param roles: Required. The list of roles where script will be executed. - :type roles: list[str] + :ivar name: The name of the script action. Required. + :vartype name: str + :ivar uri: The URI to the script. Required. + :vartype uri: str + :ivar parameters: The parameters for the script. + :vartype parameters: str + :ivar roles: The list of roles where script will be executed. Required. + :vartype roles: list[str] :ivar application_name: The application name of the script action, if any. :vartype application_name: str :ivar script_execution_id: The execution id of the script action. - :vartype script_execution_id: long + :vartype script_execution_id: int :ivar start_time: The start time of script action execution. :vartype start_time: str :ivar end_time: The end time of script action execution. @@ -3229,44 +3777,46 @@ class RuntimeScriptActionDetail(RuntimeScriptAction): """ _validation = { - 'name': {'required': True}, - 'uri': {'required': True}, - 'roles': {'required': True}, - 'application_name': {'readonly': True}, - 'script_execution_id': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, - 'status': {'readonly': True}, - 'operation': {'readonly': True}, - 'execution_summary': {'readonly': True}, - 'debug_information': {'readonly': True}, + "name": {"required": True}, + "uri": {"required": True}, + "roles": {"required": True}, + "application_name": {"readonly": True}, + "script_execution_id": {"readonly": True}, + "start_time": {"readonly": True}, + "end_time": {"readonly": True}, + "status": {"readonly": True}, + "operation": {"readonly": True}, + "execution_summary": {"readonly": True}, + "debug_information": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'parameters': {'key': 'parameters', 'type': 'str'}, - 'roles': {'key': 'roles', 'type': '[str]'}, - 'application_name': {'key': 'applicationName', 'type': 'str'}, - 'script_execution_id': {'key': 'scriptExecutionId', 'type': 'long'}, - 'start_time': {'key': 'startTime', 'type': 'str'}, - 'end_time': {'key': 'endTime', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'execution_summary': {'key': 'executionSummary', 'type': '[ScriptActionExecutionSummary]'}, - 'debug_information': {'key': 'debugInformation', 'type': 'str'}, - } - - def __init__( - self, - *, - name: str, - uri: str, - roles: List[str], - parameters: Optional[str] = None, - **kwargs - ): - super(RuntimeScriptActionDetail, self).__init__(name=name, uri=uri, parameters=parameters, roles=roles, **kwargs) + "name": {"key": "name", "type": "str"}, + "uri": {"key": "uri", "type": "str"}, + "parameters": {"key": "parameters", "type": "str"}, + "roles": {"key": "roles", "type": "[str]"}, + "application_name": {"key": "applicationName", "type": "str"}, + "script_execution_id": {"key": "scriptExecutionId", "type": "int"}, + "start_time": {"key": "startTime", "type": "str"}, + "end_time": {"key": "endTime", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "execution_summary": {"key": "executionSummary", "type": "[ScriptActionExecutionSummary]"}, + "debug_information": {"key": "debugInformation", "type": "str"}, + } + + def __init__(self, *, name: str, uri: str, roles: List[str], parameters: Optional[str] = None, **kwargs): + """ + :keyword name: The name of the script action. Required. + :paramtype name: str + :keyword uri: The URI to the script. Required. + :paramtype uri: str + :keyword parameters: The parameters for the script. + :paramtype parameters: str + :keyword roles: The list of roles where script will be executed. Required. + :paramtype roles: list[str] + """ + super().__init__(name=name, uri=uri, parameters=parameters, roles=roles, **kwargs) self.script_execution_id = None self.start_time = None self.end_time = None @@ -3276,46 +3826,47 @@ def __init__( self.debug_information = None -class ScriptAction(msrest.serialization.Model): +class ScriptAction(_serialization.Model): """Describes a script action on role on the cluster. All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the script action. - :type name: str - :param uri: Required. The URI to the script. - :type uri: str - :param parameters: Required. The parameters for the script provided. - :type parameters: str + :ivar name: The name of the script action. Required. + :vartype name: str + :ivar uri: The URI to the script. Required. + :vartype uri: str + :ivar parameters: The parameters for the script provided. Required. + :vartype parameters: str """ _validation = { - 'name': {'required': True}, - 'uri': {'required': True}, - 'parameters': {'required': True}, + "name": {"required": True}, + "uri": {"required": True}, + "parameters": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'parameters': {'key': 'parameters', 'type': 'str'}, - } - - def __init__( - self, - *, - name: str, - uri: str, - parameters: str, - **kwargs - ): - super(ScriptAction, self).__init__(**kwargs) + "name": {"key": "name", "type": "str"}, + "uri": {"key": "uri", "type": "str"}, + "parameters": {"key": "parameters", "type": "str"}, + } + + def __init__(self, *, name: str, uri: str, parameters: str, **kwargs): + """ + :keyword name: The name of the script action. Required. + :paramtype name: str + :keyword uri: The URI to the script. Required. + :paramtype uri: str + :keyword parameters: The parameters for the script provided. Required. + :paramtype parameters: str + """ + super().__init__(**kwargs) self.name = name self.uri = uri self.parameters = parameters -class ScriptActionExecutionHistoryList(msrest.serialization.Model): +class ScriptActionExecutionHistoryList(_serialization.Model): """The list script execution history response. Variables are only populated by the server, and will be ignored when sending a request. @@ -3327,25 +3878,23 @@ class ScriptActionExecutionHistoryList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[RuntimeScriptActionDetail]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[RuntimeScriptActionDetail]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - super(ScriptActionExecutionHistoryList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class ScriptActionExecutionSummary(msrest.serialization.Model): +class ScriptActionExecutionSummary(_serialization.Model): """The execution summary of a script action. Variables are only populated by the server, and will be ignored when sending a request. @@ -3357,45 +3906,43 @@ class ScriptActionExecutionSummary(msrest.serialization.Model): """ _validation = { - 'status': {'readonly': True}, - 'instance_count': {'readonly': True}, + "status": {"readonly": True}, + "instance_count": {"readonly": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'instance_count': {'key': 'instanceCount', 'type': 'int'}, + "status": {"key": "status", "type": "str"}, + "instance_count": {"key": "instanceCount", "type": "int"}, } - def __init__( - self, - **kwargs - ): - super(ScriptActionExecutionSummary, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.status = None self.instance_count = None -class ScriptActionPersistedGetResponseSpec(msrest.serialization.Model): +class ScriptActionPersistedGetResponseSpec(_serialization.Model): """The persisted script action for cluster. - :param name: The name of script action. - :type name: str - :param uri: The URI to the script. - :type uri: str - :param parameters: The parameters for the script provided. - :type parameters: str - :param roles: The list of roles where script will be executed. - :type roles: list[str] - :param application_name: The application name for the script action. - :type application_name: str + :ivar name: The name of script action. + :vartype name: str + :ivar uri: The URI to the script. + :vartype uri: str + :ivar parameters: The parameters for the script provided. + :vartype parameters: str + :ivar roles: The list of roles where script will be executed. + :vartype roles: list[str] + :ivar application_name: The application name for the script action. + :vartype application_name: str """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'uri': {'key': 'uri', 'type': 'str'}, - 'parameters': {'key': 'parameters', 'type': 'str'}, - 'roles': {'key': 'roles', 'type': '[str]'}, - 'application_name': {'key': 'applicationName', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "uri": {"key": "uri", "type": "str"}, + "parameters": {"key": "parameters", "type": "str"}, + "roles": {"key": "roles", "type": "[str]"}, + "application_name": {"key": "applicationName", "type": "str"}, } def __init__( @@ -3408,7 +3955,19 @@ def __init__( application_name: Optional[str] = None, **kwargs ): - super(ScriptActionPersistedGetResponseSpec, self).__init__(**kwargs) + """ + :keyword name: The name of script action. + :paramtype name: str + :keyword uri: The URI to the script. + :paramtype uri: str + :keyword parameters: The parameters for the script provided. + :paramtype parameters: str + :keyword roles: The list of roles where script will be executed. + :paramtype roles: list[str] + :keyword application_name: The application name for the script action. + :paramtype application_name: str + """ + super().__init__(**kwargs) self.name = name self.uri = uri self.parameters = parameters @@ -3416,78 +3975,77 @@ def __init__( self.application_name = application_name -class ScriptActionsList(msrest.serialization.Model): +class ScriptActionsList(_serialization.Model): """The persisted script action for the cluster. Variables are only populated by the server, and will be ignored when sending a request. - :param value: The list of persisted script action details for the cluster. - :type value: list[~azure.mgmt.hdinsight.models.RuntimeScriptActionDetail] + :ivar value: The list of persisted script action details for the cluster. + :vartype value: list[~azure.mgmt.hdinsight.models.RuntimeScriptActionDetail] :ivar next_link: The link (url) to the next page of results. :vartype next_link: str """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[RuntimeScriptActionDetail]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[RuntimeScriptActionDetail]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["RuntimeScriptActionDetail"]] = None, - **kwargs - ): - super(ScriptActionsList, self).__init__(**kwargs) + def __init__(self, *, value: Optional[List["_models.RuntimeScriptActionDetail"]] = None, **kwargs): + """ + :keyword value: The list of persisted script action details for the cluster. + :paramtype value: list[~azure.mgmt.hdinsight.models.RuntimeScriptActionDetail] + """ + super().__init__(**kwargs) self.value = value self.next_link = None -class SecurityProfile(msrest.serialization.Model): +class SecurityProfile(_serialization.Model): """The security profile which contains Ssh public key for the HDInsight cluster. - :param directory_type: The directory type. Possible values include: "ActiveDirectory". - :type directory_type: str or ~azure.mgmt.hdinsight.models.DirectoryType - :param domain: The organization's active directory domain. - :type domain: str - :param organizational_unit_dn: The organizational unit within the Active Directory to place the + :ivar directory_type: The directory type. "ActiveDirectory" + :vartype directory_type: str or ~azure.mgmt.hdinsight.models.DirectoryType + :ivar domain: The organization's active directory domain. + :vartype domain: str + :ivar organizational_unit_dn: The organizational unit within the Active Directory to place the cluster and service accounts. - :type organizational_unit_dn: str - :param ldaps_urls: The LDAPS protocol URLs to communicate with the Active Directory. - :type ldaps_urls: list[str] - :param domain_username: The domain user account that will have admin privileges on the cluster. - :type domain_username: str - :param domain_user_password: The domain admin password. - :type domain_user_password: str - :param cluster_users_group_d_ns: Optional. The Distinguished Names for cluster user groups. - :type cluster_users_group_d_ns: list[str] - :param aadds_resource_id: The resource ID of the user's Azure Active Directory Domain Service. - :type aadds_resource_id: str - :param msi_resource_id: User assigned identity that has permissions to read and create + :vartype organizational_unit_dn: str + :ivar ldaps_urls: The LDAPS protocol URLs to communicate with the Active Directory. + :vartype ldaps_urls: list[str] + :ivar domain_username: The domain user account that will have admin privileges on the cluster. + :vartype domain_username: str + :ivar domain_user_password: The domain admin password. + :vartype domain_user_password: str + :ivar cluster_users_group_d_ns: Optional. The Distinguished Names for cluster user groups. + :vartype cluster_users_group_d_ns: list[str] + :ivar aadds_resource_id: The resource ID of the user's Azure Active Directory Domain Service. + :vartype aadds_resource_id: str + :ivar msi_resource_id: User assigned identity that has permissions to read and create cluster-related artifacts in the user's AADDS. - :type msi_resource_id: str + :vartype msi_resource_id: str """ _attribute_map = { - 'directory_type': {'key': 'directoryType', 'type': 'str'}, - 'domain': {'key': 'domain', 'type': 'str'}, - 'organizational_unit_dn': {'key': 'organizationalUnitDN', 'type': 'str'}, - 'ldaps_urls': {'key': 'ldapsUrls', 'type': '[str]'}, - 'domain_username': {'key': 'domainUsername', 'type': 'str'}, - 'domain_user_password': {'key': 'domainUserPassword', 'type': 'str'}, - 'cluster_users_group_d_ns': {'key': 'clusterUsersGroupDNs', 'type': '[str]'}, - 'aadds_resource_id': {'key': 'aaddsResourceId', 'type': 'str'}, - 'msi_resource_id': {'key': 'msiResourceId', 'type': 'str'}, + "directory_type": {"key": "directoryType", "type": "str"}, + "domain": {"key": "domain", "type": "str"}, + "organizational_unit_dn": {"key": "organizationalUnitDN", "type": "str"}, + "ldaps_urls": {"key": "ldapsUrls", "type": "[str]"}, + "domain_username": {"key": "domainUsername", "type": "str"}, + "domain_user_password": {"key": "domainUserPassword", "type": "str"}, + "cluster_users_group_d_ns": {"key": "clusterUsersGroupDNs", "type": "[str]"}, + "aadds_resource_id": {"key": "aaddsResourceId", "type": "str"}, + "msi_resource_id": {"key": "msiResourceId", "type": "str"}, } def __init__( self, *, - directory_type: Optional[Union[str, "DirectoryType"]] = None, + directory_type: Optional[Union[str, "_models.DirectoryType"]] = None, domain: Optional[str] = None, organizational_unit_dn: Optional[str] = None, ldaps_urls: Optional[List[str]] = None, @@ -3498,7 +4056,31 @@ def __init__( msi_resource_id: Optional[str] = None, **kwargs ): - super(SecurityProfile, self).__init__(**kwargs) + """ + :keyword directory_type: The directory type. "ActiveDirectory" + :paramtype directory_type: str or ~azure.mgmt.hdinsight.models.DirectoryType + :keyword domain: The organization's active directory domain. + :paramtype domain: str + :keyword organizational_unit_dn: The organizational unit within the Active Directory to place + the cluster and service accounts. + :paramtype organizational_unit_dn: str + :keyword ldaps_urls: The LDAPS protocol URLs to communicate with the Active Directory. + :paramtype ldaps_urls: list[str] + :keyword domain_username: The domain user account that will have admin privileges on the + cluster. + :paramtype domain_username: str + :keyword domain_user_password: The domain admin password. + :paramtype domain_user_password: str + :keyword cluster_users_group_d_ns: Optional. The Distinguished Names for cluster user groups. + :paramtype cluster_users_group_d_ns: list[str] + :keyword aadds_resource_id: The resource ID of the user's Azure Active Directory Domain + Service. + :paramtype aadds_resource_id: str + :keyword msi_resource_id: User assigned identity that has permissions to read and create + cluster-related artifacts in the user's AADDS. + :paramtype msi_resource_id: str + """ + super().__init__(**kwargs) self.directory_type = directory_type self.domain = domain self.organizational_unit_dn = organizational_unit_dn @@ -3510,105 +4092,102 @@ def __init__( self.msi_resource_id = msi_resource_id -class ServiceSpecification(msrest.serialization.Model): +class ServiceSpecification(_serialization.Model): """The specification of the service. - :param metric_specifications: The metric specifications. - :type metric_specifications: list[~azure.mgmt.hdinsight.models.MetricSpecifications] + :ivar metric_specifications: The metric specifications. + :vartype metric_specifications: list[~azure.mgmt.hdinsight.models.MetricSpecifications] """ _attribute_map = { - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecifications]'}, + "metric_specifications": {"key": "metricSpecifications", "type": "[MetricSpecifications]"}, } - def __init__( - self, - *, - metric_specifications: Optional[List["MetricSpecifications"]] = None, - **kwargs - ): - super(ServiceSpecification, self).__init__(**kwargs) + def __init__(self, *, metric_specifications: Optional[List["_models.MetricSpecifications"]] = None, **kwargs): + """ + :keyword metric_specifications: The metric specifications. + :paramtype metric_specifications: list[~azure.mgmt.hdinsight.models.MetricSpecifications] + """ + super().__init__(**kwargs) self.metric_specifications = metric_specifications -class SshProfile(msrest.serialization.Model): +class SshProfile(_serialization.Model): """The list of SSH public keys. - :param public_keys: The list of SSH public keys. - :type public_keys: list[~azure.mgmt.hdinsight.models.SshPublicKey] + :ivar public_keys: The list of SSH public keys. + :vartype public_keys: list[~azure.mgmt.hdinsight.models.SshPublicKey] """ _attribute_map = { - 'public_keys': {'key': 'publicKeys', 'type': '[SshPublicKey]'}, + "public_keys": {"key": "publicKeys", "type": "[SshPublicKey]"}, } - def __init__( - self, - *, - public_keys: Optional[List["SshPublicKey"]] = None, - **kwargs - ): - super(SshProfile, self).__init__(**kwargs) + def __init__(self, *, public_keys: Optional[List["_models.SshPublicKey"]] = None, **kwargs): + """ + :keyword public_keys: The list of SSH public keys. + :paramtype public_keys: list[~azure.mgmt.hdinsight.models.SshPublicKey] + """ + super().__init__(**kwargs) self.public_keys = public_keys -class SshPublicKey(msrest.serialization.Model): +class SshPublicKey(_serialization.Model): """The SSH public key for the cluster nodes. - :param certificate_data: The certificate for SSH. - :type certificate_data: str + :ivar certificate_data: The certificate for SSH. + :vartype certificate_data: str """ _attribute_map = { - 'certificate_data': {'key': 'certificateData', 'type': 'str'}, + "certificate_data": {"key": "certificateData", "type": "str"}, } - def __init__( - self, - *, - certificate_data: Optional[str] = None, - **kwargs - ): - super(SshPublicKey, self).__init__(**kwargs) + def __init__(self, *, certificate_data: Optional[str] = None, **kwargs): + """ + :keyword certificate_data: The certificate for SSH. + :paramtype certificate_data: str + """ + super().__init__(**kwargs) self.certificate_data = certificate_data -class StorageAccount(msrest.serialization.Model): +class StorageAccount(_serialization.Model): """The storage Account. - :param name: The name of the storage account. - :type name: str - :param is_default: Whether or not the storage account is the default storage account. - :type is_default: bool - :param container: The container in the storage account, only to be specified for WASB storage + :ivar name: The name of the storage account. + :vartype name: str + :ivar is_default: Whether or not the storage account is the default storage account. + :vartype is_default: bool + :ivar container: The container in the storage account, only to be specified for WASB storage accounts. - :type container: str - :param file_system: The filesystem, only to be specified for Azure Data Lake Storage Gen 2. - :type file_system: str - :param key: The storage account access key. - :type key: str - :param resource_id: The resource ID of storage account, only to be specified for Azure Data - Lake Storage Gen 2. - :type resource_id: str - :param msi_resource_id: The managed identity (MSI) that is allowed to access the storage + :vartype container: str + :ivar file_system: The filesystem, only to be specified for Azure Data Lake Storage Gen 2. + :vartype file_system: str + :ivar key: The storage account access key. + :vartype key: str + :ivar resource_id: The resource ID of storage account, only to be specified for Azure Data Lake + Storage Gen 2. + :vartype resource_id: str + :ivar msi_resource_id: The managed identity (MSI) that is allowed to access the storage account, only to be specified for Azure Data Lake Storage Gen 2. - :type msi_resource_id: str - :param saskey: The shared access signature key. - :type saskey: str - :param fileshare: The file share name. - :type fileshare: str + :vartype msi_resource_id: str + :ivar saskey: The shared access signature key. + :vartype saskey: str + :ivar fileshare: The file share name. + :vartype fileshare: str """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'is_default': {'key': 'isDefault', 'type': 'bool'}, - 'container': {'key': 'container', 'type': 'str'}, - 'file_system': {'key': 'fileSystem', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'msi_resource_id': {'key': 'msiResourceId', 'type': 'str'}, - 'saskey': {'key': 'saskey', 'type': 'str'}, - 'fileshare': {'key': 'fileshare', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "is_default": {"key": "isDefault", "type": "bool"}, + "container": {"key": "container", "type": "str"}, + "file_system": {"key": "fileSystem", "type": "str"}, + "key": {"key": "key", "type": "str"}, + "resource_id": {"key": "resourceId", "type": "str"}, + "msi_resource_id": {"key": "msiResourceId", "type": "str"}, + "saskey": {"key": "saskey", "type": "str"}, + "fileshare": {"key": "fileshare", "type": "str"}, } def __init__( @@ -3625,7 +4204,30 @@ def __init__( fileshare: Optional[str] = None, **kwargs ): - super(StorageAccount, self).__init__(**kwargs) + """ + :keyword name: The name of the storage account. + :paramtype name: str + :keyword is_default: Whether or not the storage account is the default storage account. + :paramtype is_default: bool + :keyword container: The container in the storage account, only to be specified for WASB storage + accounts. + :paramtype container: str + :keyword file_system: The filesystem, only to be specified for Azure Data Lake Storage Gen 2. + :paramtype file_system: str + :keyword key: The storage account access key. + :paramtype key: str + :keyword resource_id: The resource ID of storage account, only to be specified for Azure Data + Lake Storage Gen 2. + :paramtype resource_id: str + :keyword msi_resource_id: The managed identity (MSI) that is allowed to access the storage + account, only to be specified for Azure Data Lake Storage Gen 2. + :paramtype msi_resource_id: str + :keyword saskey: The shared access signature key. + :paramtype saskey: str + :keyword fileshare: The file share name. + :paramtype fileshare: str + """ + super().__init__(**kwargs) self.name = name self.is_default = is_default self.container = container @@ -3637,67 +4239,82 @@ def __init__( self.fileshare = fileshare -class StorageProfile(msrest.serialization.Model): +class StorageProfile(_serialization.Model): """The storage profile. - :param storageaccounts: The list of storage accounts in the cluster. - :type storageaccounts: list[~azure.mgmt.hdinsight.models.StorageAccount] + :ivar storageaccounts: The list of storage accounts in the cluster. + :vartype storageaccounts: list[~azure.mgmt.hdinsight.models.StorageAccount] """ _attribute_map = { - 'storageaccounts': {'key': 'storageaccounts', 'type': '[StorageAccount]'}, + "storageaccounts": {"key": "storageaccounts", "type": "[StorageAccount]"}, } - def __init__( - self, - *, - storageaccounts: Optional[List["StorageAccount"]] = None, - **kwargs - ): - super(StorageProfile, self).__init__(**kwargs) + def __init__(self, *, storageaccounts: Optional[List["_models.StorageAccount"]] = None, **kwargs): + """ + :keyword storageaccounts: The list of storage accounts in the cluster. + :paramtype storageaccounts: list[~azure.mgmt.hdinsight.models.StorageAccount] + """ + super().__init__(**kwargs) self.storageaccounts = storageaccounts -class SystemData(msrest.serialization.Model): +class SystemData(_serialization.Model): """Metadata pertaining to creation and last modification of the resource. - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~azure.mgmt.hdinsight.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or ~azure.mgmt.hdinsight.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :vartype created_by_type: str or ~azure.mgmt.hdinsight.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". + :vartype last_modified_by_type: str or ~azure.mgmt.hdinsight.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { - 'created_by': {'key': 'createdBy', 'type': 'str'}, - 'created_by_type': {'key': 'createdByType', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, } def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): - super(SystemData, self).__init__(**kwargs) + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :paramtype created_by_type: str or ~azure.mgmt.hdinsight.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". + :paramtype last_modified_by_type: str or ~azure.mgmt.hdinsight.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ + super().__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type self.created_at = created_at @@ -3706,21 +4323,21 @@ def __init__( self.last_modified_at = last_modified_at -class UpdateClusterIdentityCertificateParameters(msrest.serialization.Model): +class UpdateClusterIdentityCertificateParameters(_serialization.Model): """The update cluster identity certificate request parameters. - :param application_id: The application id. - :type application_id: str - :param certificate: The certificate in base64 encoded format. - :type certificate: str - :param certificate_password: The password of the certificate. - :type certificate_password: str + :ivar application_id: The application id. + :vartype application_id: str + :ivar certificate: The certificate in base64 encoded format. + :vartype certificate: str + :ivar certificate_password: The password of the certificate. + :vartype certificate_password: str """ _attribute_map = { - 'application_id': {'key': 'applicationId', 'type': 'str'}, - 'certificate': {'key': 'certificate', 'type': 'str'}, - 'certificate_password': {'key': 'certificatePassword', 'type': 'str'}, + "application_id": {"key": "applicationId", "type": "str"}, + "certificate": {"key": "certificate", "type": "str"}, + "certificate_password": {"key": "certificatePassword", "type": "str"}, } def __init__( @@ -3731,107 +4348,126 @@ def __init__( certificate_password: Optional[str] = None, **kwargs ): - super(UpdateClusterIdentityCertificateParameters, self).__init__(**kwargs) + """ + :keyword application_id: The application id. + :paramtype application_id: str + :keyword certificate: The certificate in base64 encoded format. + :paramtype certificate: str + :keyword certificate_password: The password of the certificate. + :paramtype certificate_password: str + """ + super().__init__(**kwargs) self.application_id = application_id self.certificate = certificate self.certificate_password = certificate_password -class UpdateGatewaySettingsParameters(msrest.serialization.Model): +class UpdateGatewaySettingsParameters(_serialization.Model): """The update gateway settings request parameters. - :param is_credential_enabled: Indicates whether or not the gateway settings based authorization + :ivar is_credential_enabled: Indicates whether or not the gateway settings based authorization is enabled. - :type is_credential_enabled: bool - :param user_name: The gateway settings user name. - :type user_name: str - :param password: The gateway settings user password. - :type password: str + :vartype is_credential_enabled: bool + :ivar user_name: The gateway settings user name. + :vartype user_name: str + :ivar password: The gateway settings user password. + :vartype password: str """ _attribute_map = { - 'is_credential_enabled': {'key': 'restAuthCredential\\.isEnabled', 'type': 'bool'}, - 'user_name': {'key': 'restAuthCredential\\.username', 'type': 'str'}, - 'password': {'key': 'restAuthCredential\\.password', 'type': 'str'}, + "is_credential_enabled": {"key": "restAuthCredential\\.isEnabled", "type": "bool"}, + "user_name": {"key": "restAuthCredential\\.username", "type": "str"}, + "password": {"key": "restAuthCredential\\.password", "type": "str"}, } def __init__( self, *, - is_credential_enabled: Optional[bool] = True, + is_credential_enabled: bool = True, user_name: Optional[str] = None, password: Optional[str] = None, **kwargs ): - super(UpdateGatewaySettingsParameters, self).__init__(**kwargs) + """ + :keyword is_credential_enabled: Indicates whether or not the gateway settings based + authorization is enabled. + :paramtype is_credential_enabled: bool + :keyword user_name: The gateway settings user name. + :paramtype user_name: str + :keyword password: The gateway settings user password. + :paramtype password: str + """ + super().__init__(**kwargs) self.is_credential_enabled = is_credential_enabled self.user_name = user_name self.password = password -class Usage(msrest.serialization.Model): +class Usage(_serialization.Model): """The details about the usage of a particular limited resource. Variables are only populated by the server, and will be ignored when sending a request. - :param unit: The type of measurement for usage. - :type unit: str - :param current_value: The current usage. - :type current_value: long - :param limit: The maximum allowed usage. - :type limit: long + :ivar unit: The type of measurement for usage. + :vartype unit: str + :ivar current_value: The current usage. + :vartype current_value: int + :ivar limit: The maximum allowed usage. + :vartype limit: int :ivar name: The details about the localizable name of the used resource. :vartype name: ~azure.mgmt.hdinsight.models.LocalizedName """ _validation = { - 'name': {'readonly': True}, + "name": {"readonly": True}, } _attribute_map = { - 'unit': {'key': 'unit', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'long'}, - 'limit': {'key': 'limit', 'type': 'long'}, - 'name': {'key': 'name', 'type': 'LocalizedName'}, + "unit": {"key": "unit", "type": "str"}, + "current_value": {"key": "currentValue", "type": "int"}, + "limit": {"key": "limit", "type": "int"}, + "name": {"key": "name", "type": "LocalizedName"}, } def __init__( - self, - *, - unit: Optional[str] = None, - current_value: Optional[int] = None, - limit: Optional[int] = None, - **kwargs + self, *, unit: Optional[str] = None, current_value: Optional[int] = None, limit: Optional[int] = None, **kwargs ): - super(Usage, self).__init__(**kwargs) + """ + :keyword unit: The type of measurement for usage. + :paramtype unit: str + :keyword current_value: The current usage. + :paramtype current_value: int + :keyword limit: The maximum allowed usage. + :paramtype limit: int + """ + super().__init__(**kwargs) self.unit = unit self.current_value = current_value self.limit = limit self.name = None -class UsagesListResult(msrest.serialization.Model): +class UsagesListResult(_serialization.Model): """The response for the operation to get regional usages for a subscription. - :param value: The list of usages. - :type value: list[~azure.mgmt.hdinsight.models.Usage] + :ivar value: The list of usages. + :vartype value: list[~azure.mgmt.hdinsight.models.Usage] """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Usage]'}, + "value": {"key": "value", "type": "[Usage]"}, } - def __init__( - self, - *, - value: Optional[List["Usage"]] = None, - **kwargs - ): - super(UsagesListResult, self).__init__(**kwargs) + def __init__(self, *, value: Optional[List["_models.Usage"]] = None, **kwargs): + """ + :keyword value: The list of usages. + :paramtype value: list[~azure.mgmt.hdinsight.models.Usage] + """ + super().__init__(**kwargs) self.value = value -class UserAssignedIdentity(msrest.serialization.Model): +class UserAssignedIdentity(_serialization.Model): """The User Assigned Identity. Variables are only populated by the server, and will be ignored when sending a request. @@ -3840,51 +4476,50 @@ class UserAssignedIdentity(msrest.serialization.Model): :vartype principal_id: str :ivar client_id: The client id of user assigned identity. :vartype client_id: str - :param tenant_id: The tenant id of user assigned identity. - :type tenant_id: str + :ivar tenant_id: The tenant id of user assigned identity. + :vartype tenant_id: str """ _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "client_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, } - def __init__( - self, - *, - tenant_id: Optional[str] = None, - **kwargs - ): - super(UserAssignedIdentity, self).__init__(**kwargs) + def __init__(self, *, tenant_id: Optional[str] = None, **kwargs): + """ + :keyword tenant_id: The tenant id of user assigned identity. + :paramtype tenant_id: str + """ + super().__init__(**kwargs) self.principal_id = None self.client_id = None self.tenant_id = tenant_id -class ValidationErrorInfo(msrest.serialization.Model): +class ValidationErrorInfo(_serialization.Model): """The validation error information. - :param code: The error code. - :type code: str - :param message: The error message. - :type message: str - :param error_resource: The error resource. - :type error_resource: str - :param message_arguments: The message arguments. - :type message_arguments: list[str] + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar error_resource: The error resource. + :vartype error_resource: str + :ivar message_arguments: The message arguments. + :vartype message_arguments: list[str] """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'error_resource': {'key': 'errorResource', 'type': 'str'}, - 'message_arguments': {'key': 'messageArguments', 'type': '[str]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "error_resource": {"key": "errorResource", "type": "str"}, + "message_arguments": {"key": "messageArguments", "type": "[str]"}, } def __init__( @@ -3896,52 +4531,61 @@ def __init__( message_arguments: Optional[List[str]] = None, **kwargs ): - super(ValidationErrorInfo, self).__init__(**kwargs) + """ + :keyword code: The error code. + :paramtype code: str + :keyword message: The error message. + :paramtype message: str + :keyword error_resource: The error resource. + :paramtype error_resource: str + :keyword message_arguments: The message arguments. + :paramtype message_arguments: list[str] + """ + super().__init__(**kwargs) self.code = code self.message = message self.error_resource = error_resource self.message_arguments = message_arguments -class VersionsCapability(msrest.serialization.Model): +class VersionsCapability(_serialization.Model): """The version capability. - :param available: The list of version capabilities. - :type available: list[~azure.mgmt.hdinsight.models.VersionSpec] + :ivar available: The list of version capabilities. + :vartype available: list[~azure.mgmt.hdinsight.models.VersionSpec] """ _attribute_map = { - 'available': {'key': 'available', 'type': '[VersionSpec]'}, + "available": {"key": "available", "type": "[VersionSpec]"}, } - def __init__( - self, - *, - available: Optional[List["VersionSpec"]] = None, - **kwargs - ): - super(VersionsCapability, self).__init__(**kwargs) + def __init__(self, *, available: Optional[List["_models.VersionSpec"]] = None, **kwargs): + """ + :keyword available: The list of version capabilities. + :paramtype available: list[~azure.mgmt.hdinsight.models.VersionSpec] + """ + super().__init__(**kwargs) self.available = available -class VersionSpec(msrest.serialization.Model): +class VersionSpec(_serialization.Model): """The version properties. - :param friendly_name: The friendly name. - :type friendly_name: str - :param display_name: The display name. - :type display_name: str - :param is_default: Whether or not the version is the default version. - :type is_default: bool - :param component_versions: The component version property. - :type component_versions: dict[str, str] + :ivar friendly_name: The friendly name. + :vartype friendly_name: str + :ivar display_name: The display name. + :vartype display_name: str + :ivar is_default: Whether or not the version is the default version. + :vartype is_default: bool + :ivar component_versions: The component version property. + :vartype component_versions: dict[str, str] """ _attribute_map = { - 'friendly_name': {'key': 'friendlyName', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'is_default': {'key': 'isDefault', 'type': 'bool'}, - 'component_versions': {'key': 'componentVersions', 'type': '{str}'}, + "friendly_name": {"key": "friendlyName", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "is_default": {"key": "isDefault", "type": "bool"}, + "component_versions": {"key": "componentVersions", "type": "{str}"}, } def __init__( @@ -3953,92 +4597,127 @@ def __init__( component_versions: Optional[Dict[str, str]] = None, **kwargs ): - super(VersionSpec, self).__init__(**kwargs) + """ + :keyword friendly_name: The friendly name. + :paramtype friendly_name: str + :keyword display_name: The display name. + :paramtype display_name: str + :keyword is_default: Whether or not the version is the default version. + :paramtype is_default: bool + :keyword component_versions: The component version property. + :paramtype component_versions: dict[str, str] + """ + super().__init__(**kwargs) self.friendly_name = friendly_name self.display_name = display_name self.is_default = is_default self.component_versions = component_versions -class VirtualNetworkProfile(msrest.serialization.Model): +class VirtualNetworkProfile(_serialization.Model): """The virtual network properties. - :param id: The ID of the virtual network. - :type id: str - :param subnet: The name of the subnet. - :type subnet: str + :ivar id: The ID of the virtual network. + :vartype id: str + :ivar subnet: The name of the subnet. + :vartype subnet: str """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'subnet': {'key': 'subnet', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "subnet": {"key": "subnet", "type": "str"}, } def __init__( - self, - *, - id: Optional[str] = None, - subnet: Optional[str] = None, - **kwargs + self, *, id: Optional[str] = None, subnet: Optional[str] = None, **kwargs # pylint: disable=redefined-builtin ): - super(VirtualNetworkProfile, self).__init__(**kwargs) + """ + :keyword id: The ID of the virtual network. + :paramtype id: str + :keyword subnet: The name of the subnet. + :paramtype subnet: str + """ + super().__init__(**kwargs) self.id = id self.subnet = subnet -class VmSizeCompatibilityFilterV2(msrest.serialization.Model): +class VmSizeCompatibilityFilterV2(_serialization.Model): """This class represent a single filter object that defines a multidimensional set. The dimensions of this set are Regions, ClusterFlavors, NodeTypes and ClusterVersions. The constraint should be defined based on the following: FilterMode (Exclude vs Include), VMSizes (the vm sizes in affect of exclusion/inclusion) and the ordering of the Filters. Later filters override previous settings if conflicted. - :param filter_mode: The filtering mode. Effectively this can enabling or disabling the VM sizes - in a particular set. Possible values include: "Exclude", "Include", "Recommend", "Default". - :type filter_mode: str or ~azure.mgmt.hdinsight.models.FilterMode - :param regions: The list of regions under the effect of the filter. - :type regions: list[str] - :param cluster_flavors: The list of cluster flavors under the effect of the filter. - :type cluster_flavors: list[str] - :param node_types: The list of node types affected by the filter. - :type node_types: list[str] - :param cluster_versions: The list of cluster versions affected in Major.Minor format. - :type cluster_versions: list[str] - :param os_type: The OSType affected, Windows or Linux. - :type os_type: list[str or ~azure.mgmt.hdinsight.models.OSType] - :param vm_sizes: The list of virtual machine sizes to include or exclude. - :type vm_sizes: list[str] - :param esp_applied: Whether apply for ESP cluster. 'true' means only for ESP, 'false' means - only for non-ESP, null or empty string or others mean for both. - :type esp_applied: str - :param compute_isolation_supported: Whether support compute isolation. 'true' means only for + :ivar filter_mode: The filtering mode. Effectively this can enabling or disabling the VM sizes + in a particular set. Known values are: "Exclude", "Include", "Recommend", and "Default". + :vartype filter_mode: str or ~azure.mgmt.hdinsight.models.FilterMode + :ivar regions: The list of regions under the effect of the filter. + :vartype regions: list[str] + :ivar cluster_flavors: The list of cluster flavors under the effect of the filter. + :vartype cluster_flavors: list[str] + :ivar node_types: The list of node types affected by the filter. + :vartype node_types: list[str] + :ivar cluster_versions: The list of cluster versions affected in Major.Minor format. + :vartype cluster_versions: list[str] + :ivar os_type: The OSType affected, Windows or Linux. + :vartype os_type: list[str or ~azure.mgmt.hdinsight.models.OSType] + :ivar vm_sizes: The list of virtual machine sizes to include or exclude. + :vartype vm_sizes: list[str] + :ivar esp_applied: Whether apply for ESP cluster. 'true' means only for ESP, 'false' means only + for non-ESP, null or empty string or others mean for both. + :vartype esp_applied: str + :ivar compute_isolation_supported: Whether support compute isolation. 'true' means only for ComputeIsolationEnabled, 'false' means only for regular cluster. - :type compute_isolation_supported: str + :vartype compute_isolation_supported: str """ _attribute_map = { - 'filter_mode': {'key': 'filterMode', 'type': 'str'}, - 'regions': {'key': 'regions', 'type': '[str]'}, - 'cluster_flavors': {'key': 'clusterFlavors', 'type': '[str]'}, - 'node_types': {'key': 'nodeTypes', 'type': '[str]'}, - 'cluster_versions': {'key': 'clusterVersions', 'type': '[str]'}, - 'os_type': {'key': 'osType', 'type': '[str]'}, - 'vm_sizes': {'key': 'vmSizes', 'type': '[str]'}, - 'esp_applied': {'key': 'espApplied', 'type': 'str'}, - 'compute_isolation_supported': {'key': 'computeIsolationSupported', 'type': 'str'}, + "filter_mode": {"key": "filterMode", "type": "str"}, + "regions": {"key": "regions", "type": "[str]"}, + "cluster_flavors": {"key": "clusterFlavors", "type": "[str]"}, + "node_types": {"key": "nodeTypes", "type": "[str]"}, + "cluster_versions": {"key": "clusterVersions", "type": "[str]"}, + "os_type": {"key": "osType", "type": "[str]"}, + "vm_sizes": {"key": "vmSizes", "type": "[str]"}, + "esp_applied": {"key": "espApplied", "type": "str"}, + "compute_isolation_supported": {"key": "computeIsolationSupported", "type": "str"}, } def __init__( self, *, - filter_mode: Optional[Union[str, "FilterMode"]] = None, + filter_mode: Optional[Union[str, "_models.FilterMode"]] = None, regions: Optional[List[str]] = None, cluster_flavors: Optional[List[str]] = None, node_types: Optional[List[str]] = None, cluster_versions: Optional[List[str]] = None, - os_type: Optional[List[Union[str, "OSType"]]] = None, + os_type: Optional[List[Union[str, "_models.OSType"]]] = None, vm_sizes: Optional[List[str]] = None, esp_applied: Optional[str] = None, compute_isolation_supported: Optional[str] = None, **kwargs ): - super(VmSizeCompatibilityFilterV2, self).__init__(**kwargs) + """ + :keyword filter_mode: The filtering mode. Effectively this can enabling or disabling the VM + sizes in a particular set. Known values are: "Exclude", "Include", "Recommend", and "Default". + :paramtype filter_mode: str or ~azure.mgmt.hdinsight.models.FilterMode + :keyword regions: The list of regions under the effect of the filter. + :paramtype regions: list[str] + :keyword cluster_flavors: The list of cluster flavors under the effect of the filter. + :paramtype cluster_flavors: list[str] + :keyword node_types: The list of node types affected by the filter. + :paramtype node_types: list[str] + :keyword cluster_versions: The list of cluster versions affected in Major.Minor format. + :paramtype cluster_versions: list[str] + :keyword os_type: The OSType affected, Windows or Linux. + :paramtype os_type: list[str or ~azure.mgmt.hdinsight.models.OSType] + :keyword vm_sizes: The list of virtual machine sizes to include or exclude. + :paramtype vm_sizes: list[str] + :keyword esp_applied: Whether apply for ESP cluster. 'true' means only for ESP, 'false' means + only for non-ESP, null or empty string or others mean for both. + :paramtype esp_applied: str + :keyword compute_isolation_supported: Whether support compute isolation. 'true' means only for + ComputeIsolationEnabled, 'false' means only for regular cluster. + :paramtype compute_isolation_supported: str + """ + super().__init__(**kwargs) self.filter_mode = filter_mode self.regions = regions self.cluster_flavors = cluster_flavors @@ -4050,46 +4729,46 @@ def __init__( self.compute_isolation_supported = compute_isolation_supported -class VmSizeProperty(msrest.serialization.Model): +class VmSizeProperty(_serialization.Model): """The vm size property. - :param name: The vm size name. - :type name: str - :param cores: The number of cores that the vm size has. - :type cores: int - :param data_disk_storage_tier: The data disk storage tier of the vm size. - :type data_disk_storage_tier: str - :param label: The label of the vm size. - :type label: str - :param max_data_disk_count: The max data disk count of the vm size. - :type max_data_disk_count: long - :param memory_in_mb: The memory whose unit is MB of the vm size. - :type memory_in_mb: long - :param supported_by_virtual_machines: This indicates this vm size is supported by virtual + :ivar name: The vm size name. + :vartype name: str + :ivar cores: The number of cores that the vm size has. + :vartype cores: int + :ivar data_disk_storage_tier: The data disk storage tier of the vm size. + :vartype data_disk_storage_tier: str + :ivar label: The label of the vm size. + :vartype label: str + :ivar max_data_disk_count: The max data disk count of the vm size. + :vartype max_data_disk_count: int + :ivar memory_in_mb: The memory whose unit is MB of the vm size. + :vartype memory_in_mb: int + :ivar supported_by_virtual_machines: This indicates this vm size is supported by virtual machines or not. - :type supported_by_virtual_machines: bool - :param supported_by_web_worker_roles: The indicates this vm size is supported by web worker + :vartype supported_by_virtual_machines: bool + :ivar supported_by_web_worker_roles: The indicates this vm size is supported by web worker roles or not. - :type supported_by_web_worker_roles: bool - :param virtual_machine_resource_disk_size_in_mb: The virtual machine resource disk size whose + :vartype supported_by_web_worker_roles: bool + :ivar virtual_machine_resource_disk_size_in_mb: The virtual machine resource disk size whose unit is MB of the vm size. - :type virtual_machine_resource_disk_size_in_mb: long - :param web_worker_resource_disk_size_in_mb: The web worker resource disk size whose unit is MB + :vartype virtual_machine_resource_disk_size_in_mb: int + :ivar web_worker_resource_disk_size_in_mb: The web worker resource disk size whose unit is MB of the vm size. - :type web_worker_resource_disk_size_in_mb: long + :vartype web_worker_resource_disk_size_in_mb: int """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'cores': {'key': 'cores', 'type': 'int'}, - 'data_disk_storage_tier': {'key': 'dataDiskStorageTier', 'type': 'str'}, - 'label': {'key': 'label', 'type': 'str'}, - 'max_data_disk_count': {'key': 'maxDataDiskCount', 'type': 'long'}, - 'memory_in_mb': {'key': 'memoryInMb', 'type': 'long'}, - 'supported_by_virtual_machines': {'key': 'supportedByVirtualMachines', 'type': 'bool'}, - 'supported_by_web_worker_roles': {'key': 'supportedByWebWorkerRoles', 'type': 'bool'}, - 'virtual_machine_resource_disk_size_in_mb': {'key': 'virtualMachineResourceDiskSizeInMb', 'type': 'long'}, - 'web_worker_resource_disk_size_in_mb': {'key': 'webWorkerResourceDiskSizeInMb', 'type': 'long'}, + "name": {"key": "name", "type": "str"}, + "cores": {"key": "cores", "type": "int"}, + "data_disk_storage_tier": {"key": "dataDiskStorageTier", "type": "str"}, + "label": {"key": "label", "type": "str"}, + "max_data_disk_count": {"key": "maxDataDiskCount", "type": "int"}, + "memory_in_mb": {"key": "memoryInMb", "type": "int"}, + "supported_by_virtual_machines": {"key": "supportedByVirtualMachines", "type": "bool"}, + "supported_by_web_worker_roles": {"key": "supportedByWebWorkerRoles", "type": "bool"}, + "virtual_machine_resource_disk_size_in_mb": {"key": "virtualMachineResourceDiskSizeInMb", "type": "int"}, + "web_worker_resource_disk_size_in_mb": {"key": "webWorkerResourceDiskSizeInMb", "type": "int"}, } def __init__( @@ -4107,7 +4786,33 @@ def __init__( web_worker_resource_disk_size_in_mb: Optional[int] = None, **kwargs ): - super(VmSizeProperty, self).__init__(**kwargs) + """ + :keyword name: The vm size name. + :paramtype name: str + :keyword cores: The number of cores that the vm size has. + :paramtype cores: int + :keyword data_disk_storage_tier: The data disk storage tier of the vm size. + :paramtype data_disk_storage_tier: str + :keyword label: The label of the vm size. + :paramtype label: str + :keyword max_data_disk_count: The max data disk count of the vm size. + :paramtype max_data_disk_count: int + :keyword memory_in_mb: The memory whose unit is MB of the vm size. + :paramtype memory_in_mb: int + :keyword supported_by_virtual_machines: This indicates this vm size is supported by virtual + machines or not. + :paramtype supported_by_virtual_machines: bool + :keyword supported_by_web_worker_roles: The indicates this vm size is supported by web worker + roles or not. + :paramtype supported_by_web_worker_roles: bool + :keyword virtual_machine_resource_disk_size_in_mb: The virtual machine resource disk size whose + unit is MB of the vm size. + :paramtype virtual_machine_resource_disk_size_in_mb: int + :keyword web_worker_resource_disk_size_in_mb: The web worker resource disk size whose unit is + MB of the vm size. + :paramtype web_worker_resource_disk_size_in_mb: int + """ + super().__init__(**kwargs) self.name = name self.cores = cores self.data_disk_storage_tier = data_disk_storage_tier diff --git a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/models/_patch.py b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/models/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/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/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/operations/__init__.py b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/operations/__init__.py index f6dc3dfa5a094..54d25aae0b45f 100644 --- a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/operations/__init__.py +++ b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/operations/__init__.py @@ -18,16 +18,22 @@ from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations from ._private_link_resources_operations import PrivateLinkResourcesOperations +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__ = [ - 'ClustersOperations', - 'ApplicationsOperations', - 'LocationsOperations', - 'ConfigurationsOperations', - 'ExtensionsOperations', - 'ScriptActionsOperations', - 'ScriptExecutionHistoryOperations', - 'Operations', - 'VirtualMachinesOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkResourcesOperations', + "ClustersOperations", + "ApplicationsOperations", + "LocationsOperations", + "ConfigurationsOperations", + "ExtensionsOperations", + "ScriptActionsOperations", + "ScriptExecutionHistoryOperations", + "Operations", + "VirtualMachinesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/operations/_applications_operations.py b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/operations/_applications_operations.py index 62339d31e6652..6a3d8d8aecbb3 100644 --- a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/operations/_applications_operations.py +++ b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/operations/_applications_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,101 +6,289 @@ # 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_by_cluster_request( + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/applications", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, cluster_name: str, application_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", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/applications/{applicationName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "applicationName": _SERIALIZER.url("application_name", application_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_request( + resource_group_name: str, cluster_name: str, application_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", "2021-06-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.HDInsight/clusters/{clusterName}/applications/{applicationName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "applicationName": _SERIALIZER.url("application_name", application_name, "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") -class ApplicationsOperations(object): - """ApplicationsOperations operations. + # 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") - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, cluster_name: str, application_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", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/applications/{applicationName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "applicationName": _SERIALIZER.url("application_name", application_name, "str"), + } - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.hdinsight.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_azure_async_operation_status_request( + resource_group_name: str, + cluster_name: str, + application_name: str, + operation_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", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/applications/{applicationName}/azureasyncoperations/{operationId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "applicationName": _SERIALIZER.url("application_name", application_name, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_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) + + +class ApplicationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.hdinsight.HDInsightManagementClient`'s + :attr:`applications` 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_by_cluster( - self, - resource_group_name, # type: str - cluster_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ApplicationListResult"] + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> Iterable["_models.Application"]: """Lists all of the applications for the HDInsight cluster. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ApplicationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.hdinsight.models.ApplicationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Application or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.hdinsight.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplicationListResult"] + _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.ApplicationListResult] + 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-06-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_by_cluster.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_cluster_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_cluster.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('ApplicationListResult', pipeline_response) + deserialized = self._deserialize("ApplicationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -108,401 +297,491 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_cluster.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/applications'} # type: ignore + return ItemPaged(get_next, extract_data) + + list_by_cluster.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/applications"} # type: ignore + @distributed_trace def get( - self, - resource_group_name, # type: str - cluster_name, # type: str - application_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Application" + self, resource_group_name: str, cluster_name: str, application_name: str, **kwargs: Any + ) -> _models.Application: """Gets properties of the specified application. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param application_name: The constant value for the application name. + :param application_name: The constant value for the application name. Required. :type application_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Application, or the result of cls(response) + :return: Application or the result of cls(response) :rtype: ~azure.mgmt.hdinsight.models.Application - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Application"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-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'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'applicationName': self._serialize.url("application_name", application_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.Application] + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + application_name=application_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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Application', pipeline_response) + deserialized = self._deserialize("Application", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/applications/{applicationName}'} # type: ignore + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/applications/{applicationName}"} # type: ignore def _create_initial( self, - resource_group_name, # type: str - cluster_name, # type: str - application_name, # type: str - parameters, # type: "_models.Application" - **kwargs # type: Any - ): - # type: (...) -> "_models.Application" - cls = kwargs.pop('cls', None) # type: ClsType["_models.Application"] + resource_group_name: str, + cluster_name: str, + application_name: str, + parameters: Union[_models.Application, IO], + **kwargs: Any + ) -> _models.Application: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'applicationName': self._serialize.url("application_name", application_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(parameters, 'Application') - 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.Application] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Application") + + request = build_create_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + application_name=application_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Application', pipeline_response) + deserialized = self._deserialize("Application", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/applications/{applicationName}'} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/applications/{applicationName}"} # type: ignore + + @overload def begin_create( self, - resource_group_name, # type: str - cluster_name, # type: str - application_name, # type: str - parameters, # type: "_models.Application" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Application"] + resource_group_name: str, + cluster_name: str, + application_name: str, + parameters: _models.Application, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Application]: """Creates applications for the HDInsight cluster. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param application_name: The constant value for the application name. + :param application_name: The constant value for the application name. Required. :type application_name: str - :param parameters: The application create request. + :param parameters: The application create request. Required. :type parameters: ~azure.mgmt.hdinsight.models.Application + :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 Application 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 Application or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hdinsight.models.Application] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Application"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create( + self, + resource_group_name: str, + cluster_name: str, + application_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Application]: + """Creates applications for the HDInsight cluster. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param application_name: The constant value for the application name. Required. + :type application_name: str + :param parameters: The application create request. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Application or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hdinsight.models.Application] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + cluster_name: str, + application_name: str, + parameters: Union[_models.Application, IO], + **kwargs: Any + ) -> LROPoller[_models.Application]: + """Creates applications for the HDInsight cluster. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param application_name: The constant value for the application name. Required. + :type application_name: str + :param parameters: The application create request. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.hdinsight.models.Application 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 Application or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hdinsight.models.Application] + :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.Application] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_initial( + raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, application_name=application_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Application', pipeline_response) - + deserialized = self._deserialize("Application", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'applicationName': self._serialize.url("application_name", application_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/applications/{applicationName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def _delete_initial( - self, - resource_group_name, # type: str - cluster_name, # type: str - application_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/applications/{applicationName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, cluster_name: str, application_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-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'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'applicationName': self._serialize.url("application_name", application_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, + cluster_name=cluster_name, + application_name=application_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/applications/{applicationName}'} # type: ignore + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/applications/{applicationName}"} # type: ignore + @distributed_trace def begin_delete( - self, - resource_group_name, # type: str - cluster_name, # type: str - application_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + self, resource_group_name: str, cluster_name: str, application_name: str, **kwargs: Any + ) -> LROPoller[None]: """Deletes the specified application on the HDInsight cluster. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param application_name: The constant value for the application name. + :param application_name: The constant value for the application name. Required. :type application_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, cluster_name=cluster_name, application_name=application_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'applicationName': self._serialize.url("application_name", application_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + 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.HDInsight/clusters/{clusterName}/applications/{applicationName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/applications/{applicationName}"} # type: ignore + @distributed_trace def get_azure_async_operation_status( - self, - resource_group_name, # type: str - cluster_name, # type: str - application_name, # type: str - operation_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AsyncOperationResult" + self, resource_group_name: str, cluster_name: str, application_name: str, operation_id: str, **kwargs: Any + ) -> _models.AsyncOperationResult: """Gets the async operation status. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param application_name: The constant value for the application name. + :param application_name: The constant value for the application name. Required. :type application_name: str - :param operation_id: The long running operation id. + :param operation_id: The long running operation id. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AsyncOperationResult, or the result of cls(response) + :return: AsyncOperationResult or the result of cls(response) :rtype: ~azure.mgmt.hdinsight.models.AsyncOperationResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AsyncOperationResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - accept = "application/json" - - # Construct URL - url = self.get_azure_async_operation_status.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'applicationName': self._serialize.url("application_name", application_name, 'str'), - 'operationId': self._serialize.url("operation_id", operation_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.AsyncOperationResult] + + request = build_get_azure_async_operation_status_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + application_name=application_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_azure_async_operation_status.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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AsyncOperationResult', pipeline_response) + deserialized = self._deserialize("AsyncOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_azure_async_operation_status.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/applications/{applicationName}/azureasyncoperations/{operationId}'} # type: ignore + + get_azure_async_operation_status.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/applications/{applicationName}/azureasyncoperations/{operationId}"} # type: ignore diff --git a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/operations/_clusters_operations.py b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/operations/_clusters_operations.py index f712625c2d80a..100fed5e4b9e3 100644 --- a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/operations/_clusters_operations.py +++ b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/operations/_clusters_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,463 +6,1088 @@ # 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_create_request( + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-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.HDInsight/clusters/{clusterName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-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.HDInsight/clusters/{clusterName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, cluster_name: str, subscription_id: str, **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", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _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_resize_request( + resource_group_name: str, + cluster_name: str, + role_name: Union[str, _models.RoleName], + 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", "2021-06-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.HDInsight/clusters/{clusterName}/roles/{roleName}/resize", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "roleName": _SERIALIZER.url("role_name", role_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_auto_scale_configuration_request( + resource_group_name: str, + cluster_name: str, + role_name: Union[str, _models.RoleName], + 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", "2021-06-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.HDInsight/clusters/{clusterName}/roles/{roleName}/autoscale", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "roleName": _SERIALIZER.url("role_name", role_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.HDInsight/clusters") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_rotate_disk_encryption_key_request( + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-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.HDInsight/clusters/{clusterName}/rotatediskencryptionkey", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_gateway_settings_request( + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/getGatewaySettings", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_gateway_settings_request( + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-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.HDInsight/clusters/{clusterName}/updateGatewaySettings", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_azure_async_operation_status_request( + resource_group_name: str, cluster_name: str, operation_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", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/azureasyncoperations/{operationId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "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 + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class ClustersOperations(object): - """ClustersOperations operations. + return HttpRequest(method="GET", 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.hdinsight.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_identity_certificate_request( + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-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.HDInsight/clusters/{clusterName}/updateClusterIdentityCertificate", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_execute_script_actions_request( + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-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.HDInsight/clusters/{clusterName}/executeScriptActions", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class ClustersOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.hdinsight.HDInsightManagementClient`'s + :attr:`clusters` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") def _create_initial( self, - resource_group_name, # type: str - cluster_name, # type: str - parameters, # type: "_models.ClusterCreateParametersExtended" - **kwargs # type: Any - ): - # type: (...) -> "_models.Cluster" - cls = kwargs.pop('cls', None) # type: ClsType["_models.Cluster"] + resource_group_name: str, + cluster_name: str, + parameters: Union[_models.ClusterCreateParametersExtended, 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-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ClusterCreateParametersExtended') - 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(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ClusterCreateParametersExtended") + + request = build_create_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Cluster', pipeline_response) + deserialized = self._deserialize("Cluster", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}'} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}"} # type: ignore + + @overload def begin_create( self, - resource_group_name, # type: str - cluster_name, # type: str - parameters, # type: "_models.ClusterCreateParametersExtended" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.Cluster"] + resource_group_name: str, + cluster_name: str, + parameters: _models.ClusterCreateParametersExtended, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Cluster]: """Creates a new HDInsight cluster with the specified parameters. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param parameters: The cluster create request. + :param parameters: The cluster create request. Required. :type parameters: ~azure.mgmt.hdinsight.models.ClusterCreateParametersExtended + :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.hdinsight.models.Cluster] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Cluster"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create( + self, + resource_group_name: str, + cluster_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Cluster]: + """Creates a new HDInsight cluster with the specified parameters. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param parameters: The cluster create request. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Cluster or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hdinsight.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + cluster_name: str, + parameters: Union[_models.ClusterCreateParametersExtended, IO], + **kwargs: Any + ) -> LROPoller[_models.Cluster]: + """Creates a new HDInsight cluster with the specified parameters. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param parameters: The cluster create request. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.hdinsight.models.ClusterCreateParametersExtended 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.hdinsight.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Cluster] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_initial( + raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Cluster', pipeline_response) - + deserialized = self._deserialize("Cluster", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}"} # type: ignore + + @overload def update( self, - resource_group_name, # type: str - cluster_name, # type: str - parameters, # type: "_models.ClusterPatchParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.Cluster" + resource_group_name: str, + cluster_name: str, + parameters: _models.ClusterPatchParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Cluster: """Patch HDInsight cluster with the specified parameters. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param parameters: The cluster patch request. + :param parameters: The cluster patch request. Required. :type parameters: ~azure.mgmt.hdinsight.models.ClusterPatchParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Cluster or the result of cls(response) + :rtype: ~azure.mgmt.hdinsight.models.Cluster + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + cluster_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Cluster: + """Patch HDInsight cluster with the specified parameters. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param parameters: The cluster patch request. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Cluster, or the result of cls(response) + :return: Cluster or the result of cls(response) :rtype: ~azure.mgmt.hdinsight.models.Cluster - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + cluster_name: str, + parameters: Union[_models.ClusterPatchParameters, IO], + **kwargs: Any + ) -> _models.Cluster: + """Patch HDInsight cluster with the specified parameters. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param parameters: The cluster patch request. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.hdinsight.models.ClusterPatchParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Cluster or the result of cls(response) + :rtype: ~azure.mgmt.hdinsight.models.Cluster + :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-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ClusterPatchParameters') - 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(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ClusterPatchParameters") + + request = build_update_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Cluster', pipeline_response) + deserialized = self._deserialize("Cluster", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}'} # type: ignore - def _delete_initial( - self, - resource_group_name, # type: str - cluster_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, cluster_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-06-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'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}'} # type: ignore + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}"} # type: ignore - def begin_delete( - self, - resource_group_name, # type: str - cluster_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_delete(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> LROPoller[None]: """Deletes the specified HDInsight cluster. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. 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, 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'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + 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.HDInsight/clusters/{clusterName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def get( - self, - resource_group_name, # type: str - cluster_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Cluster" + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}"} # type: ignore + + @distributed_trace + def get(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> _models.Cluster: """Gets the specified cluster. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Cluster, or the result of cls(response) + :return: Cluster or the result of cls(response) :rtype: ~azure.mgmt.hdinsight.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-06-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'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Cluster] + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Cluster', pipeline_response) + deserialized = self._deserialize("Cluster", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}'} # type: ignore - def list_by_resource_group( - self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ClusterListResult"] + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}"} # type: ignore + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Cluster"]: """Lists the HDInsight clusters in a resource group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. 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 ClusterListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.hdinsight.models.ClusterListResult] - :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.hdinsight.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClusterListResult"] + _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.ClusterListResult] + 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-06-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_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = 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('ClusterListResult', pipeline_response) + deserialized = self._deserialize("ClusterListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -470,322 +1096,516 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters'} # type: ignore + return ItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters"} # type: ignore - def _resize_initial( + def _resize_initial( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - cluster_name, # type: str - role_name, # type: Union[str, "_models.RoleName"] - parameters, # type: "_models.ClusterResizeParameters" - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + resource_group_name: str, + cluster_name: str, + role_name: Union[str, _models.RoleName], + parameters: Union[_models.ClusterResizeParameters, IO], + **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-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._resize_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - } - url = self._client.format_url(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(parameters, 'ClusterResizeParameters') - 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(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ClusterResizeParameters") + + request = build_resize_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + role_name=role_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._resize_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _resize_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/roles/{roleName}/resize'} # type: ignore + _resize_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/roles/{roleName}/resize"} # type: ignore + @overload def begin_resize( self, - resource_group_name, # type: str - cluster_name, # type: str - role_name, # type: Union[str, "_models.RoleName"] - parameters, # type: "_models.ClusterResizeParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + cluster_name: str, + role_name: Union[str, _models.RoleName], + parameters: _models.ClusterResizeParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: """Resizes the specified HDInsight cluster to the specified size. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param role_name: The constant value for the roleName. + :param role_name: The constant value for the roleName. "workernode" Required. :type role_name: str or ~azure.mgmt.hdinsight.models.RoleName - :param parameters: The parameters for the resize operation. + :param parameters: The parameters for the resize operation. Required. :type parameters: ~azure.mgmt.hdinsight.models.ClusterResizeParameters + :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_resize( + self, + resource_group_name: str, + cluster_name: str, + role_name: Union[str, _models.RoleName], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Resizes the specified HDInsight cluster to the specified size. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param role_name: The constant value for the roleName. "workernode" Required. + :type role_name: str or ~azure.mgmt.hdinsight.models.RoleName + :param parameters: The parameters for the resize operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_resize( + self, + resource_group_name: str, + cluster_name: str, + role_name: Union[str, _models.RoleName], + parameters: Union[_models.ClusterResizeParameters, IO], + **kwargs: Any + ) -> LROPoller[None]: + """Resizes the specified HDInsight cluster to the specified size. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param role_name: The constant value for the roleName. "workernode" Required. + :type role_name: str or ~azure.mgmt.hdinsight.models.RoleName + :param parameters: The parameters for the resize operation. Is either a model type or a IO + type. Required. + :type parameters: ~azure.mgmt.hdinsight.models.ClusterResizeParameters 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._resize_initial( + raw_result = self._resize_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, role_name=role_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_resize.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/roles/{roleName}/resize'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_resize.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/roles/{roleName}/resize"} # type: ignore - def _update_auto_scale_configuration_initial( + def _update_auto_scale_configuration_initial( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - cluster_name, # type: str - role_name, # type: Union[str, "_models.RoleName"] - parameters, # type: "_models.AutoscaleConfigurationUpdateParameter" - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + resource_group_name: str, + cluster_name: str, + role_name: Union[str, _models.RoleName], + parameters: Union[_models.AutoscaleConfigurationUpdateParameter, IO], + **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-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_auto_scale_configuration_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - } - url = self._client.format_url(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(parameters, 'AutoscaleConfigurationUpdateParameter') - 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(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AutoscaleConfigurationUpdateParameter") + + request = build_update_auto_scale_configuration_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + role_name=role_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_auto_scale_configuration_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _update_auto_scale_configuration_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/roles/{roleName}/autoscale'} # type: ignore + _update_auto_scale_configuration_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/roles/{roleName}/autoscale"} # type: ignore + @overload def begin_update_auto_scale_configuration( self, - resource_group_name, # type: str - cluster_name, # type: str - role_name, # type: Union[str, "_models.RoleName"] - parameters, # type: "_models.AutoscaleConfigurationUpdateParameter" - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + cluster_name: str, + role_name: Union[str, _models.RoleName], + parameters: _models.AutoscaleConfigurationUpdateParameter, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: """Updates the Autoscale Configuration for HDInsight cluster. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param role_name: The constant value for the roleName. + :param role_name: The constant value for the roleName. "workernode" Required. :type role_name: str or ~azure.mgmt.hdinsight.models.RoleName - :param parameters: The parameters for the update autoscale configuration operation. + :param parameters: The parameters for the update autoscale configuration operation. Required. :type parameters: ~azure.mgmt.hdinsight.models.AutoscaleConfigurationUpdateParameter + :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_update_auto_scale_configuration( + self, + resource_group_name: str, + cluster_name: str, + role_name: Union[str, _models.RoleName], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Updates the Autoscale Configuration for HDInsight cluster. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param role_name: The constant value for the roleName. "workernode" Required. + :type role_name: str or ~azure.mgmt.hdinsight.models.RoleName + :param parameters: The parameters for the update autoscale configuration operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_auto_scale_configuration( + self, + resource_group_name: str, + cluster_name: str, + role_name: Union[str, _models.RoleName], + parameters: Union[_models.AutoscaleConfigurationUpdateParameter, IO], + **kwargs: Any + ) -> LROPoller[None]: + """Updates the Autoscale Configuration for HDInsight cluster. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param role_name: The constant value for the roleName. "workernode" Required. + :type role_name: str or ~azure.mgmt.hdinsight.models.RoleName + :param parameters: The parameters for the update autoscale configuration operation. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.hdinsight.models.AutoscaleConfigurationUpdateParameter 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._update_auto_scale_configuration_initial( + raw_result = self._update_auto_scale_configuration_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, role_name=role_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'roleName': self._serialize.url("role_name", role_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update_auto_scale_configuration.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/roles/{roleName}/autoscale'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def list( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ClusterListResult"] + begin_update_auto_scale_configuration.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/roles/{roleName}/autoscale"} # type: ignore + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.Cluster"]: """Lists all the HDInsight clusters under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ClusterListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.hdinsight.models.ClusterListResult] - :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.hdinsight.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClusterListResult"] + _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.ClusterListResult] + 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-06-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'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + # make call to next link with the client's api-version + _parsed_next_link = 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('ClusterListResult', pipeline_response) + deserialized = self._deserialize("ClusterListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -794,625 +1614,969 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HDInsight/clusters'} # type: ignore + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.HDInsight/clusters"} # type: ignore - def _rotate_disk_encryption_key_initial( + def _rotate_disk_encryption_key_initial( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - cluster_name, # type: str - parameters, # type: "_models.ClusterDiskEncryptionParameters" - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + resource_group_name: str, + cluster_name: str, + parameters: Union[_models.ClusterDiskEncryptionParameters, IO], + **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-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._rotate_disk_encryption_key_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ClusterDiskEncryptionParameters') - 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(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ClusterDiskEncryptionParameters") + + request = build_rotate_disk_encryption_key_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._rotate_disk_encryption_key_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _rotate_disk_encryption_key_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/rotatediskencryptionkey'} # type: ignore + _rotate_disk_encryption_key_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/rotatediskencryptionkey"} # type: ignore + @overload def begin_rotate_disk_encryption_key( self, - resource_group_name, # type: str - cluster_name, # type: str - parameters, # type: "_models.ClusterDiskEncryptionParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + cluster_name: str, + parameters: _models.ClusterDiskEncryptionParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: """Rotate disk encryption key of the specified HDInsight cluster. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param parameters: The parameters for the disk encryption operation. + :param parameters: The parameters for the disk encryption operation. Required. :type parameters: ~azure.mgmt.hdinsight.models.ClusterDiskEncryptionParameters + :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_rotate_disk_encryption_key( + self, + resource_group_name: str, + cluster_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Rotate disk encryption key of the specified HDInsight cluster. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param parameters: The parameters for the disk encryption operation. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_rotate_disk_encryption_key( + self, + resource_group_name: str, + cluster_name: str, + parameters: Union[_models.ClusterDiskEncryptionParameters, IO], + **kwargs: Any + ) -> LROPoller[None]: + """Rotate disk encryption key of the specified HDInsight cluster. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param parameters: The parameters for the disk encryption operation. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.hdinsight.models.ClusterDiskEncryptionParameters 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._rotate_disk_encryption_key_initial( + raw_result = self._rotate_disk_encryption_key_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_rotate_disk_encryption_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/rotatediskencryptionkey'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_rotate_disk_encryption_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/rotatediskencryptionkey"} # type: ignore + @distributed_trace def get_gateway_settings( - self, - resource_group_name, # type: str - cluster_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.GatewaySettings" + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> _models.GatewaySettings: """Gets the gateway settings for the specified cluster. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GatewaySettings, or the result of cls(response) + :return: GatewaySettings or the result of cls(response) :rtype: ~azure.mgmt.hdinsight.models.GatewaySettings - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GatewaySettings"] 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-06-01" - accept = "application/json" - - # Construct URL - url = self.get_gateway_settings.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + 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.GatewaySettings] + + request = build_get_gateway_settings_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_gateway_settings.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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('GatewaySettings', pipeline_response) + deserialized = self._deserialize("GatewaySettings", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_gateway_settings.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/getGatewaySettings'} # type: ignore - def _update_gateway_settings_initial( + get_gateway_settings.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/getGatewaySettings"} # type: ignore + + def _update_gateway_settings_initial( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - cluster_name, # type: str - parameters, # type: "_models.UpdateGatewaySettingsParameters" - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + resource_group_name: str, + cluster_name: str, + parameters: Union[_models.UpdateGatewaySettingsParameters, IO], + **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_gateway_settings_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 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(parameters, 'UpdateGatewaySettingsParameters') - 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(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "UpdateGatewaySettingsParameters") + + request = build_update_gateway_settings_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_gateway_settings_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _update_gateway_settings_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/updateGatewaySettings'} # type: ignore + _update_gateway_settings_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/updateGatewaySettings"} # type: ignore + @overload def begin_update_gateway_settings( self, - resource_group_name, # type: str - cluster_name, # type: str - parameters, # type: "_models.UpdateGatewaySettingsParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + cluster_name: str, + parameters: _models.UpdateGatewaySettingsParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: """Configures the gateway settings on the specified cluster. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param parameters: The cluster configurations. + :param parameters: The cluster configurations. Required. :type parameters: ~azure.mgmt.hdinsight.models.UpdateGatewaySettingsParameters + :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_update_gateway_settings( + self, + resource_group_name: str, + cluster_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Configures the gateway settings on the specified cluster. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param parameters: The cluster configurations. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_gateway_settings( + self, + resource_group_name: str, + cluster_name: str, + parameters: Union[_models.UpdateGatewaySettingsParameters, IO], + **kwargs: Any + ) -> LROPoller[None]: + """Configures the gateway settings on the specified cluster. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param parameters: The cluster configurations. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.hdinsight.models.UpdateGatewaySettingsParameters 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._update_gateway_settings_initial( + raw_result = self._update_gateway_settings_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update_gateway_settings.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/updateGatewaySettings'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update_gateway_settings.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/updateGatewaySettings"} # type: ignore + @distributed_trace def get_azure_async_operation_status( - self, - resource_group_name, # type: str - cluster_name, # type: str - operation_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AsyncOperationResult" + self, resource_group_name: str, cluster_name: str, operation_id: str, **kwargs: Any + ) -> _models.AsyncOperationResult: """The the async operation status. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param operation_id: The long running operation id. + :param operation_id: The long running operation id. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AsyncOperationResult, or the result of cls(response) + :return: AsyncOperationResult or the result of cls(response) :rtype: ~azure.mgmt.hdinsight.models.AsyncOperationResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AsyncOperationResult"] 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-06-01" - accept = "application/json" - - # Construct URL - url = self.get_azure_async_operation_status.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'operationId': self._serialize.url("operation_id", operation_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.AsyncOperationResult] + + request = build_get_azure_async_operation_status_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_azure_async_operation_status.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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AsyncOperationResult', pipeline_response) + deserialized = self._deserialize("AsyncOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_azure_async_operation_status.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/azureasyncoperations/{operationId}'} # type: ignore - def _update_identity_certificate_initial( + get_azure_async_operation_status.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/azureasyncoperations/{operationId}"} # type: ignore + + def _update_identity_certificate_initial( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - cluster_name, # type: str - parameters, # type: "_models.UpdateClusterIdentityCertificateParameters" - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + resource_group_name: str, + cluster_name: str, + parameters: Union[_models.UpdateClusterIdentityCertificateParameters, IO], + **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-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_identity_certificate_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'UpdateClusterIdentityCertificateParameters') - 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(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "UpdateClusterIdentityCertificateParameters") + + request = build_update_identity_certificate_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_identity_certificate_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _update_identity_certificate_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/updateClusterIdentityCertificate'} # type: ignore + _update_identity_certificate_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/updateClusterIdentityCertificate"} # type: ignore + @overload def begin_update_identity_certificate( self, - resource_group_name, # type: str - cluster_name, # type: str - parameters, # type: "_models.UpdateClusterIdentityCertificateParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + cluster_name: str, + parameters: _models.UpdateClusterIdentityCertificateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: """Updates the cluster identity certificate. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param parameters: The cluster configurations. + :param parameters: The cluster configurations. Required. :type parameters: ~azure.mgmt.hdinsight.models.UpdateClusterIdentityCertificateParameters + :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_update_identity_certificate( + self, + resource_group_name: str, + cluster_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Updates the cluster identity certificate. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param parameters: The cluster configurations. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update_identity_certificate( + self, + resource_group_name: str, + cluster_name: str, + parameters: Union[_models.UpdateClusterIdentityCertificateParameters, IO], + **kwargs: Any + ) -> LROPoller[None]: + """Updates the cluster identity certificate. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param parameters: The cluster configurations. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.hdinsight.models.UpdateClusterIdentityCertificateParameters 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._update_identity_certificate_initial( + raw_result = self._update_identity_certificate_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update_identity_certificate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/updateClusterIdentityCertificate'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update_identity_certificate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/updateClusterIdentityCertificate"} # type: ignore - def _execute_script_actions_initial( + def _execute_script_actions_initial( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - cluster_name, # type: str - parameters, # type: "_models.ExecuteScriptActionParameters" - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + resource_group_name: str, + cluster_name: str, + parameters: Union[_models.ExecuteScriptActionParameters, IO], + **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 404: lambda response: ResourceNotFoundError(response=response, error_format=ARMErrorFormat), } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._execute_script_actions_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ExecuteScriptActionParameters') - 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(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ExecuteScriptActionParameters") + + request = build_execute_script_actions_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._execute_script_actions_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _execute_script_actions_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/executeScriptActions'} # type: ignore + _execute_script_actions_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/executeScriptActions"} # type: ignore + @overload def begin_execute_script_actions( self, - resource_group_name, # type: str - cluster_name, # type: str - parameters, # type: "_models.ExecuteScriptActionParameters" - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + cluster_name: str, + parameters: _models.ExecuteScriptActionParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: """Executes script actions on the specified HDInsight cluster. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param parameters: The parameters for executing script actions. + :param parameters: The parameters for executing script actions. Required. :type parameters: ~azure.mgmt.hdinsight.models.ExecuteScriptActionParameters + :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_execute_script_actions( + self, + resource_group_name: str, + cluster_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Executes script actions on the specified HDInsight cluster. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param parameters: The parameters for executing script actions. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_execute_script_actions( + self, + resource_group_name: str, + cluster_name: str, + parameters: Union[_models.ExecuteScriptActionParameters, IO], + **kwargs: Any + ) -> LROPoller[None]: + """Executes script actions on the specified HDInsight cluster. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param parameters: The parameters for executing script actions. Is either a model type or a IO + type. Required. + :type parameters: ~azure.mgmt.hdinsight.models.ExecuteScriptActionParameters 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._execute_script_actions_initial( + raw_result = self._execute_script_actions_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_execute_script_actions.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/executeScriptActions'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_execute_script_actions.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/executeScriptActions"} # type: ignore diff --git a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/operations/_configurations_operations.py b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/operations/_configurations_operations.py index 25305539c343b..630475087b9be 100644 --- a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/operations/_configurations_operations.py +++ b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/operations/_configurations_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,297 +6,492 @@ # 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, Optional, TypeVar, Union, cast, 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 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, 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", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/configurations", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, cluster_name: str, configuration_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", "2021-06-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.HDInsight/clusters/{clusterName}/configurations/{configurationName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "configurationName": _SERIALIZER.url("configuration_name", configuration_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, cluster_name: str, configuration_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", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/configurations/{configurationName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "configurationName": _SERIALIZER.url("configuration_name", configuration_name, "str"), + } - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + _url = _format_url_section(_url, **path_format_arguments) -class ConfigurationsOperations(object): - """ConfigurationsOperations operations. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.hdinsight.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.hdinsight.HDInsightManagementClient`'s + :attr:`configurations` 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 - cluster_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ClusterConfigurations" + @distributed_trace + def list(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> _models.ClusterConfigurations: """Gets all configuration information for an HDI cluster. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ClusterConfigurations, or the result of cls(response) + :return: ClusterConfigurations or the result of cls(response) :rtype: ~azure.mgmt.hdinsight.models.ClusterConfigurations - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClusterConfigurations"] 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-06-01" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - '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.ClusterConfigurations] + + request = build_list_request( + resource_group_name=resource_group_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 - # 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ClusterConfigurations', pipeline_response) + deserialized = self._deserialize("ClusterConfigurations", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/configurations'} # type: ignore - def _update_initial( + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/configurations"} # type: ignore + + def _update_initial( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - cluster_name, # type: str - configuration_name, # type: str - parameters, # type: Dict[str, str] - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + resource_group_name: str, + cluster_name: str, + configuration_name: str, + parameters: Union[Dict[str, str], IO], + **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-06-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'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), - } - url = self._client.format_url(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(parameters, '{str}') - 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(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "{str}") + + request = build_update_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + configuration_name=configuration_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, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/configurations/{configurationName}'} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/configurations/{configurationName}"} # type: ignore + @overload def begin_update( self, - resource_group_name, # type: str - cluster_name, # type: str - configuration_name, # type: str - parameters, # type: Dict[str, str] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + cluster_name: str, + configuration_name: str, + parameters: Dict[str, str], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: """Configures the HTTP settings on the specified cluster. This API is deprecated, please use UpdateGatewaySettings in cluster endpoint instead. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param configuration_name: The name of the cluster configuration. + :param configuration_name: The name of the cluster configuration. Required. :type configuration_name: str - :param parameters: The cluster configurations. + :param parameters: The cluster configurations. Required. :type parameters: dict[str, str] + :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_update( + self, + resource_group_name: str, + cluster_name: str, + configuration_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Configures the HTTP settings on the specified cluster. This API is deprecated, please use + UpdateGatewaySettings in cluster endpoint instead. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param configuration_name: The name of the cluster configuration. Required. + :type configuration_name: str + :param parameters: The cluster configurations. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + cluster_name: str, + configuration_name: str, + parameters: Union[Dict[str, str], IO], + **kwargs: Any + ) -> LROPoller[None]: + """Configures the HTTP settings on the specified cluster. This API is deprecated, please use + UpdateGatewaySettings in cluster endpoint instead. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param configuration_name: The name of the cluster configuration. Required. + :type configuration_name: str + :param parameters: The cluster configurations. Is either a dict type or a IO type. Required. + :type parameters: dict[str, str] 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._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, configuration_name=configuration_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + 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.HDInsight/clusters/{clusterName}/configurations/{configurationName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/configurations/{configurationName}"} # type: ignore + + @distributed_trace def get( - self, - resource_group_name, # type: str - cluster_name, # type: str - configuration_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Dict[str, str] + self, resource_group_name: str, cluster_name: str, configuration_name: str, **kwargs: Any + ) -> Dict[str, str]: """The configuration object for the specified cluster. This API is not recommended and might be removed in the future. Please consider using List configurations API instead. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param configuration_name: The name of the cluster configuration. + :param configuration_name: The name of the cluster configuration. Required. :type configuration_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to str, or the result of cls(response) + :return: dict mapping str to str or the result of cls(response) :rtype: dict[str, str] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Dict[str, str]] 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-06-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'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str'), - } - url = self._client.format_url(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[Dict[str, str]] + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + configuration_name=configuration_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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('{str}', pipeline_response) + deserialized = self._deserialize("{str}", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/configurations/{configurationName}'} # type: ignore + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/configurations/{configurationName}"} # type: ignore diff --git a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/operations/_extensions_operations.py b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/operations/_extensions_operations.py index d7f3a489c4417..af48637a56b92 100644 --- a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/operations/_extensions_operations.py +++ b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/operations/_extensions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,1005 +6,1598 @@ # 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, Optional, TypeVar, Union, cast, 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 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_enable_monitoring_request( + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-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.HDInsight/clusters/{clusterName}/extensions/clustermonitoring", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_monitoring_status_request( + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/clustermonitoring", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_disable_monitoring_request( + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/clustermonitoring", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_enable_azure_monitor_request( + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-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.HDInsight/clusters/{clusterName}/extensions/azureMonitor", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +def build_get_azure_monitor_status_request( + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) -class ExtensionsOperations(object): - """ExtensionsOperations operations. + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/azureMonitor", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.hdinsight.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_disable_azure_monitor_request( + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/azureMonitor", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request( + resource_group_name: str, cluster_name: str, extension_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-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.HDInsight/clusters/{clusterName}/extensions/{extensionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, cluster_name: str, extension_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/{extensionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, cluster_name: str, extension_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/{extensionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_azure_async_operation_status_request( + resource_group_name: str, + cluster_name: str, + extension_name: str, + operation_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", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/{extensionName}/azureAsyncOperations/{operationId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_name, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_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) + + +class ExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.hdinsight.HDInsightManagementClient`'s + :attr:`extensions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - def _enable_monitoring_initial( + def _enable_monitoring_initial( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - cluster_name, # type: str - parameters, # type: "_models.ClusterMonitoringRequest" - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + resource_group_name: str, + cluster_name: str, + parameters: Union[_models.ClusterMonitoringRequest, IO], + **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-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._enable_monitoring_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ClusterMonitoringRequest') - 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[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ClusterMonitoringRequest") + + request = build_enable_monitoring_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._enable_monitoring_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _enable_monitoring_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/clustermonitoring'} # type: ignore + _enable_monitoring_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/clustermonitoring"} # type: ignore + @overload def begin_enable_monitoring( self, - resource_group_name, # type: str - cluster_name, # type: str - parameters, # type: "_models.ClusterMonitoringRequest" - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + cluster_name: str, + parameters: _models.ClusterMonitoringRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: """Enables the Operations Management Suite (OMS) on the HDInsight cluster. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param parameters: The Operations Management Suite (OMS) workspace parameters. + :param parameters: The Operations Management Suite (OMS) workspace parameters. Required. :type parameters: ~azure.mgmt.hdinsight.models.ClusterMonitoringRequest + :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_enable_monitoring( + self, + resource_group_name: str, + cluster_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Enables the Operations Management Suite (OMS) on the HDInsight cluster. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param parameters: The Operations Management Suite (OMS) workspace parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_enable_monitoring( + self, + resource_group_name: str, + cluster_name: str, + parameters: Union[_models.ClusterMonitoringRequest, IO], + **kwargs: Any + ) -> LROPoller[None]: + """Enables the Operations Management Suite (OMS) on the HDInsight cluster. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param parameters: The Operations Management Suite (OMS) workspace parameters. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.hdinsight.models.ClusterMonitoringRequest 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._enable_monitoring_initial( + raw_result = self._enable_monitoring_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_enable_monitoring.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/clustermonitoring'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_enable_monitoring.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/clustermonitoring"} # type: ignore + + @distributed_trace def get_monitoring_status( - self, - resource_group_name, # type: str - cluster_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ClusterMonitoringResponse" + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> _models.ClusterMonitoringResponse: """Gets the status of Operations Management Suite (OMS) on the HDInsight cluster. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ClusterMonitoringResponse, or the result of cls(response) + :return: ClusterMonitoringResponse or the result of cls(response) :rtype: ~azure.mgmt.hdinsight.models.ClusterMonitoringResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClusterMonitoringResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - accept = "application/json" - - # Construct URL - url = self.get_monitoring_status.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 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.ClusterMonitoringResponse] + + request = build_get_monitoring_status_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_monitoring_status.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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ClusterMonitoringResponse', pipeline_response) + deserialized = self._deserialize("ClusterMonitoringResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_monitoring_status.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/clustermonitoring'} # type: ignore - def _disable_monitoring_initial( - self, - resource_group_name, # type: str - cluster_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + get_monitoring_status.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/clustermonitoring"} # type: ignore + + def _disable_monitoring_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_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-06-01" - accept = "application/json" - - # Construct URL - url = self._disable_monitoring_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 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_disable_monitoring_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._disable_monitoring_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _disable_monitoring_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/clustermonitoring'} # type: ignore + _disable_monitoring_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/clustermonitoring"} # type: ignore - def begin_disable_monitoring( - self, - resource_group_name, # type: str - cluster_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + @distributed_trace + def begin_disable_monitoring(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> LROPoller[None]: """Disables the Operations Management Suite (OMS) on the HDInsight cluster. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. 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._disable_monitoring_initial( + raw_result = self._disable_monitoring_initial( # type: ignore resource_group_name=resource_group_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'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_disable_monitoring.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/clustermonitoring'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - def _enable_azure_monitor_initial( + begin_disable_monitoring.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/clustermonitoring"} # type: ignore + + def _enable_azure_monitor_initial( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - cluster_name, # type: str - parameters, # type: "_models.AzureMonitorRequest" - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + resource_group_name: str, + cluster_name: str, + parameters: Union[_models.AzureMonitorRequest, IO], + **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._enable_azure_monitor_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 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(parameters, 'AzureMonitorRequest') - 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[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AzureMonitorRequest") + + request = build_enable_azure_monitor_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._enable_azure_monitor_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _enable_azure_monitor_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/azureMonitor'} # type: ignore + _enable_azure_monitor_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/azureMonitor"} # type: ignore + @overload def begin_enable_azure_monitor( self, - resource_group_name, # type: str - cluster_name, # type: str - parameters, # type: "_models.AzureMonitorRequest" - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + cluster_name: str, + parameters: _models.AzureMonitorRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: """Enables the Azure Monitor on the HDInsight cluster. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param parameters: The Log Analytics workspace parameters. + :param parameters: The Log Analytics workspace parameters. Required. :type parameters: ~azure.mgmt.hdinsight.models.AzureMonitorRequest + :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_enable_azure_monitor( + self, + resource_group_name: str, + cluster_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Enables the Azure Monitor on the HDInsight cluster. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param parameters: The Log Analytics workspace parameters. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_enable_azure_monitor( + self, + resource_group_name: str, + cluster_name: str, + parameters: Union[_models.AzureMonitorRequest, IO], + **kwargs: Any + ) -> LROPoller[None]: + """Enables the Azure Monitor on the HDInsight cluster. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param parameters: The Log Analytics workspace parameters. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.hdinsight.models.AzureMonitorRequest 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._enable_azure_monitor_initial( + raw_result = self._enable_azure_monitor_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_enable_azure_monitor.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/azureMonitor'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_enable_azure_monitor.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/azureMonitor"} # type: ignore + @distributed_trace def get_azure_monitor_status( - self, - resource_group_name, # type: str - cluster_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AzureMonitorResponse" + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> _models.AzureMonitorResponse: """Gets the status of Azure Monitor on the HDInsight cluster. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AzureMonitorResponse, or the result of cls(response) + :return: AzureMonitorResponse or the result of cls(response) :rtype: ~azure.mgmt.hdinsight.models.AzureMonitorResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureMonitorResponse"] 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-06-01" - accept = "application/json" - - # Construct URL - url = self.get_azure_monitor_status.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + 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.AzureMonitorResponse] + + request = build_get_azure_monitor_status_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_azure_monitor_status.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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AzureMonitorResponse', pipeline_response) + deserialized = self._deserialize("AzureMonitorResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_azure_monitor_status.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/azureMonitor'} # type: ignore - def _disable_azure_monitor_initial( - self, - resource_group_name, # type: str - cluster_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + get_azure_monitor_status.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/azureMonitor"} # type: ignore + + def _disable_azure_monitor_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, cluster_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-06-01" - accept = "application/json" - - # Construct URL - url = self._disable_azure_monitor_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + 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_disable_azure_monitor_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._disable_azure_monitor_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _disable_azure_monitor_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/azureMonitor'} # type: ignore + _disable_azure_monitor_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/azureMonitor"} # type: ignore + @distributed_trace def begin_disable_azure_monitor( - self, - resource_group_name, # type: str - cluster_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> LROPoller[None]: """Disables the Azure Monitor on the HDInsight cluster. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. 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._disable_azure_monitor_initial( + raw_result = self._disable_azure_monitor_initial( # type: ignore resource_group_name=resource_group_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'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_disable_azure_monitor.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/azureMonitor'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_disable_azure_monitor.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/azureMonitor"} # type: ignore - def _create_initial( + def _create_initial( # pylint: disable=inconsistent-return-statements self, - resource_group_name, # type: str - cluster_name, # type: str - extension_name, # type: str - parameters, # type: "_models.Extension" - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + resource_group_name: str, + cluster_name: str, + extension_name: str, + parameters: Union[_models.Extension, IO], + **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-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'extensionName': self._serialize.url("extension_name", extension_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Extension') - 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[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "Extension") + + request = build_create_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + extension_name=extension_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/{extensionName}'} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/{extensionName}"} # type: ignore + @overload def begin_create( self, - resource_group_name, # type: str - cluster_name, # type: str - extension_name, # type: str - parameters, # type: "_models.Extension" - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + cluster_name: str, + extension_name: str, + parameters: _models.Extension, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: """Creates an HDInsight cluster extension. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param extension_name: The name of the cluster extension. + :param extension_name: The name of the cluster extension. Required. :type extension_name: str - :param parameters: The cluster extensions create request. + :param parameters: The cluster extensions create request. Required. :type parameters: ~azure.mgmt.hdinsight.models.Extension + :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_create( + self, + resource_group_name: str, + cluster_name: str, + extension_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Creates an HDInsight cluster extension. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param extension_name: The name of the cluster extension. Required. + :type extension_name: str + :param parameters: The cluster extensions create request. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + cluster_name: str, + extension_name: str, + parameters: Union[_models.Extension, IO], + **kwargs: Any + ) -> LROPoller[None]: + """Creates an HDInsight cluster extension. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param extension_name: The name of the cluster extension. Required. + :type extension_name: str + :param parameters: The cluster extensions create request. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.hdinsight.models.Extension 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._create_initial( + raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, extension_name=extension_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'extensionName': self._serialize.url("extension_name", extension_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/{extensionName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/{extensionName}"} # type: ignore + + @distributed_trace def get( - self, - resource_group_name, # type: str - cluster_name, # type: str - extension_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ClusterMonitoringResponse" + self, resource_group_name: str, cluster_name: str, extension_name: str, **kwargs: Any + ) -> _models.ClusterMonitoringResponse: """Gets the extension properties for the specified HDInsight cluster extension. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param extension_name: The name of the cluster extension. + :param extension_name: The name of the cluster extension. Required. :type extension_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ClusterMonitoringResponse, or the result of cls(response) + :return: ClusterMonitoringResponse or the result of cls(response) :rtype: ~azure.mgmt.hdinsight.models.ClusterMonitoringResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClusterMonitoringResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-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'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'extensionName': self._serialize.url("extension_name", extension_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.ClusterMonitoringResponse] + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + extension_name=extension_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # 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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ClusterMonitoringResponse', pipeline_response) + deserialized = self._deserialize("ClusterMonitoringResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/{extensionName}'} # type: ignore - def _delete_initial( - self, - resource_group_name, # type: str - cluster_name, # type: str - extension_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/{extensionName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, cluster_name: str, extension_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-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'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'extensionName': self._serialize.url("extension_name", extension_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, + cluster_name=cluster_name, + extension_name=extension_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - # 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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/{extensionName}'} # type: ignore + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/{extensionName}"} # type: ignore + @distributed_trace def begin_delete( - self, - resource_group_name, # type: str - cluster_name, # type: str - extension_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + self, resource_group_name: str, cluster_name: str, extension_name: str, **kwargs: Any + ) -> LROPoller[None]: """Deletes the specified extension for HDInsight cluster. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param extension_name: The name of the cluster extension. + :param extension_name: The name of the cluster extension. Required. :type extension_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, extension_name=extension_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'extensionName': self._serialize.url("extension_name", extension_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + 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.HDInsight/clusters/{clusterName}/extensions/{extensionName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/{extensionName}"} # type: ignore + + @distributed_trace def get_azure_async_operation_status( - self, - resource_group_name, # type: str - cluster_name, # type: str - extension_name, # type: str - operation_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AsyncOperationResult" + self, resource_group_name: str, cluster_name: str, extension_name: str, operation_id: str, **kwargs: Any + ) -> _models.AsyncOperationResult: """Gets the async operation status. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param extension_name: The name of the cluster extension. + :param extension_name: The name of the cluster extension. Required. :type extension_name: str - :param operation_id: The long running operation id. + :param operation_id: The long running operation id. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AsyncOperationResult, or the result of cls(response) + :return: AsyncOperationResult or the result of cls(response) :rtype: ~azure.mgmt.hdinsight.models.AsyncOperationResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AsyncOperationResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - accept = "application/json" - - # Construct URL - url = self.get_azure_async_operation_status.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'extensionName': self._serialize.url("extension_name", extension_name, 'str'), - 'operationId': self._serialize.url("operation_id", operation_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.AsyncOperationResult] + + request = build_get_azure_async_operation_status_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + extension_name=extension_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_azure_async_operation_status.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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AsyncOperationResult', pipeline_response) + deserialized = self._deserialize("AsyncOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_azure_async_operation_status.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/{extensionName}/azureAsyncOperations/{operationId}'} # type: ignore + + get_azure_async_operation_status.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/extensions/{extensionName}/azureAsyncOperations/{operationId}"} # type: ignore diff --git a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/operations/_locations_operations.py b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/operations/_locations_operations.py index 1436a03193efb..95cdbd2833218 100644 --- a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/operations/_locations_operations.py +++ b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/operations/_locations_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,397 +6,690 @@ # 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, 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 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_get_capabilities_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", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.HDInsight/locations/{location}/capabilities", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_usages_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", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.HDInsight/locations/{location}/usages" + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_billing_specs_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", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.HDInsight/locations/{location}/billingSpecs", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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="GET", url=_url, params=_params, headers=_headers, **kwargs) -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]] +def build_get_azure_async_operation_status_request( + location: str, operation_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) -class LocationsOperations(object): - """LocationsOperations operations. + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.HDInsight/locations/{location}/azureasyncoperations/{operationId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + } - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.hdinsight.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_check_name_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", "2021-06-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.HDInsight/locations/{location}/checkNameAvailability", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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_validate_cluster_create_request_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", "2021-06-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.HDInsight/locations/{location}/validateCreateRequest", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "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) + + +class LocationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.hdinsight.HDInsightManagementClient`'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") - def get_capabilities( - self, - location, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.CapabilitiesResult" + @distributed_trace + def get_capabilities(self, location: str, **kwargs: Any) -> _models.CapabilitiesResult: """Gets the capabilities for the specified location. - :param location: The Azure location (region) for which to make the request. + :param location: The Azure location (region) for which to make the request. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CapabilitiesResult, or the result of cls(response) + :return: CapabilitiesResult or the result of cls(response) :rtype: ~azure.mgmt.hdinsight.models.CapabilitiesResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CapabilitiesResult"] 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-06-01" - accept = "application/json" - - # Construct URL - url = self.get_capabilities.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - '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 = kwargs.pop("headers", {}) or {} + _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.CapabilitiesResult] - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + request = build_get_capabilities_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_capabilities.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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CapabilitiesResult', pipeline_response) + deserialized = self._deserialize("CapabilitiesResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_capabilities.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HDInsight/locations/{location}/capabilities'} # type: ignore - def list_usages( - self, - location, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.UsagesListResult" + get_capabilities.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.HDInsight/locations/{location}/capabilities"} # type: ignore + + @distributed_trace + def list_usages(self, location: str, **kwargs: Any) -> _models.UsagesListResult: """Lists the usages for the specified location. - :param location: The Azure location (region) for which to make the request. + :param location: The Azure location (region) for which to make the request. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: UsagesListResult, or the result of cls(response) + :return: UsagesListResult or the result of cls(response) :rtype: ~azure.mgmt.hdinsight.models.UsagesListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UsagesListResult"] 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-06-01" - accept = "application/json" - - # Construct URL - url = self.list_usages.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - '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 = 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.UsagesListResult] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_list_usages_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_usages.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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('UsagesListResult', pipeline_response) + deserialized = self._deserialize("UsagesListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_usages.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HDInsight/locations/{location}/usages'} # type: ignore - def list_billing_specs( - self, - location, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.BillingResponseListResult" + list_usages.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.HDInsight/locations/{location}/usages"} # type: ignore + + @distributed_trace + def list_billing_specs(self, location: str, **kwargs: Any) -> _models.BillingResponseListResult: """Lists the billingSpecs for the specified subscription and location. - :param location: The Azure location (region) for which to make the request. + :param location: The Azure location (region) for which to make the request. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BillingResponseListResult, or the result of cls(response) + :return: BillingResponseListResult or the result of cls(response) :rtype: ~azure.mgmt.hdinsight.models.BillingResponseListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BillingResponseListResult"] 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-06-01" - accept = "application/json" - - # Construct URL - url = self.list_billing_specs.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - '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 = 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.BillingResponseListResult] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_list_billing_specs_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_billing_specs.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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('BillingResponseListResult', pipeline_response) + deserialized = self._deserialize("BillingResponseListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_billing_specs.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HDInsight/locations/{location}/billingSpecs'} # type: ignore + list_billing_specs.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.HDInsight/locations/{location}/billingSpecs"} # type: ignore + + @distributed_trace def get_azure_async_operation_status( - self, - location, # type: str - operation_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AsyncOperationResult" + self, location: str, operation_id: str, **kwargs: Any + ) -> _models.AsyncOperationResult: """Get the async operation status. - :param location: The Azure location (region) for which to make the request. + :param location: The Azure location (region) for which to make the request. Required. :type location: str - :param operation_id: The long running operation id. + :param operation_id: The long running operation id. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AsyncOperationResult, or the result of cls(response) + :return: AsyncOperationResult or the result of cls(response) :rtype: ~azure.mgmt.hdinsight.models.AsyncOperationResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AsyncOperationResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - accept = "application/json" - - # Construct URL - url = self.get_azure_async_operation_status.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'location': self._serialize.url("location", location, 'str'), - 'operationId': self._serialize.url("operation_id", operation_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.AsyncOperationResult] + + request = build_get_azure_async_operation_status_request( + location=location, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_azure_async_operation_status.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 + ) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AsyncOperationResult', pipeline_response) + deserialized = self._deserialize("AsyncOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_azure_async_operation_status.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HDInsight/locations/{location}/azureasyncoperations/{operationId}'} # type: ignore + get_azure_async_operation_status.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.HDInsight/locations/{location}/azureasyncoperations/{operationId}"} # type: ignore + + @overload def check_name_availability( self, - location, # type: str - parameters, # type: "_models.NameAvailabilityCheckRequestParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.NameAvailabilityCheckResult" + location: str, + parameters: _models.NameAvailabilityCheckRequestParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NameAvailabilityCheckResult: """Check the cluster name is available or not. - :param location: The Azure location (region) for which to make the request. + :param location: The Azure location (region) for which to make the request. Required. :type location: str - :param parameters: + :param parameters: Required. :type parameters: ~azure.mgmt.hdinsight.models.NameAvailabilityCheckRequestParameters + :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: NameAvailabilityCheckResult or the result of cls(response) + :rtype: ~azure.mgmt.hdinsight.models.NameAvailabilityCheckResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, location: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.NameAvailabilityCheckResult: + """Check the cluster name is available or not. + + :param location: The Azure location (region) for which to make the request. Required. + :type location: str + :param parameters: Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: NameAvailabilityCheckResult or the result of cls(response) + :rtype: ~azure.mgmt.hdinsight.models.NameAvailabilityCheckResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, location: str, parameters: Union[_models.NameAvailabilityCheckRequestParameters, IO], **kwargs: Any + ) -> _models.NameAvailabilityCheckResult: + """Check the cluster name is available or not. + + :param location: The Azure location (region) for which to make the request. Required. + :type location: str + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.hdinsight.models.NameAvailabilityCheckRequestParameters 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: NameAvailabilityCheckResult, or the result of cls(response) + :return: NameAvailabilityCheckResult or the result of cls(response) :rtype: ~azure.mgmt.hdinsight.models.NameAvailabilityCheckResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NameAvailabilityCheckResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'location': self._serialize.url("location", location, '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(parameters, 'NameAvailabilityCheckRequestParameters') - 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[_models.NameAvailabilityCheckResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NameAvailabilityCheckRequestParameters") + + request = build_check_name_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_name_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 + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NameAvailabilityCheckResult', pipeline_response) + deserialized = self._deserialize("NameAvailabilityCheckResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HDInsight/locations/{location}/checkNameAvailability'} # type: ignore + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.HDInsight/locations/{location}/checkNameAvailability"} # type: ignore + + @overload def validate_cluster_create_request( self, - location, # type: str - parameters, # type: "_models.ClusterCreateRequestValidationParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.ClusterCreateValidationResult" + location: str, + parameters: _models.ClusterCreateRequestValidationParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ClusterCreateValidationResult: """Validate the cluster create request spec is valid or not. - :param location: The Azure location (region) for which to make the request. + :param location: The Azure location (region) for which to make the request. Required. :type location: str - :param parameters: + :param parameters: Required. :type parameters: ~azure.mgmt.hdinsight.models.ClusterCreateRequestValidationParameters + :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: ClusterCreateValidationResult, or the result of cls(response) + :return: ClusterCreateValidationResult or the result of cls(response) :rtype: ~azure.mgmt.hdinsight.models.ClusterCreateValidationResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def validate_cluster_create_request( + self, location: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ClusterCreateValidationResult: + """Validate the cluster create request spec is valid or not. + + :param location: The Azure location (region) for which to make the request. Required. + :type location: str + :param parameters: Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ClusterCreateValidationResult or the result of cls(response) + :rtype: ~azure.mgmt.hdinsight.models.ClusterCreateValidationResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def validate_cluster_create_request( + self, location: str, parameters: Union[_models.ClusterCreateRequestValidationParameters, IO], **kwargs: Any + ) -> _models.ClusterCreateValidationResult: + """Validate the cluster create request spec is valid or not. + + :param location: The Azure location (region) for which to make the request. Required. + :type location: str + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.hdinsight.models.ClusterCreateRequestValidationParameters 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: ClusterCreateValidationResult or the result of cls(response) + :rtype: ~azure.mgmt.hdinsight.models.ClusterCreateValidationResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ClusterCreateValidationResult"] 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-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate_cluster_create_request.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - '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') - - # 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(parameters, 'ClusterCreateRequestValidationParameters') - 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[_models.ClusterCreateValidationResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ClusterCreateRequestValidationParameters") + + request = build_validate_cluster_create_request_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.validate_cluster_create_request.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ClusterCreateValidationResult', pipeline_response) + deserialized = self._deserialize("ClusterCreateValidationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - validate_cluster_create_request.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.HDInsight/locations/{location}/validateCreateRequest'} # type: ignore + + validate_cluster_create_request.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.HDInsight/locations/{location}/validateCreateRequest"} # type: ignore diff --git a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/operations/_operations.py b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/operations/_operations.py index b5f55534be2ed..4e04499ca7570 100644 --- a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/operations/_operations.py +++ b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/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", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") -class Operations(object): - """Operations operations. + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.HDInsight/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.hdinsight.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.hdinsight.HDInsightManagementClient`'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.OperationListResult"] + 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 HDInsight REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.hdinsight.models.OperationListResult] - :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.hdinsight.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _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.OperationListResult] + 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-06-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('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -94,17 +137,18 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.HDInsight/operations'} # type: ignore + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.HDInsight/operations"} # type: ignore diff --git a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/operations/_patch.py b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/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/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/operations/_private_endpoint_connections_operations.py b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/operations/_private_endpoint_connections_operations.py index 62273e935e76c..0814d68a97eaf 100644 --- a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/operations/_private_endpoint_connections_operations.py +++ b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/operations/_private_endpoint_connections_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,101 +6,270 @@ # 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_by_cluster_request( + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/privateEndpointConnections", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + cluster_name: str, + private_endpoint_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", "2021-06-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.HDInsight/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_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_get_request( + resource_group_name: str, + cluster_name: str, + private_endpoint_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", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_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_delete_request( + resource_group_name: str, + cluster_name: str, + private_endpoint_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", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_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 PrivateEndpointConnectionsOperations: + """ + .. 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 PrivateEndpointConnectionsOperations(object): - """PrivateEndpointConnectionsOperations 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.hdinsight.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.hdinsight.HDInsightManagementClient`'s + :attr:`private_endpoint_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_by_cluster( - self, - resource_group_name, # type: str - cluster_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PrivateEndpointConnectionListResult"] + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnection"]: """Lists the private endpoint connections for a HDInsight cluster. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.hdinsight.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.hdinsight.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] + _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.PrivateEndpointConnectionListResult] + 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-06-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_by_cluster.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_cluster_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_cluster.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('PrivateEndpointConnectionListResult', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -108,337 +278,428 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_cluster.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/privateEndpointConnections'} # type: ignore + return ItemPaged(get_next, extract_data) + + list_by_cluster.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/privateEndpointConnections"} # type: ignore def _create_or_update_initial( self, - resource_group_name, # type: str - cluster_name, # type: str - private_endpoint_connection_name, # type: str - parameters, # type: "_models.PrivateEndpointConnection" - **kwargs # type: Any - ): - # type: (...) -> "_models.PrivateEndpointConnection" - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] + resource_group_name: str, + cluster_name: str, + private_endpoint_connection_name: str, + parameters: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: 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-06-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'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_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(parameters, 'PrivateEndpointConnection') - 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.PrivateEndpointConnection] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PrivateEndpointConnection") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + private_endpoint_connection_name=private_endpoint_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + @overload def begin_create_or_update( self, - resource_group_name, # type: str - cluster_name, # type: str - private_endpoint_connection_name, # type: str - parameters, # type: "_models.PrivateEndpointConnection" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.PrivateEndpointConnection"] + resource_group_name: str, + cluster_name: str, + private_endpoint_connection_name: str, + parameters: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: """Approve or reject a private endpoint connection manually. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str - :param parameters: The private endpoint connection create or update request. + :param parameters: The private endpoint connection create or update request. Required. :type parameters: ~azure.mgmt.hdinsight.models.PrivateEndpointConnection + :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 PrivateEndpointConnection 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 PrivateEndpointConnection or the result + of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hdinsight.models.PrivateEndpointConnection] :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - 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, + cluster_name: str, + private_endpoint_connection_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Approve or reject a private endpoint connection manually. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param parameters: The private endpoint connection create or update request. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hdinsight.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + cluster_name: str, + private_endpoint_connection_name: str, + parameters: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Approve or reject a private endpoint connection manually. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param parameters: The private endpoint connection create or update request. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.hdinsight.models.PrivateEndpointConnection 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 PrivateEndpointConnection or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hdinsight.models.PrivateEndpointConnection] + :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.PrivateEndpointConnection] + 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, cluster_name=cluster_name, private_endpoint_connection_name=private_endpoint_connection_name, parameters=parameters, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) - + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}'} # 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.HDInsight/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + @distributed_trace def get( - self, - resource_group_name, # type: str - cluster_name, # type: str - private_endpoint_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PrivateEndpointConnection" + self, resource_group_name: str, cluster_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: """Gets the specific private endpoint connection. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.hdinsight.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-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'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_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.PrivateEndpointConnection] + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + private_endpoint_connection_name=private_endpoint_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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - def _delete_initial( - self, - resource_group_name, # type: str - cluster_name, # type: str - private_endpoint_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, cluster_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-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'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_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, + cluster_name=cluster_name, + private_endpoint_connection_name=private_endpoint_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + @distributed_trace def begin_delete( - self, - resource_group_name, # type: str - cluster_name, # type: str - private_endpoint_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + self, resource_group_name: str, cluster_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> LROPoller[None]: """Deletes the specific private endpoint connection. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_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, cluster_name=cluster_name, private_endpoint_connection_name=private_endpoint_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'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/operations/_private_link_resources_operations.py b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/operations/_private_link_resources_operations.py index 50556d4b7138d..362b132285048 100644 --- a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/operations/_private_link_resources_operations.py +++ b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/operations/_private_link_resources_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,165 +6,237 @@ # 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, Optional, TypeVar + +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 + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_cluster_request( + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/privateLinkResources", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, cluster_name: str, private_link_resource_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, Optional, TypeVar + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/privateLinkResources/{privateLinkResourceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "privateLinkResourceName": _SERIALIZER.url("private_link_resource_name", private_link_resource_name, "str"), + } -class PrivateLinkResourcesOperations(object): - """PrivateLinkResourcesOperations operations. + _url = _format_url_section(_url, **path_format_arguments) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.hdinsight.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 PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.hdinsight.HDInsightManagementClient`'s + :attr:`private_link_resources` 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_by_cluster( - self, - resource_group_name, # type: str - cluster_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PrivateLinkResourceListResult" + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> _models.PrivateLinkResourceListResult: """Lists the private link resources in a HDInsight cluster. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResourceListResult, or the result of cls(response) + :return: PrivateLinkResourceListResult or the result of cls(response) :rtype: ~azure.mgmt.hdinsight.models.PrivateLinkResourceListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - accept = "application/json" - - # Construct URL - url = self.list_by_cluster.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 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.PrivateLinkResourceListResult] + + request = build_list_by_cluster_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_cluster.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 + ) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResourceListResult', pipeline_response) + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_cluster.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/privateLinkResources'} # type: ignore + list_by_cluster.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/privateLinkResources"} # type: ignore + + @distributed_trace def get( - self, - resource_group_name, # type: str - cluster_name, # type: str - private_link_resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PrivateLinkResource" + self, resource_group_name: str, cluster_name: str, private_link_resource_name: str, **kwargs: Any + ) -> _models.PrivateLinkResource: """Gets the specific private link resource. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param private_link_resource_name: The name of the private link resource. + :param private_link_resource_name: The name of the private link resource. Required. :type private_link_resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResource, or the result of cls(response) + :return: PrivateLinkResource or the result of cls(response) :rtype: ~azure.mgmt.hdinsight.models.PrivateLinkResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-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'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'privateLinkResourceName': self._serialize.url("private_link_resource_name", private_link_resource_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 {}) + + _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.PrivateLinkResource] + + request = build_get_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + private_link_resource_name=private_link_resource_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 + ) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResource', pipeline_response) + deserialized = self._deserialize("PrivateLinkResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/privateLinkResources/{privateLinkResourceName}'} # type: ignore + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/privateLinkResources/{privateLinkResourceName}"} # type: ignore diff --git a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/operations/_script_actions_operations.py b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/operations/_script_actions_operations.py index 73c74d1340974..fcad10c3faf43 100644 --- a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/operations/_script_actions_operations.py +++ b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/operations/_script_actions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,160 +6,307 @@ # 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, _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_delete_request( + resource_group_name: str, cluster_name: str, script_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", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/scriptActions/{scriptName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "scriptName": _SERIALIZER.url("script_name", script_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_cluster_request( + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/scriptActions", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_execution_detail_request( + resource_group_name: str, cluster_name: str, script_execution_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", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/scriptExecutionHistory/{scriptExecutionId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "scriptExecutionId": _SERIALIZER.url("script_execution_id", script_execution_id, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +def build_get_execution_async_operation_status_request( + resource_group_name: str, cluster_name: str, operation_id: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") -class ScriptActionsOperations(object): - """ScriptActionsOperations operations. + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/executeScriptActions/azureasyncoperations/{operationId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + } - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + _url = _format_url_section(_url, **path_format_arguments) - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.hdinsight.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ScriptActionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.hdinsight.HDInsightManagementClient`'s + :attr:`script_actions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def delete( - self, - resource_group_name, # type: str - cluster_name, # type: str - script_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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 delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, cluster_name: str, script_name: str, **kwargs: Any + ) -> None: """Deletes a specified persisted script action of the cluster. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param script_name: The name of the script. + :param script_name: The name of the script. Required. :type script_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-06-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'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'scriptName': self._serialize.url("script_name", script_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, + cluster_name=cluster_name, + script_name=script_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/scriptActions/{scriptName}'} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/scriptActions/{scriptName}"} # type: ignore + @distributed_trace def list_by_cluster( - self, - resource_group_name, # type: str - cluster_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ScriptActionsList"] + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> Iterable["_models.RuntimeScriptActionDetail"]: """Lists all the persisted script actions for the specified cluster. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ScriptActionsList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.hdinsight.models.ScriptActionsList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either RuntimeScriptActionDetail or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.hdinsight.models.RuntimeScriptActionDetail] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScriptActionsList"] + _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.ScriptActionsList] + 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-06-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_by_cluster.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_cluster_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_cluster.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('ScriptActionsList', pipeline_response) + deserialized = self._deserialize("ScriptActionsList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -167,145 +315,146 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_cluster.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/scriptActions'} # type: ignore + return ItemPaged(get_next, extract_data) + list_by_cluster.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/scriptActions"} # type: ignore + + @distributed_trace def get_execution_detail( - self, - resource_group_name, # type: str - cluster_name, # type: str - script_execution_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RuntimeScriptActionDetail" + self, resource_group_name: str, cluster_name: str, script_execution_id: str, **kwargs: Any + ) -> _models.RuntimeScriptActionDetail: """Gets the script execution detail for the given script execution ID. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param script_execution_id: The script execution Id. + :param script_execution_id: The script execution Id. Required. :type script_execution_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: RuntimeScriptActionDetail, or the result of cls(response) + :return: RuntimeScriptActionDetail or the result of cls(response) :rtype: ~azure.mgmt.hdinsight.models.RuntimeScriptActionDetail - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.RuntimeScriptActionDetail"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - accept = "application/json" - - # Construct URL - url = self.get_execution_detail.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'scriptExecutionId': self._serialize.url("script_execution_id", script_execution_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.RuntimeScriptActionDetail] + + request = build_get_execution_detail_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + script_execution_id=script_execution_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_execution_detail.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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('RuntimeScriptActionDetail', pipeline_response) + deserialized = self._deserialize("RuntimeScriptActionDetail", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_execution_detail.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/scriptExecutionHistory/{scriptExecutionId}'} # type: ignore + get_execution_detail.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/scriptExecutionHistory/{scriptExecutionId}"} # type: ignore + + @distributed_trace def get_execution_async_operation_status( - self, - resource_group_name, # type: str - cluster_name, # type: str - operation_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AsyncOperationResult" + self, resource_group_name: str, cluster_name: str, operation_id: str, **kwargs: Any + ) -> _models.AsyncOperationResult: """Gets the async operation status of execution operation. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param operation_id: The long running operation id. + :param operation_id: The long running operation id. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AsyncOperationResult, or the result of cls(response) + :return: AsyncOperationResult or the result of cls(response) :rtype: ~azure.mgmt.hdinsight.models.AsyncOperationResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AsyncOperationResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - accept = "application/json" - - # Construct URL - url = self.get_execution_async_operation_status.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'operationId': self._serialize.url("operation_id", operation_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.AsyncOperationResult] + + request = build_get_execution_async_operation_status_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_execution_async_operation_status.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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AsyncOperationResult', pipeline_response) + deserialized = self._deserialize("AsyncOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_execution_async_operation_status.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/executeScriptActions/azureasyncoperations/{operationId}'} # type: ignore + + get_execution_async_operation_status.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/executeScriptActions/azureasyncoperations/{operationId}"} # type: ignore diff --git a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/operations/_script_execution_history_operations.py b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/operations/_script_execution_history_operations.py index c540085ae1ba7..22131c65c38a2 100644 --- a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/operations/_script_execution_history_operations.py +++ b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/operations/_script_execution_history_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,99 +6,183 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import 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 ScriptExecutionHistoryOperations(object): - """ScriptExecutionHistoryOperations 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_by_cluster_request( + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.hdinsight.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", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/scriptExecutionHistory", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_promote_request( + resource_group_name: str, cluster_name: str, script_execution_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", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/scriptExecutionHistory/{scriptExecutionId}/promote", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "scriptExecutionId": _SERIALIZER.url("script_execution_id", script_execution_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="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class ScriptExecutionHistoryOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.hdinsight.HDInsightManagementClient`'s + :attr:`script_execution_history` 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_by_cluster( - self, - resource_group_name, # type: str - cluster_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ScriptActionExecutionHistoryList"] + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> Iterable["_models.RuntimeScriptActionDetail"]: """Lists all scripts' execution history for the specified cluster. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ScriptActionExecutionHistoryList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.hdinsight.models.ScriptActionExecutionHistoryList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either RuntimeScriptActionDetail or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.hdinsight.models.RuntimeScriptActionDetail] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ScriptActionExecutionHistoryList"] + _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.ScriptActionExecutionHistoryList] + 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-06-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_by_cluster.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_cluster_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_cluster.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('ScriptActionExecutionHistoryList', pipeline_response) + deserialized = self._deserialize("ScriptActionExecutionHistoryList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -106,78 +191,78 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response - return ItemPaged( - get_next, extract_data - ) - list_by_cluster.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/scriptExecutionHistory'} # type: ignore - - def promote( - self, - resource_group_name, # type: str - cluster_name, # type: str - script_execution_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + return ItemPaged(get_next, extract_data) + + list_by_cluster.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/scriptExecutionHistory"} # type: ignore + + @distributed_trace + def promote( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, cluster_name: str, script_execution_id: str, **kwargs: Any + ) -> None: """Promotes the specified ad-hoc script execution to a persisted script. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param script_execution_id: The script execution Id. + :param script_execution_id: The script execution Id. Required. :type script_execution_id: 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-06-01" - accept = "application/json" - - # Construct URL - url = self.promote.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'scriptExecutionId': self._serialize.url("script_execution_id", script_execution_id, 'str'), - } - 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[None] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_promote_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + script_execution_id=script_execution_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.promote.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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - promote.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/scriptExecutionHistory/{scriptExecutionId}/promote'} # type: ignore + promote.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/scriptExecutionHistory/{scriptExecutionId}/promote"} # type: ignore diff --git a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/operations/_virtual_machines_operations.py b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/operations/_virtual_machines_operations.py index e01cfdd68dc6d..008c461bf9300 100644 --- a/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/operations/_virtual_machines_operations.py +++ b/sdk/hdinsight/azure-mgmt-hdinsight/azure/mgmt/hdinsight/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,288 +6,469 @@ # 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, List, Optional, TypeVar, Union, cast, 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 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_hosts_request( + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/listHosts", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_restart_hosts_request( + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-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.HDInsight/clusters/{clusterName}/restartHosts", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_async_operation_status_request( + resource_group_name: str, cluster_name: str, operation_id: 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, List, Optional, TypeVar, Union + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + accept = _headers.pop("Accept", "application/json") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/restartHosts/azureasyncoperations/{operationId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + } -class VirtualMachinesOperations(object): - """VirtualMachinesOperations operations. + _url = _format_url_section(_url, **path_format_arguments) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.hdinsight.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 VirtualMachinesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.hdinsight.HDInsightManagementClient`'s + :attr:`virtual_machines` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - def list_hosts( - self, - resource_group_name, # type: str - cluster_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> List["_models.HostInfo"] + @distributed_trace + def list_hosts(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> List[_models.HostInfo]: """Lists the HDInsight clusters hosts. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of HostInfo, or the result of cls(response) + :return: list of HostInfo or the result of cls(response) :rtype: list[~azure.mgmt.hdinsight.models.HostInfo] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.HostInfo"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - accept = "application/json" - - # Construct URL - url = self.list_hosts.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 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[List[_models.HostInfo]] + + request = build_list_hosts_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_hosts.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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('[HostInfo]', pipeline_response) + deserialized = self._deserialize("[HostInfo]", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_hosts.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/listHosts'} # type: ignore - def _restart_hosts_initial( - self, - resource_group_name, # type: str - cluster_name, # type: str - hosts, # type: List[str] - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] + list_hosts.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/listHosts"} # type: ignore + + def _restart_hosts_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, cluster_name: str, hosts: Union[List[str], IO], **kwargs: Any + ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._restart_hosts_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), + 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(hosts, '[str]') - 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(hosts, (IO, bytes)): + _content = hosts + else: + _json = self._serialize.body(hosts, "[str]") + + request = build_restart_hosts_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._restart_hosts_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _restart_hosts_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/restartHosts'} # type: ignore + _restart_hosts_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/restartHosts"} # type: ignore + @overload def begin_restart_hosts( self, - resource_group_name, # type: str - cluster_name, # type: str - hosts, # type: List[str] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + cluster_name: str, + hosts: List[str], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: """Restarts the specified HDInsight cluster hosts. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param hosts: The list of hosts to restart. + :param hosts: The list of hosts to restart. Required. :type hosts: list[str] + :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_restart_hosts( + self, + resource_group_name: str, + cluster_name: str, + hosts: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Restarts the specified HDInsight cluster hosts. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param hosts: The list of hosts to restart. Required. + :type hosts: 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_restart_hosts( + self, resource_group_name: str, cluster_name: str, hosts: Union[List[str], IO], **kwargs: Any + ) -> LROPoller[None]: + """Restarts the specified HDInsight cluster hosts. + + :param resource_group_name: The name of the resource group. Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param hosts: The list of hosts to restart. Is either a list type or a IO type. Required. + :type hosts: list[str] 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._restart_hosts_initial( + raw_result = self._restart_hosts_initial( # type: ignore resource_group_name=resource_group_name, cluster_name=cluster_name, hosts=hosts, - cls=lambda x,y,z: x, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) + kwargs.pop("error_map", None) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - } - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_restart_hosts.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/restartHosts'} # type: ignore + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_restart_hosts.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/restartHosts"} # type: ignore + @distributed_trace def get_async_operation_status( - self, - resource_group_name, # type: str - cluster_name, # type: str - operation_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AsyncOperationResult" + self, resource_group_name: str, cluster_name: str, operation_id: str, **kwargs: Any + ) -> _models.AsyncOperationResult: """Gets the async operation status. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. Required. :type resource_group_name: str - :param cluster_name: The name of the cluster. + :param cluster_name: The name of the cluster. Required. :type cluster_name: str - :param operation_id: The long running operation id. + :param operation_id: The long running operation id. Required. :type operation_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AsyncOperationResult, or the result of cls(response) + :return: AsyncOperationResult or the result of cls(response) :rtype: ~azure.mgmt.hdinsight.models.AsyncOperationResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AsyncOperationResult"] 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-06-01" - accept = "application/json" - - # Construct URL - url = self.get_async_operation_status.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'clusterName': self._serialize.url("cluster_name", cluster_name, 'str'), - 'operationId': self._serialize.url("operation_id", operation_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.AsyncOperationResult] + + request = build_get_async_operation_status_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + operation_id=operation_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_async_operation_status.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) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AsyncOperationResult', pipeline_response) + deserialized = self._deserialize("AsyncOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_async_operation_status.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/restartHosts/azureasyncoperations/{operationId}'} # type: ignore + + get_async_operation_status.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HDInsight/clusters/{clusterName}/restartHosts/azureasyncoperations/{operationId}"} # type: ignore